Address File

This file is part of and Timex Sinclair Public Domain Library Tape 1001. Download the collection to get this file.
Developer(s): George W. Miller
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Database, Home

ADDFILE is a ZX81/TS1000 address-book manager published in Compute! magazine (March 1983) that stores up to 100 records, each holding a name, address, city, ZIP code, and phone number across five parallel string arrays. The program offers four operating modes — Entry, Change, List, and Search — selectable from a menu, with Search supporting lookup by either full name or city using exact-string matching against fixed-width string slices. The FAST/SLOW toggle is used during search loops to accelerate scanning. Fixed-length DIM declarations (e.g., 30, 25, 12, 5 characters) require users to pad or truncate input to fit array widths, and substring slice notation is used consistently for both assignment and comparison.


Program Analysis

Program Structure

The program is divided into clearly separated functional blocks, each starting at a round line number, making the code easy to navigate by section:

Line RangeFunction
1–17REMs and array declarations
25–75Initialisation and main menu
500–570CHANGE mode
1000–1150ENTRY mode
1500–1550LIST mode
2000–2165SEARCH mode
5000–5050Splash screen and initialisation entry point

The program starts at line 5000 via the GOTO 35 on line 35, which is itself reached from the splash screen at line 5030 (GOTO 38). Line 38 does not exist, so execution falls through to line 40, which sets the label variables for each mode. This is a deliberate technique to skip re-initialising those labels on subsequent returns to the menu.

Data Storage

All data is held in five parallel two-dimensional string arrays, each with 100 rows:

  • N$(100,30) — name (30 chars)
  • A$(100,30) — address (30 chars)
  • C$(100,25) — city (25 chars)
  • P$(100,12) — phone number (12 chars)
  • Z$(100,5) — ZIP code (5 chars)

Two single-row scratch arrays, S$(1,30) and T$(1,30), are used to hold search terms for name and city respectively before comparison. The variable L tracks the index of the last entered record, and N is used as a snapshot of L at menu time to allow the ENTRY loop to begin at the correct position.

Note that DIM L(1) on line 10 declares a numeric array, while the scalar variable L used throughout the program is a completely separate entity — the array L() is never referenced again.

Menu and Mode Dispatch

The main menu (lines 49–75) uses a string INPUT B$ and a chain of IF/GOTO tests to dispatch to the correct mode. The destination line numbers are pre-stored in variables CHANGE, ENTER, LIST, and SEARCH (lines 40–46), but these variables are never actually used in the GOTO statements — the GOTOs on lines 67–70 use the literal values 500, 1000, 1500, and 2000 directly. The label variables serve no functional purpose.

Entry Mode

Entry mode (lines 1000–1150) loops from N+1 to 100 using a FOR/NEXT construct. After each record is entered, the user is prompted with “ANOTHER ENTRY?? (Y/N)”; any response other than “Y” exits via GOTO 47, which snapshots L into N before returning to the menu. If the loop reaches record 100, line 1015 exits early with a “LIST FILLED” message.

Search Mode

Search mode (lines 2000–2165) supports two search types selected by entering “N” or “C”. For city search, T$(1,1 TO 25) holds the target string and is compared slice-by-slice against C$(S,1 TO 25). For name search, S$(1,1 TO 30) is compared against N$(S,1 TO 30). In both cases FAST mode is enabled before the loop to accelerate scanning, and SLOW is restored after.

The city search on a match jumps to line 2160, prints the record, then falls to GOTO 2041 — the NEXT S statement — continuing the loop to find all matching cities. The name search jumps to line 2160 similarly, but after printing also falls to GOTO 2041, so it too will continue scanning for further name matches rather than stopping at the first hit.

List Mode

List mode (lines 1500–1532) uses SCROLL between each printed field to advance the display without clearing the screen, giving a rolling-feed effect. Each record’s index number is printed alongside the name (PRINT N$(V);V) for reference in CHANGE mode.

Change Mode

Change mode (lines 500–570) prompts for a record number C, displays the existing fields, then prompts for corrected values one field at a time. Assignment uses substring slice notation for name, address, and city (e.g. LET N$(C,1 TO 30)=Y$), but for ZIP and phone uses bare array element assignment (INPUT Z$(C), INPUT P$(C)), which is functionally equivalent for single-row-dimension slices.

