I essentially have the app nearly the way i want it.. But....!
The first launch when installed on a real device fails to return the values from on location changed.
This is something to do with the fact that i am in on preOpenCard, creating a data stack, as if i dont create that data stack, it works as expected.
It is as if i have something in the code that is firing before the data stack is created that depends on it. But i cant really see that i have.
If i close the app on the device and restart the app it all works as expected.
Code: Select all
global tDataPath
on preOpenCard
put specialFolderPath("documents") into tDataPath
put tDataPath & "/virtAppData.livecode" into tDataPath
if not (there is a file tDataPath) then
create stack "vertDataStack"
put it into temp
set the visible of temp to false
set the filename of temp to tDataPath
save temp
go stack "vertigo"
end if
# mobGUIStart ---> Inserted by mobGUI plugin
if "MobGUILib-1309576541555.448975" is not among the lines of the stacksInUse then start using stack "MobGUILib-1309576541555.448975"
mobGUIPreOpenCard me
# mobGUIEnd
end preOpenCard
on openCard
iphoneStartTrackingLocation
put the alltimehigh of stack tDataPath into field "alltimehigh"
end openCard
on locationChanged
put iphoneCurrentLocation() into tLocation
put the round of tLocation["altitude"] into tHeightInMeters
put tHeightInMeters * 3.280839895 into tHeightInFeet
put the round of tHeightInFeet into tHeightInFeet
put field "units" into tFeetOrMeters
if tFeetOrMeters = "Ft" then
send "tmUpdateGauge" && tHeightInFeet to group "howhigh"
else
send "tmUpdateGauge" && tHeightInMeters to group "howhigh"
end if
if tHeightInMeters > the alltimehigh of stack tDataPath then
put tHeightInMeters into field "allTimeHigh"
set the alltimehigh of stack tDataPath to tHeightInMeters
end if
end locationChanged
on locationError
answer "The current location cannot be determined."
end locationError
on closeCard
iphoneStopTrackingLocation
save stack tDataPath
end closeCard