The Worx

Products: The Worx!
Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Business

The Worx is a file-management shell program that organizes multiple data areas in memory, providing a menu-driven interface for loading and saving three distinct file types: a PLAN file (a planner/calendar), a FONE file (a phone directory), and up to five Virtual files stored in a block starting at address 57374. The program uses machine code loaded from tape into address 29850, with additional code blocks at 60909, and interrogates system flags via PEEK at address 65533 to determine whether to enter the main menu or trigger an auto-save prompt on exit. A status bar is displayed on line 1 of the lower screen using PRINT #1 with PAPER and INK colors read dynamically from PEEK 65531 and 65532. The virtual file print routine reads filenames stored at fixed memory offsets (52242–52251 for the system name, 57374+ for virtual file headers) and sends file contents directly to the printer via LPRINT.

Program Structure

The program is organized into loosely grouped functional blocks by line number range:

  • Lines 1–10: Initialization — calls machine code at 29850 via RANDOMIZE USR, then PEEKs address 65533 to branch either to the main menu or the exit/save prompt.
  • Lines 1000–1100: Main file-options menu, displaying choices and dispatching on single-key input.
  • Lines 1110–1170: Virtual file print routine — lists up to five virtual files and sends selected file contents to the printer.
  • Lines 1400–1620: Subroutines for virtual file input, load, and save.
  • Lines 4000–4010: Header display subroutine — reads a system name from memory at 52242–52251 and prints it inverse.
  • Lines 5000–5050: Exit handler — prompts to save PLAN and FONE files before quitting.
  • Lines 9000–9060: Tape load sequence for the full Worx suite (BASIC, screen, two CODE blocks).
  • Lines 9500–9610: Backup routine — offers tape SAVE of the entire suite.
  • Lines 9800–9880: PLAN and FONE file load/save subroutines at fixed addresses.
  • Lines 9900–9910: System re-initialization — writes color and mode flags into the system variables area and jumps to the main menu.
  • Lines 9992–9998: Utility lines for saving the BASIC shell itself and a commented-out NEW command.

Machine Code Usage

Line 1 calls RANDOMIZE USR 29850 before CLEAR, invoking a machine code routine loaded from tape as TSWORX.CB (29850, length 21751 bytes) and a second block as TSWORX.CC at address 60909 (4599 bytes). These routines almost certainly provide the core application logic — the BASIC shell acts primarily as a loader and menu interface around them. The CLEAR 29849 in line 9002 positions BASIC’s memory ceiling just below the first machine code block, protecting it from BASIC’s variable area.

Memory Map

AddressPurpose
29850Machine code block 1 (TSWORX.CB), 21751 bytes
52242–52251System name string (10 chars), displayed in header
52894PLAN file data, 1280 bytes
54174FONE file data, 3200 bytes
57374Virtual files block start (5 × 672 bytes = 3360 bytes)
57406Virtual file data payload start (offset +32 from block start)
60909Machine code block 2 (TSWORX.CC), 4599 bytes
65530–65533System flags: color/mode settings and exit-state flag

Key BASIC Idioms and Techniques

  • Single-key polling loop: Lines 1010–1100 use INKEY$ in a tight loop with an empty-string check, a standard approach for responsive menu navigation without waiting for ENTER.
  • PEEK-based system flags: Address 65533 is polled at line 10 to decide between normal startup and an exit-save path, and addresses 65530–65532 are POKEd in line 9900 to set paper/ink/mode for the session.
  • Dynamic status bar: Line 1005 uses PRINT #1 to write to the lower screen with PAPER PEEK 65531; INK PEEK 65532, reading live color values from memory rather than hardcoding them.
  • Memory-title construction: The subroutine at line 4000 builds a display string by concatenating CHR$ PEEK over a 10-byte range, pulling a stored system name directly from RAM.
  • CAT command: Line 1405 uses CAT ".C*" to list matching files before prompting for a filename — useful for reminding the user of available virtual files on disk/microdrive.
  • Fixed-stride virtual file layout: Virtual files are accessed with stride 672 bytes, with the filename header in the first 32 bytes and 640 bytes of printable content. The print loop (lines 1120–1170) uses x=57406+((VAL f$)-1)*672 to locate the correct block.

Bugs and Anomalies

  • Case mismatch at line 1085: The condition uses A$ (uppercase) rather than a$ (lowercase) as used throughout the rest of the program. On most implementations this will still work since BASIC variable names are case-insensitive, but it is inconsistent.
  • Line 9998 comment: The line reads REM RANDOMIZE USR 100:NEW — a NEW command inside a REM is harmless, but the RANDOMIZE USR 100 suggests a placeholder or earlier entry point that was commented out rather than deleted.
  • Line 8000 orphan: POKE 65533,4:GO TO 1 is defined but never called from anywhere visible in the listing. It may be a developer utility or a hook intended for machine code to invoke.
  • STOP key string: Line 1020 tests a$="STOP " with a trailing space. Since INKEY$ returns a single character, this string can never match, making the back-navigation via SS/A non-functional from within the file menu. The status bar message is therefore misleading.

Related Products

Assortment of programs including a planner, notepad, calculator and more.

Image Gallery

