Variable Lister

This file is part of Long Island Sinclair Timex (LIST) User Group Library Tape #3.5. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 2068

Installs a short machine code routine that lists the current BASIC variables and their values on screen, arrays excepted. The BASIC program reads 173 bytes from DATA, checks them against a total of 18235, and POKEs them just above a lowered RAMTOP. The instruction screen says to CLEAR 65194, load the code, and call it at 65195.

REMs call it “VARiables” from Your Computer, May 84, for the Spectrum. The tape holds the BASIC program and the saved CODE block.

Program Analysis

How It Works

Line 30 reads RAMTOP from system variables 23730–23731, subtracts 173 and CLEARs to that address; lines 50–60 POKE the bytes from DATA and sum them. The routine walks the variables area from the address in 23627 (VARS), tests the type bits in each name byte, and prints the name followed by = and the value or the quoted string.

Notable Techniques

  • The code is placed relative to RAMTOP, so it adapts to wherever RAMTOP is when the program runs.
  • A DATA checksum guards against typing errors.

Potential Issues

  • The routine calls Spectrum ROM entry points (5633, 3435, 10930, 11747); these addresses were not checked against the TS2068 ROM.
  • The instructions say to call the code with “RND USR 65195”; the command is RANDOMIZE USR 65195.

Appears On

LIST user group library cassette with games, home finance, education, darkroom formulas, an OSCAR 10 satellite tracker and programming utilities across two sides.

Source Code

    5 REM "VAR"iables
   10 REM your computer  may 84
   20 REM SPECTRUM
   25 GO TO 200
   30 LET a=(PEEK 23730+256*PEEK 23731)-173
   40 CLEAR a
   45 LET s=0
   50 LET a=PEEK 23730+256*PEEK 23731
   55 FOR n=1 TO 173
   60 READ b: LET s=s+b: POKE a+n,b: NEXT n
   70 DATA 62,2,205,1,22,205,107,13,42,75,92,126,254,128,200,203,127,32,6,203,111,40,52,24,85,203,119,32,6,203,111,32,115,24,6,203,111,40
   80 DATA 2,24,8,35,94,35,86,25,35,24,218,229,62,2,205,1,22,225,62,20,215,62,1,215,126,238,160,215,62,13,215,17,19,0,25,24,192,229,62,2,205,1,22,225,126,215
   90 DATA 62,36,215,62,61,215,62,34,215,35,70,35,35,126,215,35,16,251,62,34,215,62,13,215,24,157,229,62,2,205,1,22,225,126,203,175,215,62,61,215,35,126,35,94,35
  100 DATA 86,35,78,35,70,35,229,205,178,42,205,227,45,225,62,13,215,24,216,229,62,2,205,1,22,225,126,238,224,215,35,126,203,127,32,3,215,24,247,203,191,215,24,204
  110 IF s<>18235 THEN PRINT "Error has occured.Please check code": STOP 
  120 STOP 
  150 SAVE "VAR"CODE a+1,173
  159 STOP 
  160 SAVE "VARS" LINE 165
  162 SAVE "VARS"CODE A+1,173
  165 LOAD ""CODE 
  200 PRINT "To use;"
  210 PRINT ,,"enter CLEAR 65194, THEN  LOAD """" CODE"
  215 PRINT "ONCE THE CODE IS LOADED YOU CAN LOOK AT YOUR VARIABLES(EXCEPT ARRAYS), BY ENTERING RND USR 65195"
  220 PRINT "THIS IS THE ORIGINAL ENTRY PROGRAM. YOU DON'T REALLY NEED IT."
  230 PRINT "EXCEPT AS A HANDY EXAMPLE. TRY IT NOW TO SEE THE VARIABLES IN THIS PROGRAM"
  240 PRINT "FIRST RUNTHIS PROGRAM BY GO ING TO 30"

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