Program Catalog

Developer(s): Bob Mitchell
Date: 1985
Type: Program
Platform(s): TS 2068

Program Catalog keeps a catalogue of the programs on your cassettes, up to 400 records. Each record holds a name of up to ten characters, the tape number, side and counter reading, a date in yymmdd form, a reference field and one of nine categories: Programming, Utility, Home/Business, Game, Math/Science, Education, Machine Code, Graphics/Sound and Misc. From the menu you add, delete and change records, sort the file by any of the four fields, search it, and list the whole file or one category on screen or printer. With the file sorted by tape, it prints two-column labels for a cassette. The catalogue is saved and loaded as a DATA file, and this copy ships with an empty catalogue, ready for your own tapes.

The menu carries the line “© R.H.Mitchell 1985”. R.H. Mitchell is Bob Mitchell of Willowdale, Ontario, and the title bar reads “PROGRAMS-A”. REMs at the top say the program was donated by the Toronto Sinclair User’s Group and was modified and adapted by Algis E. Gedris on December 19, 1986. It was on the disk SNUG_7_8 as PROGRAM T.

Program Analysis

Structure

  • Lines 1–3: REMs naming the source and the adapter.
  • Lines 150–280: the screen frame and the 32-column record printer, which shows each field in alternating normal and inverse video.
  • Lines 300–680: the main menu with a status column (records used, sort field, date, scroll mode). Keys are read with INKEY$ after PAUSE NOT PI, with caps lock set by POKE 23658,8.
  • Lines 700–790 and 2220–2520: add a record. Lines 810–940 and 2570–2830: sort.
  • Lines 960–1190: delete. Lines 1210–1580: change one field, the category, or delete the whole record.
  • Lines 1410 and 2840–3230: Display Record, a search on whichever field the file is sorted by.
  • Lines 1690–2150, 3640–3700 and 3790–3860: full and partial lists, on screen or printer.
  • Lines 3300–3530: cassette labels. Lines 3540–3600: save or load the records as a DATA file.
  • Lines 3910–3940: the error trap. Lines 9998–9999: the save line and an optional machine-code loader.

Data

Records live in the string array R$(400,29): characters 1–10 are the name, 11–16 the tape number, side and counter, 17–22 the date, 23–28 the reference and 29 the category digit. The field names (H$()), their start and end positions (B() and E()), maximum lengths (F()), category names (I$()) and the screen and label strings are all held in the saved variables. Apart from line 130, which nothing calls, the program has no set-up code, so it must be started with GO TO rather than RUN.

Sorting and Searching

The sort is an iterative quicksort that keeps its own stack of sub-ranges in L() and H() and compares the slice R$(I,A TO B) for the chosen field. The search asks for the start of a value in the sorted field, checks that at least one record matches, then homes in on it by halving the range (lines 3000–3160) and steps back through earlier records to print the other matches.

Notable Techniques

  • ON ERR GO TO 3910 traps errors. The handler uses the TS2068’s ON ERR RESET, pauses, re-arms the trap and continues with ON ERR CONTINUE.
  • Auto-scroll mode pokes the scroll counter (POKE 23692,-1) after each record so long lists run without the “scroll?” prompt.
  • Menu text is chosen with string AND, as in "Auto-scroll" AND AS;" Normal" AND NOT AS.
  • Because the DATA file holds only the array, the save prompt suggests putting the date, record count and sort flag in the file name (for example 0126N350S1), and the load routine asks for the count and sort flag afterwards.

Potential Issues

  • The program is saved to start at line 3770, which does not exist, so it begins at the partial-list routine at line 3780. That prints an empty list before “press ENTER to cont.” brings up the menu.
  • Option 8, DATE & SAVE, asks for the date and then jumps to line 3740, which does not exist. It falls into the partial list, and nothing is saved. Use option A to save the catalogue.
  • The date typed in option 8 is not part of the DATA file, so it is lost when a catalogue is reloaded.
  • “r=next record” on the change screen (line 1305) asks for a record number again rather than showing the next record.
  • When printing labels, a tape number that is not in the file reaches the STOP at line 3430 and leaves the program.
  • Record numbers below 1 are not rejected by the delete and change options and appear to be left to the error trap.

