ZX81 Program Ending

See all articles from QZX v6 n12
Author(s): Alex Burr (K5XY)
Publication: QZX
Pub Details: QZX v6 n12 (Volume 6, Issue 12)
Date: November 1988
Pages: 2-3

QZX for last month contained a simple program which performed calculations on parallel resistors. It left as an exercise for the reader a more sophisticated way of ending the program with the promise of another ending this month for those too busy to write their own. The ending was as follows.

200 PRINT
210 PRINT "DO YOU WANT TO DO
ANOTHER CALCULATION
(Y OR N)"
220 INPUT A$
230 IF A$="Y" THEN GOTO 100
240 PRINT "THAT IS ALL FOR NOW."
250 STOP

This ending, in line 230, recirculates program control back to line 100 if a Y is typed in. It passes control to line 240 and stops if anything other than a Y is entered.

Here are some lines to insert into that ending to stop the program only if an N is entered.

232 IF A$="N" THEN GOTO 240
234 PRINT "YOU DID NOT TYPE
EITHER A Y OR AN
N THEREFORE I AM
UNCERTAIN AS TO
WHAT YOU WANT ME
TO DO."
236 GOTO 200

This new ending asks the operator to answer the question about doing another calculation again if the first answer was not one of the two choiced offered. Note that here I have taken advantage of the gaps I left in the line numbers in the origianl program. I have still left some gaps for ohter lines if I happen to think of some useful ones.

Note also that all the lines after 200 could be saved for use in other, similar programs. Actually the lines 200 to 250 could be used as an ending in a wide variety of programs. You should keep a notevook of these useful parts of programs to make the creation of other programs easier. If this is done with this ending the lines should be remumbered to keep the line spacing at 10.