A Fist Full of LKDOS Tools

See all articles from Sinc-Link v7 n4
Author(s): Bill Jones
Publication: Sinc-Link
Pub Details: Sinc-Link v7 n4 (Volume 7, Issue 4)
Date: July/August 1989
Pages: 14-16

A Fist Full of LKDOS TOOLS

Provided to Sinc-Link by Bill Jones “UPDATE“

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 anOFF 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 rountult. 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

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 anAuto 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.