Line Numbers
Line numbers remained until the third pass. GOS. 175 is a function call to line 175 that prints the Enterprise's location. As the main functions and code flow were identified, unnecesary line numbers were removed. I left the Gosub line numbers in as comments, in case I missed one.
Use of variables
In Tiny Basic all variables are global and there is no concept of local variables. This simplifies understanding but makes it easy to introduce bugs.Initially I thought I'd leave all variables.in and use them as they were. However, changing them to more meaningful names made a lot more sense and vastly increased the readability.
Lines 120 and 125 use S, G, L, P, R, W and T variables to hold the line number of the subroutines that do the main commands. That's what the Goto A in line 125 does! The if in that line is just a clever switch statement. Inside an if statement a + is more like ||, and a * is like an &&.
This is quite clever- what do you think it (line 20) does?
20 M=R.(Y),M=(M<209)+(M<99)+(M<49)+(M<24)+(M<9)+(M<2)The first assignment to M is a random number between 1 and Y. The 2nd assignment to M (after the comma) sets it to 0 to 5 depending on the value of M. If M is 209 or higher then all these tests fail and the value assigned is 0. If M was 16 then it is less than 209, less than 99 and less than 49 so it has a value of 3. Each test that passes adds 1 to M.
On the next page Learn about converting arrays

