IF to if (
R.( to Random()
R. to return
REM to //
F. to for
N. to next. This commented the loop end.
GOS. is a function call. I left these in as reminders for the next pass.
G. is a goto and again I left them in as comments to help unravel the structure.
Note that Gosub (GOS.) translates to a void function call, which returns no values.
Overall Approach to Conversion
This is a straight forward program. Though there are less than 150 lines of code, many are multiple statements, like a block { of code } and after conversion to C, it was 6 times as long! There were no comments but with a bit of teasing, the structure of the program wasn't too difficult to unravel.I went for a multi pass approach.
- First pass : Cut and Paste each abbreviation to transform it into a C like syntax. Add brackets to correct the syntax of if statements. Change = inside if () to ==.
- Second Pass. Try and identify the structure. Basic is notorious for "easy to write" spaghetti code, and older Basics use line numbers which does not make reading the code any easier. So identifying subroutines and code blocks was the objective here.
- Third Pass. Edit to make it compileable. Remove line numbers, change Gosubs to function calls, add variable declarations and hopefully end up with a nearly working program.
- Fourth Pass. Test, test, and test.
On the next page Converting by Cut and Paste

