GPS and Conversion

forisco

Member
Licensed User
Hi,
if i write this :

lat = GPS.latitude
gradi = SubString(lat,0,2)
minuti = SubString(lat,2,2)
secondi = SubString(lat,5,4)
secondi = (minuti*0.6-Int(minuti*0.6))*60+secondi*0.0036

i obtain the FormatException error : why?
 

specci48

Well-Known Member
Licensed User
Longtime User
Hi forisco,

gps.latitude has the format ddmm.mm
So you should use:
secondi = SubString(lat,5,2)

Basic4ppc will not throw an error, if a SubString statement exceeds the original StrLength.


specci48
 

specci48

Well-Known Member
Licensed User
Longtime User
Do you get a correct latitude? What is the value of lat?
If you a developing on the device you could use a MsgBox for debugging.
 

forisco

Member
Licensed User
If i show only the lat variable, i obtain 4019.671835
The latitude is correct. The error is in the last line :

secondi = (minuti*0.6-Int(minuti*0.6))*60+secondi*0.0036

and i obtain the same error if i use a calculation in an other line, for example :

minuti = SubString(lat,2,2) * 0.6

It seem that b4ppc don't convert the SubString function in number...
 

forisco

Member
Licensed User
I solved my problem thanks to an old answer of Erel (simply, the best)!

When the GPS not send data, the gps.latitude variable is empty and i have my error!

I must check if gps works (with the status property) and all work fine!!!!

Wowwwwwwwww!!! :sign0136:
 
Top