Page 1 of 1

Adding numbers to a field SOLVED

Posted: Fri Jan 16, 2015 5:21 pm
by calmrr3
Hello,

I am trying to figure out a way of adding numbers to a field (currently I am adding the latitude to a field each time the location changes).

I want each number to be added to the field but on a new line.


Then, when I press the stop button (which stops tracking the location) I would like to be able to get the highest and lowest values.

Currently I have this script on the card which adds the latitude values to the field but they dont take a new line each time one is added:

Code: Select all

global counterVar
global allXCoords

on locationChanged pLatitude, pLongitude, pAltitude
   
   put pAltitude into field "altitude"
   put pLatitude into field "latitude"
   put pLongitude into field "longitude"
   put counterVar into field "counter"
   add 1 to counterVar
   put counterVar into field "counter"
   
   put pLatitude & comma after allXCoords
   put allXCoords into field "allX"
   
end locationChanged  pLatitude, pLongitude, pAltitude


on errorDialog pExecutionError, pParseError
   answer "An error occurred on line: " & item 2 of line 1 of pExecutionError & cr & pExecutionError
end errorDialog

Re: Adding numbers to a field

Posted: Fri Jan 16, 2015 5:42 pm
by dave.kilroy
Hi calmrr3

Instead of "put pLatitude into field "latitude"" try "put pLatitude & cr after field "latitude""

And in the code of your 'stop' button (or in a handler on your card that is called by the button) have something like:

Code: Select all

on findMinMax
   put fld "Latitude" into tList
   replace cr with comma in tList
   put max(tList) into tMax
   put min(tList) into tMin
   answer "Max: " & tMax & cr & "Min: " & tMin
end findMinMax
By the way the reason why I change carriage returns to commas is that the max() and min() functions expect a comma delimited list.

Dave

Re: Adding numbers to a field

Posted: Fri Jan 16, 2015 5:51 pm
by calmrr3
Excellent, works perfectly!
Thank you!