A Half Dozen or More TOS Tools

Author(s): Earl Dunnington
Publication: Update Magazine
Pub Details: Update October 1989
Date: October 1989
Pages: 21-23

This program was converted from Bill Jones “LKDOS TOOLS BY THE HALF DOZEN” published in the July issue. Whereever possible I have used the same range of line numbers.

There are many differences between LKDOS and TOS. Rather than using RANDOMIZE USR 100, TOS uses an asterisk after the BASIC command to denote that it is a disk command. TOS has a Serial Printer driver and does not have a Centronics Parallel print driver. This program is designed for use with the OS-64 cartridge, a Centronics Parallel printer and a 80 column monitor.

With the OS-64 in the dock, when the 2068 is powered up,the screen colors are set up with a 64 character display. The default printer interface is either an AERCO or Oliger. The two problems with the OS-64, is that one should have a 80 column monitor and that there is no single POKE for setting the left margin of the printer. One must know the manufacturers code for setting the left margin or program around it. In order to make this program universal as far as printers go, I have chosen the second option.

The first two lines in the program are REM statements. Line 104 sets RAMTOP as the OS-64 V1.71 does not do this automatically. This prevents unwanted crashes while in the BASIC program. Aswith LKDOS Tools, variables are initialized so they can be found faster by the program.

TOOL #1. PRINTER INITIALIZATION. TOS does not require initialization like LKDOS. Merely turning on the drives and inserting a formatted or program disk accomplishes this. The OS-64, however, must be initialized for type of interface, number of characters per line, if the computer must generate a carriage return, and if the computer must generate a line feed. This is accomplished in lines 9801 to 9814.

The next tool begins at 9815 ending at 9819. Itis merely a five line proof test of the initialization of the OS+64 and the printer. To overcome the lack of a single poke to set the left margin, the string variable M$ is dimensioned using the variable TB. When a string is dimensioned it contains only spaces. M$ is printed at the front of each line to provide the left margin.

The next tool is the two really neat subroutines, devised by Bill Jones,that allow one to switch from a 64 character display to 32 and vice versa. They are contained in lines 9820 and 9821. When in the 32 character mode, you cannot use LOAD, SAVE, LPRINT, or RANDOMIZE a location in the OS-64 without crashing the computer.

TOOL #2. The CAT print tool starts at line 9822. As the old saying goes, there is more than one way of skinning a cat. In order to overcome the margin setting problem, a different method is used from the one used by Bill in his LKDOS CAT Print.

This version picks up the characters from the screen using SCREEN$. In addition Tree Structured or nested Subdirectories are allowed in TOS. Not so in LKDOS. Unfortunately Tree Structured directories are stressed in the TOS manual, rather than just formatting a disk, SAVEing, and LOADing a program. This makes the use of disk drives appear very complicated to the novice. Actually using disk drive “A” is no more complicated than using a tape recorder to save and load programs. The drives in TOS are daisy chained to the “A” drive. That is a program disk must be in the “A” drive for the other drives to work. The directory in another drive becomes a subdirectory of the disk in the “A” drive. Printing a catalog from any other drive would give an erroneous result, listing a directory that is not on the disk. For this reason I did not allow the option of a change in drives.

TOOL #3-SENDING STRING DATA TO DISK. This program follows the LKDOS version fairly closely. The text entry display is changed to provide a 64 character display. Line 9902 inserts an ENTER character into U$ as an end of record marker. TOS allows 65535 records to a data file. TOS uses a disk drive buffer that allows only 256 characters to be sent to the disk at one time. Lines 9903 to 9904 utilize string slicing and a loop to send the string data to the disk. Line 9940 contains the 2068 replacement for the TS 1000/1500 SCROLL command (LET t=USR 2361). When the text input fills the screen to the end of line 20, the screen scrolls upone line, leaving the character counter undisturbed. Line 9971 concatenates (chains the parts) of the file name into N$ and opens the file as a sequential streem file (no fixed record length) in the output to disk mode. TOS allows an eight character name plus an extension consisting of a period and a three character data type. The use of the extension with BASIC program names is optional.

