Thanks a lot Mark.
2 little notes.
1. if you need to declare multiple variables of the same type, just list them all and at the end add the AS clause. So:
[code=thinbasic]DIM n AS INTEGER, x AS INTEGER, y AS INTEGER, z AS INTEGER[/code]
is shorted into
[code=thinbasic]DIM n, x, y, z AS INTEGER[/code]
2. under 32 bit programming languages, it is always better to use LONG data type when you need to use integer class numbers. LONG are natively managed by processor, are better handled by thinBasic, are faster because in many cases thinBasic makes some internal optimization if LONG numbers are used.
Possibly use INTEGER numbers only if really needed, for example inside data structures used to pass in/out data to external functions (external DLL or windows API) but only because external data requires them to be used.
[code=thinbasic]DIM n, x, y, z AS LONG[/code]