Losing the value of a constant

Hello All - I am trying to initialize the position of a sprite based on GPS and then move it as my phone moves. I initialize Xstart and Ystart to the initial GPS location, and also Xnow and Ynow. Then when you hit the start button, it computes an X and Y coordinate for the sprite to start at. It does this correctly, with the initial Xstart and Ystart being equal so the result being pixel 120,120. Then as I move, the timer should update Xnow and Ynow and produce a new pixel location. But for some reason, when the timer fires, Xstart and Ystart become zero even though I have not changed them. Can anyone say why this is and what to do about it? Code here:

![Purple

Hmmm...no picture - I hope the image is accessible

You're doing a dump of the geolocation and screen coordinates to see where it fails you.

It would be interesting for you to follow it to understand if it always fails at some inconsistent moment for you.

It's just my suggestion.

Thanks - it always fails (ie changes the values) as soon as the timer fires. I currently have that set for ten seconds so that I have time to observe. Everything is fine up to that point, then the values of Xstart and Ystart are changed to zero for reasons unknown. I need them to stay at their original values (ie where I started) so that I can plot the change in location.

Hi Tom,
looking at your code how can you say that at the beginning xstart and ystart are different from 0 ?
You say : It does this correctly, with the initial Xstart and Ystart being equal so the result being pixel 120,120.
But you initialize both Xstart and Xnow at Longitude and both Ystart, and Ynow at Latitude. Therefore you expect that their difference is 0 leading to the formula 120 + ((30000 * (Xnow- Ystart)) = 120. But this is true also if Xstart is initially = 0.
Then I'am afraid that Xstart is always = 0.
My suggestion is to print Xstart in the Button1 event, to be sure it is not = 0.
The same for Ystart.
What are your thoughts about ?
Cheers!

Well, that is a good suggestion and I will try it but I doubt it is going to work because when the timer fires, the values of Xnow and Ynow are correct, and they are computed the same way. But lets see.....

Well hey - YOU WERE RIGHT - now I just have to see why they didnt initialize correctly - but that I can address - THANKS

Hi Tom,
I'm glad it works. Another hint is to put the Xstart and Ystart initial setting in Button1.... (?).
:thinking:

...or in Screen1 _Initialize. Just to not let the Xstart and Ystart being initialized during the global variable declaration... :roll_eyes:

Yes, I put them inside the start button - at first I got a bad result but then it seems to be resolved. I will experiment some more and see what happens - but GREAT SUGGESTIONS

:smile:
Happy of that !

My friend you are the best :slight_smile:

Sorry not having replied before. My PC has crashed the boot record, so I was not able to use it.
I've changed the broken SSD and now I have recovered, but I have to re-install all.
:worried:

Hey, I'm very good with hardware, if you need help with something, I'll be happy to help you.

Greetings

Thanks Andy, now everything is solved. I've replaced the SSD and I've restored data and app's.
Anyway, I take your advice for future needs .. :smirk:.
Cheers !

to send :+1: :innocent: