Strange Numbers in file_var_read

Posted By: Dooley

Strange Numbers in file_var_read - 06/06/17 22:42

I am using external files to save data. Occasionally, when my function opens a particular file, it gets strange data out of it that was never actually in the file.

I am using local variables in my function to store the data from the file. I have also made sure that only one instance of the function can access the file at a particular time.

I can't figure out where this strange data is coming from. If you reach the end of a file it should return zero, but in this case it is returning strange numbers, like 675.794 or -.001

I have a code that tells the game to stop reading if the number does not match a certain expected number (I added numbers to the file writing sequence to do this) but it still somehow reads these strange numbers from the file.

It's as if the function is being fed numbers from some source other than the external file.

Does this sound like a known bug of some kind? Or perhaps it's a problem someone encountered before?
Posted By: Dooley

Re: Strange Numbers in file_var_read - 06/08/17 20:19

Okay, I'm just following up with my solution. It's pretty obvious, and I should have caught it much sooner, and I'm kind of embarrassed to explain what happened, but for the good of the Game-Studio community, here goes:

I forgot to assign my variables a 0 value when I declared them.

I (almost) always assign a value when I declare variable. I don't know why I did not in this case, but that's why it took me so long to figure it out.

Happy programming!
© 2024 lite-C Forums