Regularity
From Maze
(Difference between revisions)
(Added that line number is optional in last variant.) | (→FOR ... TO ... STEP (Sidebar)) | ||
| Line 227: | Line 227: | ||
30 NEXT</nowiki> | 30 NEXT</nowiki> | ||
| − | This allows for an alternate version of 10 PRINT, slightly longer but still a "one-liner" of no more than 80 characters, that uses a FOR loop instead of GOTO: | + | This allows for an alternate version of 10 PRINT that uses a FOR loop instead of GOTO: |
<nowiki>10 FOR A=1 TO 2 STEP 0 : PRINT CHR$(205.5+RND(1)); : NEXT</nowiki> | <nowiki>10 FOR A=1 TO 2 STEP 0 : PRINT CHR$(205.5+RND(1)); : NEXT</nowiki> | ||
| − | In fact, in this version the "10" at the beginning is optional. The three statements can be entered together in immediate mode, just as one can type <code>PRINT "HELLO"</code> and have the PRINT statement executed immediately: | + | This one is slightly longer and exceeds the 40 characters of a physical line but still a "one-liner" in the sense that it fits into the 80 character logical line. |
| − | <nowiki>10 FOR A=1 TO 2 STEP 0 : PRINT CHR$(205.5+RND(1)); : NEXT</nowiki> | + | In this version, the "10" at the beginning is optional. The three statements can be entered together in immediate mode, just as one can type <code>PRINT "HELLO"</code> and have the PRINT statement executed immediately: |
| + | |||
| + | <nowiki>FOR A=1 TO 2 STEP 0 : PRINT CHR$(205.5+RND(1)); : NEXT</nowiki> | ||
The only reason the line number is needed in the original program is as a point to branch back to. As GOTO goes, so goes the line number. | The only reason the line number is needed in the original program is as a point to branch back to. As GOTO goes, so goes the line number. | ||
