The Real World (ZX-81)
Michael Johnson
London, N16
Ever since I bought my ZX-81 and 16K RAM earlier this year I have been interested in discovering ways of using it to help me with the routine calculations and figure work associated with my job.
I have found that a number of routines and programs have proved to be very useful indeed: carry-outs, cash-flow projections and sales analyses are all much less of a chore than they used to be.
This routine may be of use to those who are interested in real world applications for the ZX-81. This routine allows you to enter any quantity of data as part of a single string.
The bits of data are separated by commas, following the convention of DATA statements found in other Basic dialects. The machine uses the commas to identify the bits of data ready for subsequent operations.
The input as a string seems to me to have two advantages: there is no need to wait for the cursor to reappear before inputting the next piece of data, and secondly, the string assignment allows direct inputting of an expression such as *7 or /25 which can be applied to the original data. Of course this routine is only one building block in what can be developed into a customised “Intelligent Calculator” program. One suggestion which I would make is to convert the broken-up bits of string into a dimensioned array for later re-use.
I should point out that this use of concatenated strings in the handling of numerical data does present certain pitfalls for the unwary. The routine I have mentioned is in fact derived from a mini-routine which can be used to explore and experiment with strings and numbers:
10 INPUT A$
20 INPUT B$
30 PRINT A$, B$
40 PRINT VAL (A$+B$)
50 RUN
Note that 2 followed by +2 gives 4. A$=”25″, B$=”/2″ gives 12.5. A$ = “23+2″, B$=”-5″ gives 20. Care needs to be taken with priorities and with bracketing. For example, A$ = “(4″, B$=”+4)/2″ gives 4. As a point of interest, someone may care to ponder for a moment why A$=”2+3″, B$=”3″ results in 35 and A$=”7+1″, B$=”4″ results in 21.
01 REM INTIALISE DATE, M JOHNSON
20 SCROLL
30 PRINT “INPUT DATA, SEPERATED BY COMMAS”
40 INPUT A$
50 SCROLL
60 PRINT A$
70 LET A$=A$+”,*”
80 LET B=1
90 LET C=1
100 SCROLL
110 PRINT “ENTER OPERATION AND EXPRESSION”
120 INPUT B$
130 CLS
140 PRINT AT 6,0; “DATA “; A$ (TO LEN A$-2),, B$
150 PRINT
160 FOR N=1 TO LEN A$
170 IF A$(N)<> “,” THEN GOTO 220
180 IF A$(N) = “*” THEN GOTO 230
190 LET C=N
200 PRINT VAL (A$(B TO C-1)+B$
210 LET B=C+1
220 NEXT N
230 GOTO 80
To conserve memory, delete lines 20, 50 and 100, and change line 140 to PRINT B$. The input for A$ needs to read for example “20, 456, 783, 12.5, 3″. The input for B$ needs to be something like “*5″ or “+200″ or “/100*25″.
Sub attack (ZX Spectrum)
Sorcerer’s castle (BBC)
Bomber (Vic-20)
The real world (ZX-81)
Gripe cure (ZX Spectrum)
The hawk (Atom)
Vic synth (Vic-20)
Visual recall (BBC)
New quirk (ZX-81)
Bit bandit (Atom)
Vic stick (Vic-20)
List self-starters (ZX-81)
Tape salvage (BBC)
Error fix (Atom)
Long line (Atom)
Quick peek (ZX-81)