Notable Techniques and Anomalies

  • Line 5030 uses GOTO 38, a non-existent line, to fall through to line 40 — a deliberate idiom to skip lines 35 (the initial GOTO 5000) while landing exactly at the label-variable initialisation block.
  • Line 47 (LET N=L) is placed before the CLS at line 49 rather than inside the menu, ensuring N is always updated on each menu visit so ENTRY mode resumes at the correct position.
  • The unused DIM L(1) array declaration consumes memory without serving any purpose and may reflect an early draft of the program where a numeric array was planned.
  • Lines 2140–2145 (an unreachable block after a city search match) print record fields and pause, but are never reached because all match branches jump to line 2160. This is dead code.
  • Line 113 (PRINT) appears in isolation with no apparent purpose; it is never reached by normal program flow and seems to be a remnant of editing.
  • PAUSE 30000 is used as an indefinite pause (the user presses a key to continue), which is a standard ZX81 idiom since there is no INKEY$-based wait built in.
  • Lines 5035–5050 provide a SAVE routine under a custom filename with an auto-run flag, saving the program as 1000 6 (with the inverse-video character encoding the auto-run marker).

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Correction to ZX-81/TS-1000 Data Management program that appeared in the March 1983 issue of Compute!
The user of the Timex-Sinclair computer can store and work with data files, even though some commands for handling data...

Related Content

Image Gallery

Address File

Source Code

   1 REM "ADDFILE"
   2 REM  GEORGE W. MILLER
   3 REM  COMPUTE MAG. MAR. 1983
   4 REM 
   5 REM  START PROGRAM BY                ENTERING GOTO 35
   6 REM 
  10 DIM L(1)
  11 DIM S$(1,30)
  12 DIM T$(1,30)
  13 DIM N$(100,30)
  14 DIM A$(100,30)
  15 DIM C$(100,25)
  16 DIM P$(100,12)
  17 DIM Z$(100,5)
  25 LET L=0
  30 LET N=0
  35 GOTO 5000
  40 LET CHANGE=500
  42 LET ENTER=1000
  44 LET LIST=1500
  46 LET SEARCH=2000
  47 LET N=L
  49 CLS 
  50 PRINT AT 0,10;":FUNCTION:"
  52 PRINT 
  54 PRINT TAB 5;"ENTER %C FOR CHANGE MODE"
  55 PRINT 
  56 PRINT TAB 5;"ENTER %E FOR ENTRY MODE"
  57 PRINT 
  59 PRINT TAB 5;"ENTER %L FOR LIST MODE"
  60 PRINT 
  61 PRINT TAB 5;"ENTER %S FOR SEARCH MODE"
  62 PRINT 
  63 PRINT TAB 5;"ENTER STOP...TO STOP"
  65 INPUT B$
  67 IF B$="C" THEN GOTO CHANGE
  68 IF B$="E" THEN GOTO ENTER
  69 IF B$="L" THEN GOTO LIST
  70 IF B$="S" THEN GOTO SEARCH
  71 IF B$="STOP" THEN STOP 
  75 GOTO 49
 113 PRINT 
 500 CLS 
 510 PRINT AT 0,12;"CHANGE MODE"
 512 PRINT 
 513 PRINT TAB 5;"ENTER NUMBER TO CHANGE"
 514 INPUT C
 515 CLS 
 516 PRINT N$(C,1 TO 30)
 517 PRINT A$(C,1 TO 30)
 518 PRINT C$(C,1 TO 25)
 519 PRINT Z$(C,1 TO 5)
 520 PRINT P$(C,1 TO 12)
 524 PRINT AT 10,5;"ENTER CORRECT NAME"
 525 INPUT Y$
 530 LET N$(C,1 TO 30)=Y$
 535 PRINT AT 10,5;"ENTER CORRECT ADDRESS"
 540 INPUT H$
 545 LET A$(C,1 TO 30)=H$
 550 PRINT AT 10,5;"ENTER CORRECT CITY"
 555 INPUT G$
 560 LET C$(C,1 TO 25)=G$
 562 PRINT AT 10,5;"ENTER CORRECT ZIP CODE"
 563 INPUT Z$(C)
 564 PRINT AT 10,5;"ENTER CORRECT PHONE NUMBER"
 565 INPUT P$(C)
 570 GOTO 49