This program came from an Oliger (JLO SAFE) disk and was converted to load from tape. The disk SAVE / and LOAD / commands in lines 9998 and 9999 became plain tape commands, and the saved catalogue was cleared, so the program starts with 0 of 400 records. The PCODE machine code that line 9999 would load was not on the disk and is not needed. It was tested in ZEsarUX by adding two records and listing the file.

Related Content

Image Gallery

Source Code

    1 REM THIS PROGRAM WAS                DONATED BY TORONTO              SINCLAIR USER'S GROUP
    2 REM MODIFIED AND ADAPTED BY ALGIS E. GEDRIS  DEC. 19, 1986
    3 REM 2068 COMPUTER PROGRAMS
  120 GO TO 310
  130 DIM R$(X,29): LET N=0: LET FS=N: LET J$="": REM INITIALIZE
  140 GO TO 310
  150 REM VERTICAL BARS
  160 FOR I=2 TO 17: PRINT AT I,0;": ";AT I,19;": ";AT I,31;" :"
  170 NEXT I: RETURN 
  190 REM 32 COL PRINT SUBROUTINE
  200 LET FT=1: LET TOG=FT
  210 FOR O=1 TO 4
  220 LET TOG=ABS (TOG-1): INVERSE TOG
  230 PRINT TAB B(O)+2;R$(RNN,B(O) TO E(O));
  240 INVERSE TOG
  250 NEXT O
  260 LET TOG=ABS (TOG-1): PRINT ; INVERSE TOG;R$(RNN,29)
  270 INVERSE 0
  280 RETURN 
  290 REM MAIN MENU
  300 LET G=300: LET AS=0
  310 ON ERR GO TO 3910
  320 INVERSE 0: INK 7: PAPER 0: BORDER 0: BRIGHT 0: CLS : CLOSE #2: CLOSE #3
  330 POKE 23658,8
  340 PRINT TAB 12; INVERSE 1;Y$
  350 LET FP=0: LET FA=1: LET FC=0
  360 PRINT B$;TAB 14;'" Press Option....";TAB 20; INVERSE 1;"  STATUS";TAB 32''
  370 PRINT "  1> ADD RECORD    "; INVERSE 1;" ";N;" of ";X;TAB 32
  380 IF FS<>0 THEN PRINT "  2> SORT FILE";TAB 20; INVERSE 1;H$(FS) AND FS<>0;"-sorted";TAB 32
  390 IF FS=0 THEN PRINT "  2> SORT FILE";TAB 20; INVERSE 1;" Unsorted" AND FS=0;TAB 32
  400 PRINT "  3> DELETE RECORD"
  410 PRINT "  4> CHANGE RECORD"
  420 PRINT "  5> DISPLAY RECORD"
  430 PRINT "  6> DISPLAY FILE"
  440 PRINT "  7> PRINT-OUT" 
  450 PRINT "  8> DATE & SAVE";TAB 20; INVERSE 1;"  ";J$;TAB 32
  460 PRINT "  9> QUIT PROGRAM"
  470 PRINT "  0> PRINT LABELS"
  480 PRINT "  A> DATA HANDLING"
  490 PRINT "  B> SET SCROLL ";TAB 20; INVERSE 1;"Auto-scroll" AND AS;"  Normal" AND NOT AS;TAB 32: GO SUB 150
  500 PRINT INVERSE 1;B$
  510 PRINT 'TAB 6; INK 9;"* R.H.Mitchell 1985"
  520 GO SUB 3250
  530 PAUSE NOT PI
  540 IF INKEY$="A" THEN GO TO 3540
  550 IF INKEY$="B" THEN LET AS=ABS (AS-1): GO TO 310
  560 IF INKEY$<"0" OR INKEY$>"9" THEN GO TO 530
  570 IF INKEY$="" THEN GO TO 530
  580 IF INKEY$="0" THEN GO TO 3300
  590 IF INKEY$="1" THEN GO TO 700
  600 IF INKEY$="2" THEN GO TO 810
  610 IF INKEY$="3" THEN GO TO 960
  620 IF INKEY$="4" THEN GO TO 1210
  630 IF INKEY$="5" THEN GO TO 1410
  640 IF INKEY$="6" THEN GO TO 1690
  650 IF INKEY$="7" THEN GO TO 2190
  660 IF INKEY$="8" THEN GO TO 3280
  670 IF INKEY$="9" THEN CLS : PRINT AT 10,0;"End of session. Switch off or   ENTER to resume.": GO TO 2140
  680 GO TO 530
  690 REM ADD RECORD
  700 LET RN=N+1
  710 IF RN>X THEN GO TO 2530
  720 GO SUB 2220
  730 IF RN=N+2 THEN LET N=N+1
  740 PRINT #0;"a=add record;m=menu"
  750 PAUSE NOT PI
  760 IF INKEY$="" THEN GO TO 760
  770 IF INKEY$="M" THEN GO TO 310
  780 IF INKEY$<>"M" THEN GO TO 710
  790 GO TO 750
  800 REM SORT
  810 CLS 
  820 FOR I=1 TO 4
  830 PRINT #0;I;" =by ";H$(I)': NEXT I
  850 PAUSE NOT PI
  860 LET VV=CODE INKEY$-48
  870 IF VV=FS THEN CLS : PRINT AT 8,0;"The file was last sorted by"'H$(FS);"."'"To re-sort again in this option you must first sort into any    other of the available options.": GO TO 2140
  880 GO TO 900
  890 IF INKEY$="" THEN GO TO 890
  900 LET FS=VV: LET A=B(VV): LET B=E(VV): GO TO 920
  910 GO TO 850
  920 CLS : PRINT '' FLASH 1;AT 10,0;"SORTING BY ";H$(FS)
  930 GO SUB 2570
  940 GO TO 310
  950 REM DELETE
  960 CLS 
  970 INPUT "enter record # for deletion"'DR
  980 IF DR>N THEN PRINT AT 10,10; FLASH 1;"INVALID #": PAUSE 240: GO TO 310
  990 PRINT '"Record # ";DR;" is:"''
 1000 LET RNN=DR
 1010 GO SUB 200
 1020 PRINT #0;"d=delete; m=menu"
 1030 PAUSE NOT PI
 1040 IF INKEY$="" THEN GO TO 1040
 1050 IF INKEY$="M" THEN GO TO 310
 1060 IF INKEY$="D" THEN PRINT #1;"Deleting: Stand-by": GO TO 1080
 1070 GO TO 1030
 1080 IF DR>N-1 THEN LET R$(DR)="": GO TO 1120
 1090 FOR I=DR TO N-1: LET R$(I)=R$(I+1): NEXT I
 1100 LET N=N-1
 1110 GO TO 1130
 1120 LET N=N-1
 1130 CLS 
 1140 PRINT #1;"Record # ";DR;" has been deleted.": PRINT #0;"d=more deletions; m=menu"
 1150 PAUSE NOT PI
 1160 IF INKEY$="" THEN GO TO 1160
 1170 IF INKEY$="D" THEN GO TO 960
 1180 IF INKEY$="M" THEN GO TO 310
 1190 GO TO 1150
 1200 REM CHANGE
 1210 CLS 
 1220 INPUT #0;"enter record # for change"'RN
 1230 IF RN>N THEN PRINT AT 10,10; FLASH 1;"INVALID #": PAUSE 240: GO TO 310
 1240 PRINT "Record # ";RN;" is:"''
 1250 LET RNN=RN
 1260 GO SUB 200
 1270 PRINT #0;"c=change;r=next record;m=menu"
 1280 PAUSE NOT PI
 1290 IF INKEY$="" THEN GO TO 1290
 1300 IF INKEY$="C" THEN GO TO 1440
 1305 IF INKEY$="R" THEN GO TO 1210
 1310 IF INKEY$<>"C" THEN GO TO 310
 1320 GO TO 1280
 1400 REM DISPLAY RECORD
 1410 CLS 
 1420 LET AA=1: LET BB=N: LET P=0: LET S1=AA
 1430 GO TO 2870
 1440 PRINT ''"What is wrong?"
 1450 FOR I=1 TO 4
 1460 PRINT "   ";I;". ";H$(I): NEXT I
 1480 PRINT "   A. EVERYTHING: Delete record"'"   B. NOTHING: Leave as is",
 1490 PRINT "   C. Category",,
 1500 PRINT #0;AT 1,0; FLASH 1;" Select #",,
 1510 PAUSE NOT PI
 1520 LET V=CODE INKEY$-48
 1530 IF INKEY$="B" THEN GO TO 310
 1540 IF INKEY$="A" THEN LET DR=RN: PRINT #1;"Deleting: Stand-by": GO TO 1090
 1550 IF INKEY$="C" THEN INPUT "Enter NEW Category Code"' LINE R$(RN,29): CLS : GO TO 1240
 1560 IF V<1 OR V>4 THEN GO TO 1510
 1570 INPUT ("ENTER NEW "'H$(V))' LINE R$(RN,B(V) TO E(V)): LET FS=0: CLS : GO TO 1240
 1580 GO TO 1510
 1590 PRINT #1; FLASH 1;"NO RECORD FOUND"
 1600 PRINT #0;"r=another record; m=menu"
 1610 PAUSE NOT PI
 1620 IF INKEY$="" THEN GO TO 1620
 1630 IF INKEY$="R" THEN GO TO 1410
 1640 IF INKEY$<>"R" THEN GO TO 310
 1650 GO TO 1610
 1660 NEXT I
 1670 GO TO 310
 1680 REM DISPLAY FILE
 1690 CLS 
 1700 LET K=0: LET FC=K
 1710 PRINT TAB 10;"List records"
 1720 PRINT ''"Press..."'' INVERSE 1;"Print-out Mode" AND FP;"Screen Mode" AND NOT FP
 1730 PRINT "F for FULL list 32 COL"
 1740 PRINT "X for FULL list 40 COL"
 1750 PRINT "P for PARTIAL list 32 COL"
 1760 PRINT "Y for PARTIAL list 40 COL"
 1770 LET SR=1
 1780 IF FP THEN PRINT AT 10,0; FLASH 1;"Check printer is ON.": OPEN #2,"P"
 1790 PAUSE NOT PI
 1800 IF INKEY$="" THEN GO TO 1800
 1810 IF INKEY$="F" THEN GO SUB 3880: GO TO 1860
 1820 IF INKEY$="X" THEN CLS : GO SUB 3880: PRINT #1;AT 0,0;: GO TO 3630
 1830 IF INKEY$="Y" THEN LET FC=1: PRINT #1;AT 0,0;: GO TO 1900
 1840 IF INKEY$="P" THEN GO TO 1900
 1850 GO TO 1790
 1860 CLS 
 1870 PRINT J$''
 1880 FOR I=SR TO N
 1890 GO TO 2050
 1900 CLS 
 1910 IF FP=1 THEN CLOSE #2
 1920 PRINT AT 2,10;"CATEGORIES"
 1930 FOR I=1 TO C
 1940 PRINT TAB 5; PAPER 1; INK 7;I;".";I$(I)
 1950 NEXT I
 1960 IF NOT FA THEN RETURN 
 1970 INPUT ("enter category code # (1 TO ";C;")")' LINE C$
 1980 CLS 
 1990 IF FP=1 THEN OPEN #2,"p"
 2000 IF FC THEN GO TO 3790
 2010 PRINT I$(VAL C$),J$
 2020 PRINT 
 2030 FOR I=SR TO N
 2040 IF R$(I,29)<>C$ THEN GO TO 2120
 2060 PRINT INVERSE 1;I;
 2080 LET RNN=I
 2090 GO SUB 200
 2100 ON ERR GO TO 310
 2110 IF AS THEN POKE 23692,-1
 2120 NEXT I
 2130 REM BOTTOM LINE MSG
 2140 GO SUB 3250: PRINT #0;"press ENTER to cont."
 2150 PAUSE NOT PI: CLS : GO TO 310
 2180 REM  COPY 
 2190 CLS 
 2200 LET FP=1
 2210 GO TO 1720
 2220 CLS : REM ADD SUBROUTINE
 2230 LET FS=0: LET FA=FS
 2240 PRINT "Enter record # ";RN
 2250 FOR I=1 TO 4
 2260 INPUT INVERSE 1;(H$(I); INVERSE 0;" :max len= ";F(I))' LINE N$(I)
 2270 PRINT N$(I)
 2280 NEXT I
 2290 GO SUB 1930
 2300 INPUT ("Category ";"1 to ";C)' LINE C$
 2310 IF C$=" " THEN PRINT #0;"INVALID ENTRY": PAUSE 120: GO TO 2230
 2320 PRINT AT 5,0;P$
 2330 PRINT AT 5,0;C$;"=";I$(VAL C$)
 2340 PRINT #0;"correct? y/n"
 2350 PAUSE NOT PI
 2360 IF INKEY$="" THEN GO TO 2360
 2370 IF INKEY$="N" THEN GO TO 2490
 2380 IF INKEY$="Y" THEN GO TO 2400
 2390 GO TO 2350
 2400 FOR I=1 TO 4
 2410 LET R$(RN,B(I) TO E(I))=N$(I)
 2420 NEXT I
 2430 LET R$(RN,29)=C$
 2440 CLS 
 2450 PRINT "Record # ";RN;" added to file"
 2460 LET RN=RN+1
 2470 GO SUB 3240
 2480 RETURN 
 2490 CLS 
 2500 PRINT AT 19,0;"ENTRY CANCELLED"
 2510 PAUSE 120
 2520 GO TO 310
 2530 CLS 
 2540 PRINT AT 10,11; FLASH 1;"FILE FULL"
 2550 PAUSE 240
 2560 GO TO 310
 2570 REM QUICKSORT
 2580 LET L(1)=1
 2590 LET H(1)=N
 2600 LET II=2
 2610 IF II<=1 THEN RETURN 
 2620 IF L(II)>=H(II) THEN LET II=II-1
 2630 IF L(II)>=H(II) THEN GO TO 2610
 2640 LET I=L(II)-1
 2650 LET J=H(II)
 2660 LET IL=J
 2670 IF I>=J THEN GO TO 2760
 2680 LET I=I+1
 2690 IF R$(I,A TO B)<R$(IL,A TO B) THEN GO TO 2680
 2700 LET J=J-1
 2710 IF J>1 THEN IF R$(J,A TO B)>R$(IL,A TO B) THEN GO TO 2700
 2720 IF I<J THEN LET W$=R$(I)
 2730 IF I<J THEN LET R$(I)=R$(J)
 2740 IF I<J THEN LET R$(J)=W$
 2750 GO TO 2670
 2760 LET J=H(II): LET W$=R$(I): LET R$(I)=R$(J): LET R$(J)=W$
 2770 IF I-L(II)<H(II)-1 THEN LET L(II+1)=L(II): LET H(II+1)=I-1: LET L(II)=I+1: GO TO 2810
 2780 LET L(II+1)=I+1
 2790 LET H(II+1)=H(II)
 2800 LET H(II)=I-1
 2810 LET II=II+1
 2820 GO TO 2610
 2830 STOP 
 2840 REM SEARCH
 2850 CLS : PRINT AT 8,0;"The file is not sorted by any   field. To use this option you   must first sort into the"'"appropriate order."
 2860 GO TO 2140
 2870 GO SUB 3250
 2880 IF FS=0 THEN GO TO 2840
 2890 PRINT AT 10,0;"The file is now sorted by "'H$(FS)
 2900 INPUT ("enter search data for "'H$(FS))' LINE A$
 2910 LET SS=B(FS)
 2920 CLS 
 2930 PRINT "Searching for ";A$
 2940 LET Q=0
 2950 FOR I=1 TO N
 2960 IF R$(I,SS TO SS+LEN A$-1)=A$ THEN LET Q=Q+1
 2970 IF Q>=1 THEN GO TO 3000
 2980 NEXT I
 2990 IF Q=0 THEN GO TO 1590
 3000 LET S=INT ((BB-AA)/2+.5)
 3010 GO TO 3050
 3020 IF S>BB THEN GO TO 3220
 3030 IF R$(S,SS TO SS+LEN A$-1)>A$ THEN LET S=INT ((BB-AA)/2+.5)
 3040 IF R$(S,SS TO SS+LEN A$-1)<A$ THEN LET S=INT ((BB-AA)/2+.5)+AA
 3050 IF P>0 AND R$(S1)=R$(S) THEN GO TO 3170
 3060 IF R$(S,SS TO SS+LEN A$-1)=A$ THEN PRINT INVERSE 1;S;
 3070 IF R$(S,SS TO SS+LEN A$-1)=A$ THEN LET RNN=S: GO SUB 200
 3075 IF AS THEN POKE 23692,-1
 3080 ON ERR GO TO 310
 3090 IF R$(S,SS TO SS+LEN A$-1)=A$ THEN LET P=P+1
 3100 IF P=1 AND R$(S,SS TO SS+LEN A$-1)=A$ THEN LET S1=S
 3110 IF R$(S,SS TO SS+LEN A$-1)=A$ THEN GO TO 3150
 3120 IF R$(S,SS TO SS+LEN A$-1)>A$ THEN LET BB=S
 3130 IF R$(S,SS TO SS+LEN A$-1)<A$ THEN LET AA=S
 3140 GO TO 3020
 3150 LET S=S+1
 3160 GO TO 3020
 3170 IF S1<=AA THEN GO TO 3230
 3180 IF R$(S1-1,SS TO SS+LEN A$-1)=A$ THEN PRINT INVERSE 1;S1-1;
 3190 IF R$(S1-1,SS TO SS+LEN A$-1)=A$ THEN LET RNN=S1-1: GO SUB 200
 3195 IF AS THEN POKE 23692,-1
 3200 ON ERR GO TO 310
 3210 LET S1=S1-1
 3220 GO TO 3170
 3230 PRINT #0;"press ENTER to continue": PAUSE NOT PI: GO TO 310
 3240 REM  BEEP 
 3250 BEEP .05,40: RETURN 
 3270 REM DATE, SAVE & VERIFY 
 3280 CLS : INPUT "Enter date (yymmdd)"' LINE J$
 3290 GO TO 3740
 3300 CLS : REM LABEL PRINTING
 3310 IF FS<>2 THEN PRINT AT 8,0;"The file must be sorted by TAPE for this option to work": GO TO 2140
 3320 INPUT "Enter tape # (nn)";F$
 3330 CLS : PRINT AT 10,0;"Check printer ON, then press    any key to print label"
 3340 IF INKEY$="" THEN GO TO 3340
 3350 LPRINT '''X$;Z$
 3360 LPRINT ":       CASSETTE #  TS";F$;"        : "
 3370 LPRINT Z$
 3380 LPRINT O$
 3390 LPRINT " CTR   nAmE      CTR   nAmE      "
 3400 LET CC=0: LET COL=CC: LET LC1=CC
 3410 FOR I=1 TO N: IF F$=R$(I,11 TO 12) THEN LET TS1=I: GO TO 3440
 3420 NEXT I
 3430 STOP 
 3440 FOR I=TS1 TO N
 3450 IF LC1 AND F$<>R$(I,B(FS) TO B(FS)+1) THEN GO TO 3500
 3460 IF F$=R$(I,B(FS) TO B(FS)+1) THEN LET LC1=1: LPRINT TAB COL; INVERSE 1;R$(I,B(FS)+3 TO E(FS)); INVERSE 0;R$(I, TO E(1));: LET CC=CC+1
 3470 IF COL=0 AND F$=R$(I,B(FS) TO B(FS)+1) THEN LET COL=17: GO TO 3490
 3480 IF COL=17 AND F$=R$(I,B(FS) TO B(FS)+1) THEN LPRINT TAB 31;" :": LET COL=0
 3490 NEXT I
 3500 IF COL=0 THEN GO TO 3520
 3510 LPRINT TAB 31;" :"
 3520 LPRINT TAB 0;O$
 3530 GO TO 310
 3540 REM DATA HANDLING
 3550 CLS : INPUT "1=Load;0=Save",DH
 3560 IF DH THEN CLS : PRINT FLASH 1;AT 8,0;"WARNING! If you Continue you    will erase all current data.    ": INPUT "1=Continue;0=Menu",DHC: GO TO 3590
 3570 IF NOT DH THEN CLS : PRINT AT 8,0;"Include Date (mmdd);number of   records USED and sort flag in   file name (eg: 0126N350S1).": INPUT "Name of Data File?";D$: SAVE D$ DATA R$(): CLS : PRINT FLASH 1;"Rewind for verify": VERIFY "" DATA R$(): CLS : PRINT "Data file ";D$'" Saved and verified OK.": PRINT ''"Press ENTER for MENU.": PAUSE NOT PI: GO TO 310
 3580 STOP 
 3590 IF DHC THEN CLS : DIM R$(400,32): PRINT AT 8,0;"Ready data file for loading,    then press any key and          start tape recorder": PAUSE NOT PI: LOAD "" DATA R$(): CLS : PRINT AT 8,0;"Using data file name, set valuesfor Number of Records and for   Sort Flag": INPUT "Number of records"'N: INPUT "Sort flag"'FS: GO TO 310
 3600 IF NOT DHC THEN GO TO 310
 3610 STOP 
 3620 REM PRINTOUT
 3640 PRINT #1;AT 0,0;J$
 3645 LET G$="   "
 3650 FOR I=SR TO N
 3654 IF I>=10 AND I<100 THEN LET G$="  "
 3656 IF I>=100 THEN LET G$=" "
 3660 PRINT #1;I;G$;R$(I, TO 10);" ";R$(I,11 TO 16);" ";R$(I,17 TO 22);" ";R$(I,23 TO 28);" ";R$(I,29)
 3670 ON ERR GO TO 310
 3680 IF AS THEN POKE 23692,-1
 3690 NEXT I
 3700 GO TO 2140
 3780 REM PARTIAL PRINTOUT
 3790 PRINT #1;AT 0,0;I$(VAL C$),J$
 3795 LET G$="   "
 3800 FOR I=1 TO N
 3805 IF I>=10 AND I<100 THEN LET G$="  "
 3807 IF I>=100 THEN LET G$=" "
 3810 IF R$(I,29)<>C$ THEN GO TO 3850
 3820 PRINT #1;I;G$;R$(I, TO 10);" ";R$(I,11 TO 16);" ";R$(I,17 TO 22);" ";R$(I,23 TO 28);" ";R$(I,29)
 3830 ON ERR GO TO 310
 3840 IF AS THEN POKE 23692,-1
 3850 NEXT I
 3860 GO TO 2140
 3870 REM START RECORD #
 3880 INPUT "Start record #?"'SR
 3890 RETURN 
 3900 REM ERROR TRAPPING
 3910 ON ERR RESET 
 3920 PAUSE 30
 3930 ON ERR GO TO 3910
 3940 ON ERR CONTINUE 
 9997 REM  SAVE AND VERIFY 
 9998 SAVE "PROGRAM T" LINE 3770: REM SAVE "PCODE"CODE 63744,1536: GO SUB 3710: PRINT "REWIND FOR VERIFY": VERIFY "": VERIFY ""CODE : GO SUB 3720: GO TO 300
 9999 LOAD "PCODE"CODE : RANDOMIZE USR 63744: GO TO 300

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