Enter a value for X and for Y. The program prints which of the comparisons it tries are true, and the values of X AND Y and X OR Y, which follow the ZX81’s rules (any non-zero number counts as true). Answer Y to AGAIN? to try other values; the article suggests 0, 1 and -1 in different pairs.
The article explains how the 8K ROM’s AND and OR differ from other BASICs, and how to fit the program into 1K.
Published in Syntax November 1982 (Boolean Demonstration).
Source Code
5 REM "BOOLEAN DEMO"
10 PRINT "ENTER A VALUE FOR X."
20 INPUT X
30 PRINT X
35 PRINT
40 PRINT "ENTER A VALUE FOR Y."
50 INPUT Y
60 PRINT Y
70 IF X AND Y THEN GOSUB 300
80 IF X OR Y THEN GOSUB 400
90 IF NOT X THEN GOSUB 500
100 IF NOT Y THEN GOSUB 600
110 PRINT
120 PRINT "THE VALUE OF X AND Y IS . . ";
130 PRINT (X AND Y)
140 PRINT
150 PRINT "THE VALUE OF X OR Y IS . . ";
160 PRINT (X OR Y)
245 PRINT
255 PRINT "AGAIN? (Y/N)"
265 INPUT A$
275 IF A$="N" THEN GOTO 1005
285 IF A$="Y" THEN GOTO 705
295 GOTO 70
300 PRINT
310 PRINT "X AND Y WAS TRUE."
320 RETURN
400 PRINT
410 PRINT "X OR Y WAS TRUE."
420 RETURN
500 PRINT
510 PRINT "NOT X WAS TRUE."
520 RETURN
600 PRINT
610 PRINT "NOT Y WAS TRUE."
620 RETURN
705 CLS
715 GOTO 10
1005 CLS
1015 PRINT "THE END"Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

