The description of the exact steps of the For( loop was horrendously wrong. Before it said the behavior of For(var,start,end[,step]) was:
- Set var to equal start.
- Run all the statement(s).
- Increase the value of var by step (or by 1, if you didn't provide a step)
- As long as var is no greater than end (or no less than, if step is negative), go back to step 2.
It's actually:
- Set var to equal start.
- If var is greater than end (or less than, if step is negative), quit the For loop immediately.
- Run the statements.
- Add step to var.
Thus, we can have For( loops that never run the statements, and also, the variable usually ends up being end + step after the loop is over. I felt the need to point this out because, considering the For( loop is one of the most fundamental parts of BASIC, this is a big deal.
Example: if you run For(A,B,0:End, with B>0, then what you've just done is set B to A without changing Ans. This could be useful in many situations.
Example 2: You can use the loop counter after the loop ends for useful things. In order to do this, you need to know what the loop counter should equal after you leave the loop.
Perhaps we should document the behavior of the loop counter after the loop closes.