Board Thread:Questions and Answers/@comment-24454571-20140517053531/@comment-5334617-20140519181917

Randomouscrap98's answer is good; not to detract from that, but I think I can answer other parts of your post too.

I'll explain a little about READ and RESTORE. What RESTORE does is, it tells Petit Computer, "Next time you see a READ, start looking for DATA from here". What READ does is, it tells Petit Computer "Start looking for the next DATA, when you find some value, put it in the variable I tell you".

An important aspect of READ is that it looks for the next DATA. If there is no RESTORE, then "the next" DATA, the very first time, is the first DATA. READ does not try and take data from the next line of code whatever it may be, it will skip over any line of code that's not DATA until it finds a DATA.

In Randomousecrap98's image, when you start the program, the crane is over the first line of code, and when the crane is activated by a READ command, it will skip over anything that's not DATA.

"I would expect that you would need to somehow relate these two functions together in a statement that would say something like, "In relation to the Dimension MAP, these loops, dadadadadada""... in more sophisticted programming environments, you have constructions like this. In BASIC, the first index to the array is a numerical value, nothing more, nothing less. Anything that is a numerical value will do (after it is rounded, and provided it's not negative or out-of-bounds). FOR gives numerical values to a variable name. You don't have to say, "the purpose of this numerical value is to act as an index into the array", you just have to say "this is a numerical value", and then just use it that way. Or, to put it another way, the way you relate the two functions together is through the variable: you put the variable in the FOR, and you put the variable where the code wants an index to the array, and that's how they're related. It's simple, and yes, there's something missing there, that another programming language would allow you to express - but not SmileBasic. You're overthinking. :)

"I figured that this was a statement that declared the existence of the variable in the first place." In SmileBasic V2, variables are not declared at all. Try starting up SmileBasic, and typing "PRINT VAR1". You will get 0. You will not get an error, even though this variable has never been declared, and this variable has never been written to. Try "PRINT LEN(VAR2$)", you will also get 0. Any and every variable name is a variable, in potentia. That potential becomes realized whenever the variable is accessed, either read from or written to. If a numerical variable is read from before it is written to, its default value is 0, and if a string variable is read from before it is written to, its default value is the empty string. Again, other programming environments have different philosophies on what is the correct thing to do for these kinds of circumstances. But, a simplification of SmileBasic's model is: every variable name is essentially 'declared', all the time, and every variable is essentially initialized to either 0 or "". If you're even using the phrase 'declare a variable', you're overthinking again, as far as SmileBasic is concerned. :)

That you are concerned about these kinds of issues suggests to me that you may appreciate, and get a lot out of, computer science courses - or at least, from learning other types of programming language. You're thinking on a higher level than SmileBasic - go find a programming language that's a more suitable playground for your brain!