TOOL #4-LPRINT OR VIEW A DISK FILE. In the LKDOS version Tools 3 and 4 are intertwined. As I wished to make a comparison of the two systems easy, I left them that way in the TOS version. I found it convenient, while programing, to be able to view or LPRINT any data file. Also to see the Catalog while choosing a file. I added these features in line 9920. Once again as the TOS buffer accepts only 256 characters at one time and due to the OS-64 laft margin problem, the program differs from the LKDOS version. TOS allows the use of 16 channels. Four fast (#1-#4) and 12 slow (#5-#16). The fast channels are more convenient for reading back (Input) a stream sequential file and so I used Channel #1. As the BASIC system does not recognize the TOS generated error reports, ON ERROR GOTO is not used. To determine when the the End of File is reached, lines 9930 and 9934 illustrate the method used for TOS.

TOOL #5. It is merely a subroutine for quick printer format changes and is contained in line 9960. Once again it differs from the LKDOS version because of that left margin problem of the OS-64 and the Smith Corona Fastex 80 dot matrix printer.

This article was typed into data files using Tool #3 and Lprinted using Tool #4. One should remember that the major part of programing is the development of the logic which was done by Bill Jones in his LKDOS version. Many thanks Bill.

(Handwritten: and Thanks to you Earl -)

