This program is a data-entry and printing tool for creating a Magic-User spell list reference sheet for Dungeons & Dragons, designed for use with an 80-column printer. It collects spell names for all nine spell levels (levels 1–9) in groups of three per row, packing them into three large string arrays: A$ (40 rows × 64 characters, covering levels 1–3), B$ (34 rows × 64 characters, covering levels 4–6), and C$ (26 rows × 64 characters, covering levels 7–9). Each row concatenates three 20-character spell name strings to fill the 64-character row width, using a blank array E$ as a reset/clear mechanism between entries. The program is intentionally entered via GO TO 610 rather than RUN, as noted in line 3, to avoid re-initialising the arrays after a SAVE/LOAD cycle; line 9900 contains a commented-out machine code call (RAND USR 14336) suggesting the author was aware of or experimented with a machine code save routine.
Program Analysis
Program Purpose and Structure
The program collects Magic-User spell names for Dungeons & Dragons across nine spell levels, packs them into three large string arrays, and prints them across three pages on an 80-column printer. The workflow is divided into four logical phases:
- Initialisation (lines 5–80): Dimension declarations for temporary single-row string arrays and the three main data arrays.
- Data entry (lines 200–590): Three nested loops collect spells for levels 1–3 (40 entries), 4–6 (34 entries), and 7–9 (26 entries).
- Menu/pause (lines 600–605): A
STOPwith on-screen instructions directs the user toGO TO 610orGO TO 9900. - Print output (lines 610–800): Three LPRINT loops dump each array, separated by printer-reset pauses.
Array Design and Memory Layout
Three two-dimensional string arrays hold all spell data:
| Array | Dimensions | Total chars | Spell levels |
|---|---|---|---|
A$() | 40 × 64 | 2560 | 1, 2, 3 |
B$() | 34 × 64 | 2176 | 4, 5, 6 |
C$() | 26 × 64 | 1664 | 7, 8, 9 |
Each row is formed by concatenating three 20-character temporary strings (e.g., F$(1)+S$(1)+T$(1)), which exactly fills the 60-character content portion of the 64-character row. The remaining 4 characters are left as spaces due to the fixed-length string array padding behaviour of Sinclair BASIC.
Temporary String Array Idiom
Rather than using simple string variables, the author uses single-row DIM arrays (E$, F$, S$, T$, U$, V$, X$, Z$, P$, Q$) each dimensioned to 20 characters (DIM x$(1,20)). This exploits the fixed-length nature of Sinclair string arrays: INPUT into F$(1) automatically pads or truncates the entry to exactly 20 characters, which is required for the row concatenation to produce a predictable 60-character string. Simple string variables would not provide this guarantee.
After each row is assembled and stored, each temporary array is reset by assignment from the blank E$(1) (which was never assigned to, so it contains 20 spaces by default), effectively clearing the buffer for the next iteration.
Entry Point Design (GO TO vs RUN)
Line 3 explicitly warns NEVER RUN, USE GOTO 610. This is because RUN in Sinclair BASIC clears all variables, which would destroy the data held in A$, B$, and C$ after a break or SAVE. By directing users to GO TO 610, the program resumes printing without reinitialising the arrays. The STOP at line 605 also serves as a controlled breakpoint rather than an error condition, again preserving variable memory.
Print Paging and PAUSE Idiom
Lines 704–706 and 764–766 instruct the user to reset the printer between pages, using PAUSE 4E4 (i.e., PAUSE 40000, approximately 27 minutes) as an indefinite wait — effectively waiting for a keypress since any key press or interrupt terminates PAUSE. This is a common Sinclair BASIC idiom for “press any key to continue” without using INKEY$ polling.
Save Routine (Lines 9900–9920)
Lines 9900 and 9910 contain REMmed-out statements: a machine code call RAND USR 14336 and a SAVE "MUSPLS.B1". These suggest the author experimented with a machine code fast-save routine but ultimately reverted to a standard SAVE at line 9915. After saving, line 9920 loops back to 610 to allow immediate reprinting without data loss.
Notable Observations and Minor Issues
- The 64-character row width of
A$,B$, andC$exceeds the 60 characters produced by three 20-character fields; the last 4 characters of each row will always be spaces, wasting a small amount of memory but causing no functional problem. - The loop counts (40, 34, 26) for the three arrays are asymmetric and appear to reflect the author’s chosen total spell slots per level group rather than a standard D&D table, so the actual spell capacity per level is implicitly 40, 34, and 26 named spells respectively across three levels each.
- The variable name
Zis reused as both the loop counter (lines 200–590) and as an array name (Z$()), which is permissible in Sinclair BASIC since numeric variables and string arrays occupy separate namespaces. - Line 9900’s comment refers to address 14336 (0x3800), a common target for machine code utilities in Sinclair systems.
Content
Source Code
0 REM %M%A%G%I%C%-%U%S%E%R%S% %S%P%E%L%L% %L%I%S%T BY ANTHONY WILLING 3-1-86 FOR DUNGEONS AND DRAGONS 80 COLUMN PRINTER REQUIRED
3 REM %N%E%V%E%R% %R%U%N%,% %U%S%E% %G%O%T%O% %6%1%0
5 DIM E$(1,20)
10 DIM F$(1,20)
20 DIM S$(1,20)
30 DIM T$(1,20)
40 DIM U$(1,20)
50 DIM V$(1,20)
60 DIM X$(1,20)
70 DIM Z$(1,20)
71 DIM P$(1,20)
72 DIM Q$(1,20)
80 DIM A$(40,64)
90 DIM B$(34,64)
100 DIM C$(26,64)
200 FOR Z=1 TO 40
210 PRINT "INPUT 1ST LEVEL SPELL ";Z
220 INPUT F$(1)
230 PRINT "INPUT 2ND LEVEL SPELL ";Z
240 INPUT S$(1)
250 PRINT "INPUT 3RD LEVEL SPELL ";Z
260 INPUT T$(1)
270 LET A$(Z)=F$(1)+S$(1)+T$(1)
280 LET F$(1)=E$(1)
290 LET S$(1)=E$(1)
300 LET T$(1)=E$(1)
310 CLS
320 NEXT Z
350 FOR Z=1 TO 34
360 PRINT "INPUT 4TH LEVEL SPELL ";Z
370 INPUT U$(1)
380 PRINT "INPUT 5TH LEVEL SPELL ";Z
390 INPUT V$(1)
391 PRINT "INPUT 6TH LEVEL SPELL ";Z
392 INPUT X$(1)
400 LET B$(Z)=U$(1)+V$(1)+X$(1)
410 LET U$(1)=E$(1)
420 LET V$(1)=E$(1)
425 LET X$(1)=E$(1)
430 CLS
440 NEXT Z
500 FOR Z=1 TO 26
530 PRINT "INPUT 7TH LEVEL SPELL ";Z
540 INPUT Z$(1)
541 PRINT "INPUT 8TH LEVEL SPELL ";Z
542 INPUT P$(1)
546 PRINT "INPUT 9TH LEVEL SPELL ";Z
548 INPUT Q$(1)
550 LET C$(Z)=Z$(1)+P$(1)+Q$(1)
560 LET Z$(1)=E$(1)
570 LET P$(1)=E$(1)
575 LET Q$(1)=E$(1)
580 CLS
590 NEXT Z
600 CLS
603 PRINT "GOTO 610 FOR SPELL LIST"
604 PRINT "GOTO 9900 TO SAVE"
605 STOP
610 PRINT "PRESS ANY KEY",,"TO PRINT SPELL LISTS"
620 PAUSE 4E4
630 LPRINT "MAGIC-USERS SPELLS"
650 LPRINT
660 LPRINT
670 FOR Z=1 TO 40
680 LPRINT A$(Z)
690 NEXT Z
700 LPRINT
701 LPRINT
704 PRINT "RESET PRINTER TO PRINT PAGE","TWO OF MAGIC USER SPELLS","PRESS ANY KEY TO CONTINUE"
706 PAUSE 4E4
708 CLS
715 LPRINT "MAGIC-USERS SPELLS"
716 LPRINT
717 LPRINT
720 FOR Z=1 TO 34
730 LPRINT B$(Z)
740 NEXT Z
750 LPRINT
760 LPRINT
764 PRINT "RESET PRINTER TO PRINT PAGE","THREE OF MAGIC USER SPELLS","PRESS ANY KEY TO CONTINUE"
766 PAUSE 4E4
768 CLS
770 LPRINT "MAGIC-USERS SPELLS"
771 LPRINT
772 LPRINT
774 FOR Z=1 TO 26
780 LPRINT C$(Z)
790 NEXT Z
800 STOP
9900 REM RAND USR 14336
9910 REM SAVE "MUSPLS.B1"
9915 SAVE "1020%9"
9920 GOTO 610
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
