SmallBASIC GuideThe language | Programming Tips | Commands | System | Graphics & Sound | Miscellaneous | File system | Mathematics | 2D Algebra | Strings | Console | Glossary |
Loops and variables

When we write loops it is much better to initialize the counters on the top of the loop instead of the top of the program or nowhere.
i = 0
REPEAT
  ...
  i = i + 1
UNTIL i > 10
Initializing the variables at the top of the loop, can make code better readable, and can protect us from usual pitfalls such as forgetting to giving init value or re-run the loop without reset the variables.


[Prev] [Next]