Optional GOTO

From Maze

Jump to: navigation, search

Regarding this variation of 10 Print:

for a=1 to 2 step 0:print chr$(205.5+rnd(1));:next a

Nick writes:

Since you can type more than one statement at a time directly at the BASIC prompt by using ":", I have a variant of this program that doesn't use a line number. That is, it is typed in DIRECT Mode (as when you type 'PRINT "HELLO"' and press return) rather than in PROGRAM mode (when you use line numbers to construct a program and type RUN to run it).

This looks bit odd, but it isn't exploiting any bugs in BASIC. The FOR ... TO ... STEP statement is defined so that an increment of 0 is allowed: "Any value can be used as the STEP increment." (Commodore 64 Programmer's Reference Guide p. 86).

I don't think there's any reason to suggest that this is a cleaner version or that GOTO and a line number should be avoided -- quite the contrary. But it shows that these two staples of BASIC are not needed to produce our maze.

Personal tools