100 REM TOS TOOLS #1-5
102 REM REQUIRES OS-64 CART, CENTRONICS INTERFACE & PRINTER
104 CLEAR 63423: LET A=0: LET B=0: LET C=0: LET U$=""
9800 REM TOOL #1-PRINTER INITIALIZATION ROUTINE
9801 GO SUB 9820: PRINT #0;"TURN OFF PRINTER"''"SET PRINTER SWITCHES"''"IF NECESSARY"''"THEN <ENTER>": PAUSE 0: CLS
9804 PRINT #0;"INPUT TYPE OF INTERFACE"''"<1> AERCO OR OLIGER"''"<2> TASMAN B"''"<3> TASMAN C"''"<4> A & J": PAUSE 0: LET ZZ=VAL INKEY$: IF ZZ<1 OR ZZ>4 THEN CLS : GO TO 9801
9806 POKE 65523,(167 AND ZZ=1)+(135 AND ZZ=2)+(122 AND ZZ=3)+(185 AND ZZ=4)
9807 CLS : INPUT "LINE WIDTH?"''"THEN <ENTER> ";LW
9808 INPUT "LEFT MARGIN TAB?"''"THEN <ENTER> ";TB: IF LW+TB>80 OR LW+TB<1 THEN PRINT #0;"LINE WIDTH + LEFT MARGIN TAB MUST BE LESS THAN 81 WITH PICA"''"<ENTER> TO CONTINUE": PAUSE 0: GO TO 9807
9809 POKE 65525,LW+TB: GO SUB 9821: RANDOMIZE USR 15623: REM The OS-64 does not have a single poke for setting left margin. Must know the printer code if any
9810 GO SUB 9820: INPUT "<1> COMPUTER LINE FEED?"''"<2> NO LINE FEED"''"THEN <ENTER> ";LF: IF LF<1 OR LF>2 THEN GO TO 9810
9811 POKE 65510,(13 AND LF=1)+(0 AND LF=2)
9812 INPUT "<1> COMPUTER CARRIAGE RETURN?"''"<2> NO CARRIAGE RETURN"''"THEN <ENTER> ";CR: IF CR<1 OR CR>2 THEN GO TO 9812
9813 POKE 65511,(10 AND CR=1)+(0 AND CR=2)
9814 PRINT #0;"TURN ON THE PRINTER, THEN <ENTER>": PAUSE 0: GO SUB 9821: LPRINT : CLS
9815 FOR N=1 TO 5: IF TB=0 THEN GO TO 9818
9816 DIM M$(TB): LPRINT M$;
9818 FOR M=1 TO LW: LPRINT "X";: NEXT M: NEXT N: LPRINT : REM Test print lines for printer whose left margin code is not known
9819 STOP
9820 CLS : OUT 255,0: OUT 244,0: BORDER 0: PAPER 0: INK 5: CLS : RETURN : REM Put OS-64 to sleep
9821 CLS : OUT 255,62: OUT 244,3: INK 7: CLS : RETURN : REM wake up OS-64
9822 REM TOOL #2-CAT PRINT-Print a Disk Catalog
9823 PRINT #0;"ARE THE DRIVES ON AND IS"''"THERE A DISK IN ""A"" DRIVE?"''"TURN OFF PRINTER"''"<ENTER> WHEN READY": PAUSE 0: CLS : REM TOS Initialization
9824 POKE 65525,80: RANDOMIZE USR 15623: PRINT #0;"TURN ON PRINTER THEN <ENTER>": PAUSE 0: CLS : REM Set LPRINT width to 80
9826 PRINT #0;"INSERT DISK TO BE CATALOGED"''"IN DRIVE ""A"" THEN <ENTER>": PAUSE 0 : CLS : GO SUB 9856: GO TO *":": CAT *: GO SUB 9860: GO TO *"A"d
9830 GO SUB 9856: CLS : CAT *: GO SUB 9860: INPUT "IS THE DISK TREE STRUCTURED"''"<1> YES"''"<2> NO"''"THEN <ENTER> ";T: IF T<1 OR T>2 THEN GO TO 9830: REM Does the catalog show subdirectories?
9832 IF T=1 THEN GO TO 9840
9834 INPUT "<1> CATALOG ANOTHER DISK?"''"<2> QUIT?"''"THEN <ENTER>";S: IF S<1 OR S>2 THEN GO TO 9834
9836 IF S=1 THEN GO TO 9826
9838 GO TO 9864
9840 INPUT "<1> LPRINT ANOTHER CATALOG?"''"<2> QUIT"''"THEN <ENTER>";S: IF S<1 OR S>2 THEN GO TO 9840
9842 IF S=2 THEN GO TO 9864
9844 GO SUB 9856: INPUT "INPUT SUBDIRECTORY PATHNAME"''"THEN <ENTER> ";P$: CAT *P$: GO SUB 9860: GO TO 9840
9856 INPUT "LPRINT"''"<1> LEFT SIDE"''"<2> RIGHT SIDE"''"THEN <ENTER>";S: CLS : IF S<1 OR S>2 THEN GO TO 9856
9858 RETURN
9860 DIM M$(5): IF S=2 THEN DIM M$(43): REM Sets margin
9862 DIM C$(32): FOR N=0 TO 21: FOR M=0 TO 31: LET C$(M+1)=SCREEN$ (N,M): NEXT M: LPRINT M$;C$: IF C$(1 TO 5)="Max 1" THEN RETURN : REM Picks up catalog from screen and prints it
9863 NEXT N: RETURN
9864 STOP
9868 REM TOOL #3-SENDING STRING DATA TO DISK
9869 REM Create the U$ Data first * Use CAPS SHIFT+SYMBOL SHIFT to QUIT * * Use ENTER for starting new line *
9870 POKE 23730,191: POKE 23731,247: LET A=0: LET B=0: LET C=0: CLS : INPUT "TURN DRIVES ON, INSERT DATA DISK"''"ENTER A FILE NBR <1 TO 99999>";ZZ: GO SUB 9970: LET U$="": CLS : PRINT AT 21,60;LEN U$;AT A,B;"_";: REM TOS allows 8 character name + period and 3 character file type extension
9872 POKE 23611,220
9874 IF PEEK 23611<221 THEN GO TO 9874
9876 LET C=PEEK 23560: POKE 23611,220
9878 IF C=12 THEN GO TO 9890: REM delete char
9880 IF C=13 THEN GO SUB 9940: GO SUB 9902: GO TO 9872: REM ENTER key
9882 IF C=14 THEN GO SUB 9902: GO TO 9906: REM CS+SS keys
9884 IF C<32 OR C>122 THEN GO TO 9872
9885 PRINT AT A,B;CHR$ C;: LET B=B+1: IF B=64 THEN GO SUB 9940
9886 PRINT AT A,B;"_";: LET U$=U$+CHR$ C: PRINT AT 21,60;LEN U$
9888 GO TO 9872
9890 IF LEN U$=0 THEN GO TO 9872: REM error trap
9891 LET U$=U$( TO LEN U$-1): PRINT AT 21,60;" ";AT 21,60;LEN U$;AT A,B;" ": LET B=B-1: IF B=-1 THEN LET B=63: LET A=A-1: IF A=-1 THEN LET A=0
9892 PRINT AT A,B;"_": GO TO 9872
9902 LET U$=U$+CHR$ 13: REM End of record marker
9903 FOR N=1 TO LEN U$ STEP 256: IF LEN U$<N+256 THEN PRINT *#5;U$(N TO LEN U$): GO TO 9905: REM TOS Drive buffer accepts only up to 256 characters at one time
9904 PRINT *#5;U$(N TO N+255): NEXT N
9905 LET U$="": PRINT AT 21,60;" ": RETURN
9906 CLS : INPUT "<1> CREATE MORE TEXT"''"<2> QUIT";XX: IF XX=1 THEN GO SUB 9940: GO TO 9872
9908 CLOSE #*5: STOP
9918 REM TOOL #4. LPRINT OR VIEW A DISK FILE
9920 CLS : CAT *: INPUT "ENTER THE FILE NBR <1 TO 99999> ";ZZ: INPUT "<1> VIEW FILE <2> LPRINT FILE ";XX: LET U$="": IF XX=1 THEN GO TO 9928
9924 CLS : PRINT #0;"TURN PRINTER ON, THEN <ENTER>": PAUSE 0: GO SUB 9960: REM printer initialization
9928 CLS : LET U$="": GO SUB 9980: REM Open disk file for input to screen or printer
9929 IF XX=2 THEN GO TO 9933: REM send data to printer instead of screen
9930 POKE 23729,255: INPUT *#1;U$: IF PEEK 23728<>0 THEN GO TO 9946: REM Peek and Poke are error trap as ON ERROR does not recognize TOS system errors
9931 PRINT U$;: GO TO 9930
9933 IF LM>0 THEN LPRINT M$;
9934 FOR N=1 TO LW: POKE 23729,255: INPUT *#1;U$: IF PEEK 23728<>0 THEN LPRINT : GO TO 9946
9935 LPRINT U$;: IF U$=CHR$ 13 THEN GO TO 9933
9936 NEXT N: GO TO 9933
9940 LET A=A+1: LET B=0: IF A>20 THEN PRINT AT 21,60;" ": LET t=USR 2361: LET A=20: PRINT AT A,B;"_": RETURN
9942 PRINT AT A,B;"_";: RETURN
9946 CLOSE #*1: PRINT #0;"REACHED END OF FILE, PRESS <ENTER>": PAUSE 0
9950 STOP
9952 GO TO 9920
9956 REM TOOL #5. GOSUB ROUTINE FOR QUICK FORMAT CHANGES
9960 CLS : INPUT "INPUT TAB ";LM: INPUT "LINE WIDTH ";LW: POKE 65525,LM+LW: RANDOMIZE USR 15623: IF LM>0 THEN DIM M$(LM)
9962 LPRINT : RETURN
9970 REM Assign file name (N$) and open TOS file as a Stream File
9971 LET N$="DTA"+STR$ ZZ+".DAT": DIM *N$: OPEN #*5;N$;O: RETURN
9980 REM Assign file name N$ and open that TOS file for (I)nput of (1) character at a time, to screen or printer using channel one (*1)
9981 LET N$="DTA"+STR$ ZZ+".DAT": OPEN #*1;N$;I;1: RETURN

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