I've spent the last couple of days trying to debug my script but I have had no luck and can see no reason why it doesn't work. So I thought a fresh set of eyes might be able to spot something...
So the first card script is:
Code: Select all
global tLatitudeListA
global tLatitudeList
global tLatitudeMax
global tLatitudeMin
global tLongitudeListA
global tLongitudeList
global tLongitudeMax
global tLongitudeMin
global tAltitudeListA
global tAltitudeList
global tAltitudeMax
global tAltitudeMin
global counterVar
global itemCount
on openCard
put EMPTY into fld "Latitude" of this card
put EMPTY into fld "Longitude" of this card
put EMPTY into fld "Altitude" of this card
put EMPTY into fld "countField" of this card
end openCard
on locationChanged pLatitude, pLongitude, pAltitude
put pAltitude & cr after fld "Altitude" of this card
put pLatitude & cr after fld "Latitude" of this card
put pLongitude & cr after fld "Longitude" of this card
add 1 to counterVar
put counterVar into fld "countField" of this card
end locationChanged
on findMinMaxLat
put fld "Latitude" of this card into tLatitudeList
put tLatitudeList into tLatitudeListA
replace cr with comma in tLatitudeList
put max(tLatitudeList) into tLatitudeMax
put min(tLatitudeList) into tLatitudeMin
end findMinMaxLat
on findMinMaxLon
put fld "Longitude" of this card into tLongitudeList
put tLongitudeList into tLongitudeListA
replace cr with comma in tLongitudeList
put max(tLongitudeList) into tLongitudeMax
put min(tLongitudeList) into tLongitudeMin
end findMinMaxLon
on findMinMaxAlt
put fld "Altitude" of this card into tAltitudeList
put tAltitudeList into tAltitudeListA
replace cr with comma in tAltitudeList
put max(tAltitudeList) into tAltitudeMax
put min(tAltitudeList) into tAltitudeMin
end findMinMaxAlt
on errorDialog pExecutionError, pParseError
answer "An error occurred on line: " & item 2 of line 1 of pExecutionError & cr & pExecutionError
end errorDialog
There is a start button with this script :
Code: Select all
global counterVar
on mouseUp
put 0 into counterVar
if the environment is "mobile" then
if mobileCanTrackLocation() is true then
mobileStartTrackingSensor "location"
else
answer "Can't find your location"
end if
end if
end mouseUp
Code: Select all
on mouseUp
mobileStopTrackingSensor "location"
findMinMaxLat
findMinMaxLon
findMinMaxAlt
end mouseUp
Code: Select all
global tLatitudeListA
global tLatitudeList
global tLatitudeMax
global tLatitudeMin
global tLongitudeListA
global tLongitudeList
global tLongitudeMax
global tLongitudeMin
global tAltitudeListA
global tAltitudeList
global tAltitudeMax
global tAltitudeMin
global itemCountA
local xLocA
local zLocA
local yLocA
local yLocNewA
local xLocNewA
local zLocNewA
local G
on openCard
lock screen
repeat with G = 1 to the number of graphics of this card
if the short name of graphic G begins with "grcLoc" then
delete graphic G
end if
end repeat
set the opaque of the templateGraphic to true
repeat with itemCountA = 1 to the number of lines of tLatitudeListA
put line itemCountA of tLatitudeListA into xLocA
put line itemCountA of tLongitudeListA into yLocA
put line itemCountA of tAltitudeListA into zLocA
put (((xLocA - tLatitudeMin) * (60 - 320)) / (tLatitudeMax - tLatitudeMin)) + 320 into yLocNewA
put (((yLocA - tLongitudeMin) * (60 - 320)) / (tLongitudeMax - tLongitudeMin)) + 320 into xLocNewA
put (((zLocA - tAltitudeMin) * (3 - 1)) / (tAltitudeMax - tAltitudeMin)) + 3 into zLocNewA
put fnSnapNumbers(yLocNewA,20,10) into yLocNewA
put fnSnapNumbers(xLocNewA,20,10) into xLocNewA
put xLocNewA & comma & yLocNewA into tSquareLoc
add 1 to tLocsArr[(tSquareLoc)]
end repeat
put the keys of tLocsArr into tKeys
repeat for each line tKey in tKeys
create graphic
put it into tNewGrcIDa
set the name of the last graphic to ("grcLoc" & tNewGrcIDa)
set the loc of graphic ("grcLoc" & tNewGrcIDa) to (tKey)
set the style of the last grc to oval
set the height of the last grc to 10
set the width of the last grc to 10
set the backgroundColor of the last grc to black
set the blendlevel of the last grc to 0
if tLocsArr[(tKey)] < 20 then
set the blendLevel of graphic ("grcLoc" & tNewGrcIDa) to 70-tLocsArr[(tKey)]
set the textColor of the last grc to 36,203,185
else if tLocsArr[(tKey)] < 40 then
set the blendLevel of graphic ("grcLoc" & tNewGrcIDa) to 70-tLocsArr[(tKey)]
set the textColor of the last grc to 245,54,16
else if tLocsArr[(tKey)] < 60 then
set the blendLevel of graphic ("grcLoc" & tNewGrcIDa) to 70-tLocsArr[(tKey)]
set the textColor of the last grc to 253,50,81
else if tLocsArr[(tKey)] < 80 then
set the blendLevel of graphic ("grcLoc" & tNewGrcIDa) to 70-tLocsArr[(tKey)]
set the textColor of the last grc to 147,16,123
else if tLocsArr[(tKey)] < 100 then
set the blendLevel of graphic ("grcLoc" & tNewGrcIDa) to 70-tLocsArr[(tKey)]
set the textColor of the last grc to 18,67,97
else
set the blendLevel of graphic ("grcLoc" & tNewGrcIDa) to 70-tLocsArr[(tKey)]
set the textColor of the last grc to 49,138,225
end if
set the width of graphic ("grcLoc" & tNewGrcIDa) to 8+ (tLocsArr[(tKey)] / 30)
set the height of graphic ("grcLoc" & tNewGrcIDa) to 8 + (tLocsArr[(tKey)]/30)
set the lineSize of graphic ("grcLoc" & tNewGrcIDa) to 2+ (tLocsArr[(tKey)] / 40)
end repeat
unlock screen
reset the templateGraphic
end openCard
on closeCard
lock screen
put the number of graphics into theGraphsCount
repeat with currentGraphic = theGraphsCount down to 1
if there is a graphic currentGraphic then
delete graphic currentGraphic
end if
end repeat
end closeCard
function fnSnapNumbers pNum,pSnapGap,pSnapOffset
put pNum mod pSnapGap into tM
put max(0,round(tM-pSnapOffset - 9,-1)) into tM
put trunc((pNum-1) / pSnapGap) * pSnapGap into tN
return tN + tM + pSnapOffset
end fnSnapNumbers
Thanks!