Clerical Spell List D&D

This file is part of and Timex Sinclair Public Domain Library Tape 1004. Download the collection to get this file.
Developer(s): Tony Willing
Date: 198x
Type: Program
Platform(s): TS 1000

This program manages and prints a Clerical Spell List for the Dungeons & Dragons tabletop role-playing game. It collects spell names for all seven clerical spell levels: 20 spells each for levels 1–3 (paired into 64-character strings in array A$), 16 spells each for levels 4–5 (stored in B$), and 12 spells each for levels 6–7 (stored in C$). Each pair or triplet of spell names is concatenated and packed into a single fixed-length string row using the DIM statement’s 64-character width. An 80-column printer is required to display the output correctly via LPRINT, and the program includes a SAVE routine at line 9900 to preserve entered data.


Program Analysis

Program Structure

The program is divided into four clear phases:

  1. Initialisation (lines 5–80): Declares single-row, 20-character working string arrays (E$ through Z$) used as temporary input buffers, plus a blank/empty reference array E$.
  2. Data entry (lines 200–600): Three loops collect spell names for levels 1–3 (20 entries each), levels 4–5 (16 entries each), and levels 6–7 (12 entries each), packing them into the storage arrays A$, B$, and C$.
  3. Print phase (lines 610–800): Entered via GO TO 610 (either directly after entry or on re-run), the program waits for a keypress then sends all stored spells to the printer via LPRINT.
  4. Save routine (line 9900): Saves the program (with populated arrays) to tape, then falls through to the print phase.

String Array Storage Technique

The three storage arrays are declared with 64-character row widths: DIM A$(20,64), DIM B$(16,64), and DIM C$(12,64). Each row holds a concatenation of two or three 20-character spell name strings. For A$, three 20-character strings are packed into 60 characters (leaving 4 characters of padding to 64). For B$ and C$, two 20-character strings occupy 40 characters. This packing means the 80-column printer prints two or three spells per line, making efficient use of paper width.

Buffer Clearing with E$

After each row is assembled, the temporary input buffers are reset by assigning them the contents of E$(1) (lines 280–300, 410–420, 560–570). Because E$ is declared DIM E$(1,20) and never written to, it always contains 20 spaces. This is a clean idiom for blanking a fixed-length string variable without using string literals or explicit space padding.

Entry Point Design

The REM at line 0 documents that the program should be entered at line 610 on subsequent runs (after saving with populated arrays). Line 605 uses STOP to halt after data entry, with lines 603–604 printing instructions. This two-entry-point design — data entry from line 200, print-only from line 610 — lets the saved file be reloaded and used purely as a print utility without re-entering spell names.

Notable Idioms and Observations

  • PAUSE 4E4 at line 620 pauses for 40,000 display frames (approximately 27 minutes at 50 Hz), effectively waiting for user intervention rather than a specific keypress — a common long-pause wait technique.
  • The loop variable Z is reused across all three data-entry loops (lines 200, 350, 500) as well as the print loops, which is valid since each loop completes before the next begins.
  • Array Z$ (lines 60, 540, 550, 570) shares its name with the loop counter Z. In this BASIC, numeric and string variables are distinct namespaces, so there is no conflict, but it is an unusual stylistic choice.
  • The working arrays (F$, S$, T$, U$, V$, X$, Z$) are all declared DIM x$(1,20); only row 1 is ever used, so they function as simple 20-character string variables with the syntax overhead of array indexing.
  • The SAVE at line 9900 uses an inverse-video digit in the filename, functioning as an auto-run marker so the saved program can resume at the print phase automatically on load.

Potential Issues

  • Spell names longer than 20 characters will be silently truncated by the fixed-width string array rows, with no warning to the user.
  • There is no validation or correction mechanism; a mistyped spell name requires restarting the entire entry process from line 200.
  • The concatenated output lines (A$(Z) etc.) are printed with LPRINT without separating delimiters, so distinguishing individual spell names within a printed row depends entirely on the user having entered consistent-length names.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10176 – 10210.

Related Products

Related Articles

Related Content

Image Gallery

Clerical Spell List D&D

Source Code

   0 REM %C%L%E%R%I%C%A%L% %S%P%E%L%L% %L%I%S%T         DUNGEONS AND DRAGONS            BY ANTHONY WILLING 3-1-86       GOTO 610, NEVER RUN             80 COLUMN PRINTER REQUIRED
   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)
  80 DIM A$(20,64)
  90 DIM B$(16,64)
 100 DIM C$(12,64)
 200 FOR Z=1 TO 20
 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 16
 360 PRINT "INPUT 4TH LEVEL SPELL ";Z
 370 INPUT U$(1)
 380 PRINT "INPUT 5TH LEVEL SPELL ";Z
 390 INPUT V$(1)
 400 LET B$(Z)=U$(1)+V$(1)
 410 LET U$(1)=E$(1)
 420 LET V$(1)=E$(1)
 430 CLS 
 440 NEXT Z
 500 FOR Z=1 TO 12
 510 PRINT "INPUT 6TH LEVEL SPELL ";Z
 520 INPUT X$(1)
 530 PRINT "INPUT 7TH LEVEL SPELL ";Z
 540 INPUT Z$(1)
 550 LET C$(Z)=X$(1)+Z$(1)
 560 LET X$(1)=E$(1)
 570 LET Z$(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 "CLERICAL SPELLS"
 650 LPRINT 
 660 LPRINT 
 670 FOR Z=1 TO 20
 680 LPRINT A$(Z)
 690 NEXT Z
 700 LPRINT 
 720 FOR Z=1 TO 16
 730 LPRINT B$(Z)
 740 NEXT Z
 750 LPRINT 
 770 FOR Z=1 TO 12
 780 LPRINT C$(Z)
 790 NEXT Z
 800 STOP 
 9900 SAVE "1020%3"
 9910 GOTO 610

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top