Regularity

From Maze

(Difference between revisions)
Jump to: navigation, search
(Moved last paragraph from next section to here, revised)
(→Conditional and Unconditional Branching)
Line 34:Line 34:
<nowiki>10 INPUT A$
<nowiki>10 INPUT A$
−
20 IF A$ = "1" THEN PRINT "ONE" : END
+
20 IF A$ = "1" THEN PRINT "YOU TYPED ONE!" : END
−
30 PRINT "SOMETHING ELSE"</nowiki>
+
30 PRINT "SOMETHING ELSE..."</nowiki>
−
If, after running this program, the user types just the digit "1" and then presses RETURN, all of the statements on line 20 will be executed. "ONE" will be printed and then the program will terminate as END instructs. If the user types anything else before pressing RETURN, the flow of control moves to line 30 and PRINT "ONE" and END are skipped. "SOMETHING ELSE" is printed instead.
+
If, after running this program, the user types just the digit "1" and then presses RETURN, all of the statements on line 20 will be executed. "YOU TYPED ONE!" will be printed and then the program will terminate as END instructs. If the user types anything else before pressing RETURN, the flow of control moves to line 30; both the first PRINT statement and the END are skipped. "SOMETHING ELSE..." is printed instead.
Although there is no IF ... THEN statement in 10 PRINT, and the program does not by any interpretation contain a conditional branch, this short program does accomplish a very small-scale sort of variation. By computing 205.5+RND(1) and passing that value to the function CHR$, the program prints either PETSCII character 205 or PETSCII character 206. This variation between two characters is a one-bit variation, a selection from the smallest possible set of options. Yet, in combination with the regularity of a repeating processes and the regularity of the Commodore 64's screen grid, these selections take shape as something evocative and visually interesting.
Although there is no IF ... THEN statement in 10 PRINT, and the program does not by any interpretation contain a conditional branch, this short program does accomplish a very small-scale sort of variation. By computing 205.5+RND(1) and passing that value to the function CHR$, the program prints either PETSCII character 205 or PETSCII character 206. This variation between two characters is a one-bit variation, a selection from the smallest possible set of options. Yet, in combination with the regularity of a repeating processes and the regularity of the Commodore 64's screen grid, these selections take shape as something evocative and visually interesting.

Revision as of 11:15, 19 July 2011

View this revision of Regularity.

Personal tools