--- title: "Variable Lister" id: 71955 type: "computer_media" slug: "variable-lister" url: "http://localhost/computer_media/variable-lister/" markdown_url: "http://localhost/computer_media/variable-lister.md" published_at: "2026-10-20T14:56:16+00:00" modified_at: "2026-10-20T14:56:17+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "POKEs a 173-byte machine code routine under RAMTOP that lists the names and values of a BASIC program's variables, except arrays." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Programming" slug: "programming" taxonomy: "genre" url: "http://localhost/type/programming/" media_contents: - id: 71965 title: "Long Island Sinclair Timex (LIST) User Group Library Tape #3.5" type: "computer_media" url: "http://localhost/computer_media/long-island-sinclair-timex-list-user-group-library-tape-3-5/" media_type: "Program" tsrun_member: "LIST LIB 3.5 (198x)(Long Island Sinclair Timex User Group)(TS2068)(US)(Cassette)/List_Lib_3.5A(Unk)(Unk)(TS2068)(Cassette)/21_VARS.tap" mediadate: "198x" media_type_tags: "Programming" --- # Variable Lister 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 `CLEAR`s 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`. ## 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" ```