\n1000 CLS 
\n1010 FOR X=N+1 TO 100
\n1015 IF X=100 THEN GOTO 1142
\n1020 LET L=X
\n1030 CLS 
\n1040 PRINT AT 0,10;"    ENTRY MODE"
\n1050 PRINT AT 2,10;"LAST ENTRY WAS : ";X-1
\n1052 PRINT 
\n1055 PRINT "ENTER NAME"
\n1060 INPUT N$(X)
\n1070 PRINT 
\n1075 PRINT "ENTER ADDRESS"
\n1080 INPUT A$(X)
\n1090 PRINT 
\n1095 PRINT "ENTER CITY"
\n1100 INPUT C$(X)
\n1105 PRINT 
\n1107 PRINT "ENTER ZIP CODE"
\n1108 INPUT Z$(X)
\n1109 PRINT 
\n1110 PRINT "ENTER PHONE NUMBER"
\n1111 INPUT P$(X)
\n1112 PRINT 
\n1115 PRINT "ANOTHER ENTRY?? (Y/N)"
\n1130 INPUT F$
\n1138 IF F$<>"Y" THEN GOTO 47
\n1140 NEXT X
\n1142 PRINT 
\n1145 PRINT "          LIST FILLED"
\n1147 PAUSE 200
\n1150 GOTO 47
\n1500 CLS 
\n1505 PRINT AT 20,12;"LIST MODE"
\n1510 FOR V=1 TO L
\n1515 SCROLL 
\n1520 PRINT N$(V);V
\n1521 SCROLL 
\n1522 PRINT A$(V)
\n1523 SCROLL 
\n1524 PRINT C$(V)
\n1525 SCROLL 
\n1526 PRINT Z$(V)
\n1527 SCROLL 
\n1528 PRINT P$(V)
\n1529 SCROLL 
\n1530 PRINT 
\n1532 NEXT V
\n1540 PAUSE 200
\n1550 GOTO 49
\n2000 CLS 
\n2020 PRINT AT 0,12;"SEARCH MODE"
\n2021 PRINT 
\n2022 PRINT "SEARCH NAME(N) OR CITY(C)??"
\n2023 INPUT V$
\n2033 FAST 
\n2034 IF V$="N" THEN GOTO 2050
\n2036 PRINT "ENTER CITY AND STATE"
\n2037 PRINT "NOTE: SPELLING MUST BE EXACT"
\n2038 INPUT T$(1,1 TO 25)
\n2039 FOR S=1 TO L
\n2040 IF C$(S,1 TO 25)=T$(1,1 TO 25) THEN GOTO 2160
\n2041 NEXT S
\n2042 SLOW 
\n2043 PRINT TAB 5;"      END OF LIST"
\n2044 PAUSE 30000
\n2045 GOTO 47
\n2047 PRINT 
\n2050 PRINT "ENTER NAME FOR SEARCH"
\n2055 PRINT 
\n2060 INPUT S$(1,1 TO 30)
\n2062 FAST 
\n2063 FOR S=1 TO L
\n2065 IF N$(S,1 TO 30)=S$(1,1 TO 30) THEN GOTO 2160
\n2070 NEXT S
\n2100 PRINT 
\n2110 PRINT ,"NAME NOT FOUND"
\n2115 PAUSE 30000
\n2117 SLOW 
\n2120 GOTO 47
\n2140 PRINT N$(S)
\n2141 PRINT A$(S)
\n2142 PRINT C$(S)
\n2143 PRINT Z$(S)
\n2144 PRINT P$(S)
\n2145 SLOW 
\n2146 PAUSE 30000
\n2150 GOTO 47
\n2160 PRINT N$(S)
\n2161 PRINT A$(S)
\n2162 PRINT C$(S)
\n2163 PRINT Z$(S)
\n2164 PRINT P$(S)
\n2165 GOTO 2041
\n5000 PRINT "********************************"
\n5005 PRINT "*                              *"
\n5006 PRINT "*                              *"
\n5007 PRINT "*                              *"
\n5008 PRINT "*                              *"
\n5009 PRINT "*                              *"
\n5010 PRINT "*                              *"
\n5011 PRINT "*                              *"
\n5012 PRINT "********************************"
\n5013 REM FILE NAME
\n5015 PRINT AT 4,5;"   ADDRESS FILE"
\n5020 PAUSE 300
\n5021 CLS 
\n5022 PRINT "THIS PROGRAM WILL STORE UP TO"
\n5023 PRINT 
\n5024 PRINT "100 NAMES, ADDRESSES AND PHONE"
\n5025 PRINT 
\n5026 PRINT "NUMBERS, AND WILL SEARCH BY NAME"
\n5027 PRINT 
\n5028 PRINT "OR CITY"
\n5029 PAUSE 500
\n5030 GOTO 38
\n5035 CLEAR 
\n5040 SAVE "1000%6"
\n5050 RUN 

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

Scroll to Top