I want to use a set of variable arrays to store direction and distance to trave
tedbeau
Posts: 48
I have a simple question (yeah right, they’re all simple if you know the answer).
I want to use a set of variable arrays to store direction and distance to travel. The user would input the direction and distance into the array using debug.
Here is the question, when the stamp is started or reset, are variable arrays and variables reset or cleared?
If so what are is the default value. In other words after I have the numbers in the array, when the program finishes, can I press reset, and run it again without entering, and also, if I want to change the array, do I need to clear out old values first, in case I use less numbers. I don’t want to program to use the old data if it’s still in the array after reset.
Thanks
[noparse][[/noparse]Moderator Added Subject]
Post Edited By Moderator (Chris Savage (Parallax)) : 4/1/2008 4:25:09 PM GMT
Comments
When you enter the data through debugin you will increment the index of the array by one each time , by keeping track of the index you will know exactly how many elements of the array·you are using·and you will ignore any elements of the array·beyond the stored index value.
Jeff T.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Terms like "top" and "bottom" can be misunderstood. In your code you're going to be using the address values. The above should keep you safe.
So from the replies it appears that the array elements are reset to 0 every start or reset. That would negate my plan of having a zero value serve as an end of usable data marker in the array. I guess I could use a different character. I think its possible to write a NULL into an array, isnt it? Or I could use unsounds suggestion and just track how many elements were filled using the index. Thats probably the "Correct" way to do it.
Whichever way you choose keeping track of the index is keeping track of your position, you can count from 0 to the upper limit of your index to travel one direction and the upper limit of the index to 0 to travel back or use an index value to perform a certain action at a certain position.
Jeff T.
Ted