As more TS-2068 users become LKDOS users the questions roll in. Some are working “Max DOS” (with Oliger Dos), but most are just getting their feet wetter with the rich LKDOS functions. Sometimes the process becomes a bit of a head scratching event. Update does not sell hair restoring lotion, but perhaps these utilities will have even better results.
The LLISTING for “LKDOS TOOLS” contains a group of utilities, each headed by REM statements. Each of these utilities may be plucked out to make individual sub-routines to MERGE to any BASIC program for their specific TOOL. There are no “ride-in Variables” and the utilities are independant. But there are a few vars that are re-used by the follow on tools.
The first few lines are simple Screen set ups. Then Line 104 sets three vars that need “Fast Finding” by the utilities. When initialized FIRST in the vars file, each subsequent use makes the programs run faster than if a large file must be searched for the vars values.
TOOL #1, The LKDOS INITIALIZATION, begins at line 9800. When the computer is turned ON, LKDOS is asleep. The “Wake-Up” slap is <RANDOMIZE USR 100:> followed by a LK System Command. The LKDOS manual tells us that we can use <RANDOMIZE USR 100:OPEN#4,”dd”> and from then on we can use <PRINT#4:> followed by a System Command. However, as we get into “MAX DOS”, the PRINT#4 causes some conflicts. Actually, I find that it is better to always just use RANDOMIZE USR 100 before the System Commands, and never <OPEN#4,”dd”>. Later, we will see that having channel 4 OPEN for the PRINT#4 commands can result in “too many channels open” and cause some confusion.
So, as this programmers personal preference, these utilities wont use PRINT#4 at all! If you thought that PRINT#4 was an essential ingredient for the soup then this should convince you, as there are many many LKDOS system commands and all are preceeded by RANDOMIZE USR 100. AND, channel #4 remains closed throughout. You can corrolate the POKES in line 9804 through 9898 with the LKDOS “Version 3 EPROM” manual. <OPEN#3,lp> wakes up the PRINTER CODE in the LKDOS EPROM. At that time the key addresses in the LKDOS RAM chip are set to numbers that may or MAY NOT be suitable for your printer, or your desires. Beginning at line 9800 and ending at line 9814 is an initialization routine that will fit into your needs for all Basic Program.
The next TOOL begins at line 9818 and is simply a “Proof Test” of the initialization routine. But note the LPRINT at the end of line 9814. This is necessary after the initialization tools to reset the printer’s carriage for the new LEFT MARGIN. Most printers requires an OFF and back ON for any switch settings that changes print style or margins. Line 9818 simply prints groups of five characters for you to easily check to see that your desired TAB and LINE WIDTH are correct. You ALWAYS POKE 16090 with ONE Number LESS than your desired line width. Also, I might mention that all of these system POKES require either RANDOMIZE USR 100 or PRINT #4 AHEAD of the POKE.
In fact, all LKDOS commands require the RANDOMIZE or PRINT #4. This is because the LKDOS system is operating in an EXTRA MEMORY BANK, “the DOS BANK”. So, RANDOMIZE USR: or PRINT#4: causes a BANK SWITCHING caper in order to carry out the following LKDOS command. The LKDOS system opens up another bank of memory and uses 16K of that new bank of memory addresses. Later we may see more “chunks” of the LKDOS Bank used, but for now thats all of the noodles in that bowl of soup (16K). Half is the EPROM and the other half is RAM.
The next LKDOS TOOL is at line 9822 and is a “CAT PRINTER”. This lets you LPRINT a Disk Directory, another, and as many more as you would like to do, and from any drive in your system. You can get hard copies of all of your disks in the library with this CAT PRINT utility. Also, if you want to you can add <GOSUB 9960> just after the line number of line 9826. This would let you set up TAB for the Cat Print in order to print double column catalogs.
Tools #3 is a very versatile group of functions. First it uses some of the “TS-2068 DATA INPUT” program’s techniques. Thats the neat program that was presented in the April 89 issue. Here it is abbreviated to provide a fairly fast input typing to a “Sequential File SAVER”. Actually this set of functions is a “mini data base manager and printer”, jerked together to demonstrate a method of creating managable SEQUENTIAL FILES in disk. The File Saver operates so slick that you dont even realize that the typed data is going into the disk file, and you wont believe that it is until proven by the next TOOL.
So, lets discuss whats happening between line 9869 and 9908. First, the DATA INPUT section operates to INPUT data from the keyboard. A “Character Counter” is printed at the bottom Right corner of the screen. You can create “LINES of data by watching the counter as you type. For example, if you plan to print lines of 64 characters, then as the counter reaches near 64, touch ENTER. The cursor springs down to the start of the next line— B U T !! What you wont believe is that each time you touch ENTER, the previous line of data is socked away in a Sequential Disk File!! Actually ALL data ABOVE the current line being typed are “DEAD LINES”. They have all been saved to disk, and are retained on screen just for your orientation.
Back at line 9890 a “File # is entered”. Then a <GO SUB 9970 “OPENS a Sequential Disk File” with the name of “Dta” plus the file number. Example: file #1 will have the title of “Dta1.A$ OUT “. Thereafter each time ENTER is touched, the data in U$, the typing buffer, is saved to that file in disk. Lines 9872, 9874, and 9876 comprise the (now familiar) “Peek K State” INPUT typing function for reading the keyboard and assigning the key struck code to var c. If the key is DELETE, then line 9878 goes SUB to the DELETE Characer routine. If the key struck is ENTER, then line 9880 goes SUB to the Sequential File SAVER routine. After the line of data is SAVED the typing buffer U$ is zeroed and its back to the K-State for more characters.
Continuing- Then at line 9884, if CAPS-SYM SHIFT is the key, we have decided to QUIT, and the last line is SAVED at 9906. During input typing none of these escape routes are taken and line 9985 executes to do several things. First, the character counter prints the current length to keep you up-dated. Then the last character is printed to screen. Then the “print position variables a and b are up-dated. Then line 9986 prints the cursor and then Concatenates the last character to U$. At line 9888 the GO TO 9872 gets Peek K again for the next character. Now lets look back at lines 9880 and 9885. Both use <GO SUB 9940> which is to check to see if the screen is full.
If so, then at line 9940 we POKE 23692,255. This kills SCROLL and any subsequent line ENTERED will push up from the screen bottom, a SCROLL UP if you will. Line 9906 is the END ESCAPE routine. But it also gives you a choice of continuing input to the disk file. If you decide to quit then line 9908 does a V E R Y IMPORTANT function. It CLOSES the FILE with <RANDOMIZE USR 100:CLOSE#5>. This is absolutely essential when you finish inputing data to an open disk file. ANY LKDOS FILE is OPENED with <RANDOMIZE USR 100> and must be CLOSED in the same manner. Remember that LKDOS is operating from the “DOS BANK of memory” and wont operate without RANDOMIZE USR 100.
TOOL #4, is the “View-PRINT” for Sequential Disk Files. These functions begin at line 9918 and end at line 9946. First, at line 9918, the STOP is to keep this package of functions from operating after the previous routine is finished. So, if you are operating both together, the STOP will be reported. Then to enter the routines type <CONT ENTER>. Line 9920 gives the choices of Viewing the Disk File or Printing it. We will skip the rationale about screen viewing and work with PRINTING. Line 9924 goes SUB to a neat little “PRINTER FORMAT” routine at line 9960, where you can format the TAB and Line width.
Then line 9928 does a little shenanagin of selectively OPENING a previously closed file in disk. Variable ZZ is carried over from the INPUT TOOL section (line 9870). Its value is between 1 and 5. So the proper line for the GO SUB is already fixed. This group of lines are the “OPEN#5 “IN” group”. The objective is to OPEN the disk file and read the file back to the printer. A little parenthetical comment is appropriate. I couldn’t find a key to Concatenate the titles with a number for either the OUT titles or the IN titles. This leaves the door open for someone to feed back the solution.
At line 9930 the <INPUT #5;u$> “reads the disk file that has been opened. The disk file contains as many “RECORDS” as were previously separated by “ENTER”. Saying that in a different way; Each time you SEND data to a OPEN FILE, it forms a new RECORD. Remember that earlier we sent the “lines of data” to disk each time we touched ENTER. So, each line became a separate RECORD, and now we are READING the records back from disk, one at a time. MOVING on to line 9932 and 9934, variable xx=2 for PRINTING, so line 9934 executes to LPRINT U$, which has the current RECORD from disk.
Then Line 9936 goes back to line 9930 to get the next record. There is one problem to overcome. We are in a LOOP here, returning to line 9930 to keep on reading in records from the disk file. When there are no more records, the system will cause a report code “no more records” and stop. So, we place <ON ERR GO TO 9946> at the beginning of line 9930. Then when there is an attempt to read beyond the last record, the ON ERR will trip and line 9946 will execute.
When line 9946 executes, every record of the disk file has been printed. The ON ERR is RESET, and the disk file is CLOSED. And that is the end of this haranguing group of epistles (except for a few closing comments).
Sequential Files seemed to be a very complicated part of LKDOS to me. So, I pushed it aside until I could get rountuit. Actually, once one gets used to “OPENING” and CLOSING FILES, which is the principal bug-aboo, sequential files offer great flexibility of managing data. The file handling is much faster than I thought possible. The principal advantage is the TINY amount of computer memory that is used. One can just keep on building a disk file to an extremely large size, much larger than can be handled within FREE RAM memory. These utilities points out just one method of data management with sequential files using short “line length” records. A record can be from a single character in length to several thousand characters.
Each individual save to disk is a separate RECORD. So, to build large records, one just keeps on typing and when finished, do the SAVE with <PRINT #5;”data” or U$>. Dont forget to CLOSE the file when finished, either sending or retrieving data. Have fun! -BJ
LKDOS TOOLS by the Half Dozen
100 REM "LKDOS Print Tools #1-5"
102 BORDER 0: PAPER 0: INK 7: CLS
104 CLEAR : LET a=0: LET b=0: LET u$=""
9800 REM #1. Initialization Routine
9804 RANDOMIZE USR 100: OPEN #3,"lp": PRINT #0;"Input Type of Interface"'"<1> Aerco-Oliger"'"<2> Tasman"'"<3> A & J": PAUSE 0: LET zz=CODE INKEY$-49: IF zz>2 THEN CLS : GO TO 9804
9806 RANDOMIZE USR 100: POKE 16096,zz
9808 INPUT "Line Width?";Lw: RANDOMIZE USR 100: POKE 16090,Lw-1
9809 INPUT "Left Margin Tab?";Lm: RANDOMIZE USR 100: POKE 16094,lm
9810 INPUT "<1> for Line Feed - <2> No Lf";Lf: IF Lf<1 OR Lf>2 THEN GO TO 9810
9812 RANDOMIZE USR 100: POKE 16092,(10 AND Lf=1)+(0 AND Lf=2)
9814 PRINT #0;"Turn OFF PRINTER, Re-Set Printerswitches, then TURN Back ON. ENTER when Done": PAUSE 0: LPRINT : CLS
9818 FOR n=1 TO 150 STEP 5: LPRINT "xxxx ";: NEXT n: LPRINT : REM Test print lines
9820 STOP
9822 REM #2. CAT PRINT * Print a Disk Catalog
9824 CLS : INPUT "Drive #";dn: RANDOMIZE USR 100: GO TO dn
9826 RANDOMIZE USR 100: POKE 16090,31: REM * Set line to 32 Chrs
9850 RANDOMIZE USR 100: OPEN #2,"lp": RANDOMIZE USR 100: CAT "",: PRINT ': RANDOMIZE USR 100: CLOSE #2
9860 PRINT AT 20,0;"Install new Diskette, -OR- ""Q"" to Quit, Any Key for Next": PAUSE 0: CLS : LET z$=INKEY$: IF z$="Q" OR z$="q" THEN GO TO 9864
9862 GO TO 9826
9864 STOP
9866
9868 REM ** Sending String Data to Disk
9869 REM #3. Create the U$ Data first * Use Caps Sym Shf to QUIT * Use ENTER for starting new line
9870 LET u$="": CLS : PRINT AT 20,0;"Turn Disk ON, Enter a file.nbr <1 to 5 only)": INPUT zz: GO SUB 9970+zz: CLS : LET u$="": LET a=0: LET b=0: PRINT AT a,b;" ";:
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
9880 IF c=13 THEN GO SUB 9940: GO SUB 9902: GO TO 9872
9884 IF c=14 THEN GO SUB 9902: GO TO 9906
9885 PRINT AT 21,29;LEN u$;AT a,b;CHR$ c;: LET b=b+1: IF b=32 THEN GO SUB 9940
9886 PRINT AT a,b;"_";: LET u$=u$+CHR$ c
9888 GO TO 9872
9890 LET u$=u$( TO LEN u$-1): LET b=b-1: IF b=-1 THEN LET b=31: LET a=a-1
9892 PRINT AT a,b;"_";: GO TO 9872
9902 PRINT #5;u$: LET u$="": PRINT AT 21,29;" ": RETURN
9906 CLS : PRINT AT 20,0;"<1> Create More Text"'"<2> QUIT": INPUT xx: IF xx=1 THEN GO SUB 9940: GO TO 9872
9908 RANDOMIZE USR 100:CLOSE #5:STOP
9918 STOP : REM #4. LPrint or View disk file
9920 CLS : PRINT AT 20,0;"<1> View File <2> LPRINT File": INPUT xx: IF xx=1 THEN GO TO 9928
9924 CLS : PRINT AT 20,0;"Set Printer ON, Then ENTER": PAUSE 0: CLS : GO SUB 9960: REM * Send data to printer instead of screen
9928 CLS : LET u$="": GO SUB 9980+zz: REM * Open disk file for INPUT to screen or printer
9930 ON ERR GO TO 9946: INPUT #5;u$: REM * Bring in record from disk
9932 IF xx=1 THEN PRINT u$: REM * Print this record and get next record from disk.
9934 IF xx=2 THEN LPRINT u$: LET u$=""
9936 GO TO 9930
9940 LET a=a+1: LET b=0: IF a>21 THEN POKE 23692,255: LET a=21
9942 PRINT : PRINT "_";: RETURN
9946 ON ERR RESET : RANDOMIZE USR 100: CLOSE #5
9950 STOP
9952 GO TO 9920
9956 REM #5. Gosub Routine for quick format changes
9960 CLS : INPUT "Input TAB;";Lm: INPUT "Line Width";Lw: RANDOMIZE USR 100: POKE 16094,Lm: RANDOMIZE USR 100: POKE 16090,Lw-1: LPRINT : RETURN
9970 REM * Tell me how to Concatenate a number to OUT File?
9971 RANDOMIZE USR 100: OPEN #5,"Dta1.A$ OUT ": RETURN
9972 RANDOMIZE USR 100: OPEN #5,"Dta2.A$ OUT ": RETURN
9973 RANDOMIZE USR 100: OPEN #5,"Dta3.A$ OUT ": RETURN
9974 RANDOMIZE USR 100: OPEN #5,"Dta4.A$ OUT ": RETURN
9975 RANDOMIZE USR 100: OPEN #5,"Dta5.A$ OUT ": RETURN
9981 RANDOMIZE USR 100: OPEN #5,"Dta1.A$ IN ": RETURN
9982 RANDOMIZE USR 100: OPEN #5,"Dta2.A$ IN ": RETURN
9983 RANDOMIZE USR 100: OPEN #5,"Dta3.A$ IN ": RETURN
9984 RANDOMIZE USR 100: OPEN #5,"Dta4.A$ IN ": RETURN
9985 RANDOMIZE USR 100: OPEN #5,"Dta5.A$ IN ": RETURN
Two More TOOLS
The above two utilities are very useful to me. The LKDOS disk catalog does not contain the Start Address and END address or byte length of CODE FILES (Extension .C1). So, one is left fumbling in the dark when one needs that information to peek a code file. If you can peek a code file you can convert the peeks to Characters (if the code represents character data). Or, if it is a CODE Program, the code can be disassembled. “CODE FINDER” does that for you.
Next, we have a nice little utility to AUTO SAVE a program. “Heck, thats easy to do with just RANDOMIZE USR 102, eh”? It sure is, but the SAVE takes about 7 cylinders of disk space! This is because an Auto Save SAVES every bit of RAM from PROG clear up to Ram Top. So an auto save actually saves 38K of stuff to disk, when the actual program may be only 2K in length and will fit in just ONE CYLINDER of the disk.
The “LKDOS AUTO SAVE” utility given above reduces RAM TOP to about 750 bytes above the basic program and its variable file. Then it saves the program so that it auto runs by holding the ENTER key as the computer is turned on.
There is some rationale about Auto Running programs with LKDOS. We will attack it this this way. We reduce RAM TOP to make the program shorter, thus taking up less disk space. BUT- when the program is reloaded, RAM TOP is STILL REDUCED. The result is that the program will Auto Boot O.K., but then may have a severe shortage FREE MEMORY for operation. If we reduce FREE (by setting Ram Top DOWN before the save) then it could be that the program wont run after auto loading. The way to fix this is to “prepare the program before saving it”. We do that by installing a bit of programming in the FIRST convenient program line of the program to be saved.
There are two addresses, the contents of which controls Ram Top. They are addresses 23730 and 23731. Upon start up these two addresses have these values: 23730=87 and 23731=255. So, we should POKE these value to the two addresses EARLY in the auto run program. We do that by adding to the first operating line of the program: <POKE 23731,255:POKE 23730,87>. Then when the program auto loads Ram Top will be set to 65367, its normal setting.
5 REM "CODE FINDER"** Adaptable to all TS-2068 systems ** Finds start and end address, and byte length of any CODE program.
10 BORDER 0: PAPER 0: INK 7: CLS : INPUT "Data Disk #?";dd: RANDOMIZE USR 100: GO TO dd: RANDOMIZE USR 100: CAT "",: INPUT "File name";z$: RANDOMIZE USR 100: LOAD z$CODE
20 CLS : PRINT "Searching for Starting Code Adr"''': FOR z=30000 TO 65535
30 IF PEEK z<>0 THEN PRINT "Code Start is ";z: LET aa=z: GO TO 50
40 NEXT z
50 PRINT '''"Searching for END Code Address": FOR z=65367 TO z STEP -1
60 IF PEEK z<>0 THEN PRINT "End address=";z: GO TO 80
70 NEXT z
80 PRINT ''"The byte length is ";z-aa:
9990 REM *** LKDOS AUTO SAVE ROUTINE ***
9992 POKE 23730,255: POKE 23731,PEEK 23642+3
9994 RANDOMIZE USR 102: RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.