I turned on my Apple //c with my work disk in it. When it booted up and the startup menu appeared, I accidently typed in 4 instead of 3 to start AppleWorks 3.0. AppleSoft came back with:
?BAD SUBSCRIPT ERROR IN 2110
So I list the program and the last section of the program including line 2110 deals with the menu choices starting at 2070. I did virtually no error checking.
Line 2080 converts the value of the input to a number. If you enter something that is not a number, this line returns a zero. This was for all intents and purposes an accidental form of error checking. I didn’t know that VAL() did that, didn’t even think of entering anything but numbers. This was a beginners mistake for me. I should have planned for all input and dealt with it.
In line 2090 if the number is zero, then we go do the menu again.
In line 2100, if the number is one then we quit the program, exiting to AppleSoft.
In line 2110 we execute the command for the menu choice.
What I know at this point after rereading the program, is I don’t deal with numbers less than zero or greater than one. I just assume the number is good and try to execute the command that goes with the menu choice, even if there isn’t one.
Fixing this won’t take much, we’ll redo two lines and add one more.
Change 2090 to check for numbers less than 1 (if the number is less than 1, then we do the menu again).
2090 IF C<1 THEN 2000
Change 2110 to check for numbers that are higher than then menu count (if the number is too big, then we do the menu again).
2110 IF C>MC THEN 2000
Put back the line to execute the menu command.
2120 PRINT CHR$(4);R$(C)
That fixes the problem and I’ve updated the disk image.

Leave a Reply