Source Code

    1 RANDOMIZE USR 29850:CLEAR 
   10 LET a= PEEK 65533:IF a=3 THEN GO TO 5000
 1000 GO SUB 4000:PRINT TAB 2;"\{20}\{1}File Options\{20}\{0}"'' TAB 6;"\{20}\{1}1\{20}\{1}\{20}\{0} Load PLAN file"'' TAB 6;"\{20}\{1}2\{20}\{0} Save PLAN file"'' TAB 6;"\{20}\{1}3\{20}\{0} Load FONE file"'' TAB 6;"\{20}\{1}4\{20}\{0} Save FONE file"'' TAB 6;"\{20}\{1}5\{20}\{0} Load a Virtual file"'' TAB 6;"\{20}\{1}6\{20}\{0} Save a Virtual file"'' TAB 6;"\{20}\{1}7\{20}\{0} Print a Virtual file"
 1005 PRINT #1; PAPER PEEK 65531; INK PEEK 65532; AT 0,0; INVERSE 1;"STOP (SS/A) goes back one level"
 1010 LET a$= INKEY$:IF a$="" THEN GO TO 1010
 1020 IF a$="STOP " THEN GO TO 1
 1050 IF a$="1" THEN GO SUB 9800:GO TO 1000
 1060 IF a$="2" THEN GO SUB 9825:GO TO 1000
 1065 IF a$="3" THEN GO SUB 9850:GO TO 1000
 1070 IF a$="4" THEN GO SUB 9875:GO TO 1000
 1075 IF a$="5" THEN GO SUB 1400:GO SUB 1500:GO TO 1000
 1080 IF a$="6" THEN GO SUB 1400:GO SUB 1600:GO TO 1000
 1085 IF A$="7" THEN GO SUB 1110:GO TO 1000
 1100 GO TO 1010
 1110 CLS :PRINT ''"Print a virtual file":LET f=1
 1120 FOR i=57374 TO 60062 STEP 672:PRINT "   ";f;" ";
 1130 FOR j=0 TO 7:PRINT CHR$ PEEK (i+j);:NEXT j:PRINT 
 1140 LET f=f+1:NEXT i
 1150 INPUT "File number (ENTER=exit): ";f$:IF f$="" THEN RETURN 
 1160 IF f$<"1" OR f$>"5" THEN GO TO 1150
 1170 LET x=57406+((VAL f$)-1)*672:FOR i=x TO x+639:LPRINT CHR$ PEEK i;:NEXT i:LPRINT :LPRINT :GO TO 1110
 1400 REM input
 1405 CLS :CAT ".C*",:INPUT "Filename: ";f$:LET f$=f$+".C1":RETURN 
 1500 REM LOAD VIRT
 1520 LOAD f$ CODE 57374:RETURN 
 1600 REM Save VIRT
 1620 SAVE f$ CODE 57374,3360:RETURN 
 4000 LET g$="System                ":FOR i=52242 TO 52251:LET g$=g$+ CHR$ PEEK i:NEXT i
 4010 CLS :PRINT INVERSE 1;g$;:RETURN 
 5000 GO SUB 4000:PRINT ''"Save PLAN file? (Y/N)":INPUT i$:IF i$ <>"y" AND i$ <>"Y" THEN GO TO 5010
 5002 GO SUB 9830
 5010 PRINT ''"Save FONE file? (Y/N)":INPUT i$:IF i$ <>"y" AND i$ <>"Y" THEN GO TO 5050
 5014 GO SUB 9880
 5050 GO TO 9998
 8000 POKE 65533,4:GO TO 1
 9000 REM TAPE LOAD
 9002 BORDER 5:PAPER 6:INK 6:CLEAR 29849:LOAD "WORX.C$"SCREEN$ 
 9005 PRINT AT 14,0
 9020 LOAD "TSWORX.CB"CODE 29850
 9025 PRINT AT 14,0
 9030 LOAD "TSWORX.CC"CODE 60909
 9060 GO TO 9500
 9500 REM BACKUP
 9505 BEEP 1/200,20:INPUT AT 0,0;"Make Backup (Y/N)? ";f$
 9510 IF F$="N" OR f$="n" THEN GO TO 9900
 9530 IF F$="Y" OR f$="y" THEN GO TO 9600
 9540 GO TO 9505
 9600 REM TAPE SAVE
 9605 SAVE "THE WORX" LINE 9000:SAVE "WORX.SC"SCREEN$ :SAVE "TSWORX.OB"CODE 29850,21751:SAVE "TSWORX.CO"CODE 60909,4599
 9610 GO TO 9500
 9800 REM load plan file
 9805 LOAD "PLAN.C1"CODE 52894:RETURN 
 9825 REM save plan file
 9830 SAVE "PLAN.C1"CODE 52894,1280:RETURN 
 9850 REM load fone file
 9855 LOAD "FONE.C1"CODE 54174:RETURN 
 9875 REM save fone file
 9880 SAVE "FONE.C1"CODE 54174,3200:RETURN 
 9900 INK 1:POKE 65530,5:POKE 65531,6:POKE 65532,1:POKE 65533,0
 9905  POKE 65293,60
 9910 GO TO 1
 9992 SAVE "WORX.B1" LINE 9000
 9998 REM RANDOMIZE USR 100:NEW 

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