16K disk
by Tony Messina
This issue's utility is rather simple in nature but can prove quite helpful when trying to remember what program is on which diskette. In order for this utility to work you need the following items. 1) A disk drive 2) a printer (40 or 80 column) 3) an ATARI computer with a least 16k of memory. The utility itself will give you a neat, formatted hardcopy of your disk directory (I told you it was simple!). The following article should also give you a general idea about IOCB's and the OPEN/CLOSE statements which are part of the BASIC repertoire.
Many programs appearing in A.N.A.L.O.G. use OPEN and CLOSE statements to perform a particular function. I'm sure such questions as (What is being opened/closed, How/Why is it being opened/closed and How can I open/close my own things?) has crossed your mind, so now would be a good time to find out what it's all about!!
One of the most difficult things to do on any computer is INPUT/OUTPUT or I/O for short. Would you like to write the program (commonly called a driver) to print to the printer or list to the disk or input a character from the keyboard?? It really isn't all that fun. Thanks to those great ATARI folks who designed our systems, (the operating system in particular), we don't have to worry too much about the above-mentioned items. We can control our I/O through an IOCB or Input Output Control Block. The operating system has eight IOCBs. Each IOCB contains information as to the nature of the device we want to communicate with, where the driver for the device is located, where the buffer for the device is located, length of the buffer, the command we are trying to execute on the device (OPEN, CLOSE, PUT CHARACTER, GET CHARACTER etc), Timeout values (i.e. how long do we try to execute a command before we decide to give up) etc. This information is used by the Central Input/Output (CIO) portion of the operating system when communicating with the device on the IOCB specified. Now that we know about IOCBs, lets look at how we set them up.
The OPEN command allows us to communicate with a device using the CIO facility. We don't have to know machine language to access a device... we can use BASIC instead! OPEN just dedicates an IOCB to perform our command. We can think of it as opening a hotline to our device. The line will stay open until we hang up or CLOSE it. The form of the OPEN command is as follows:
OPEN #IOCB,I/O CODE, SPECIAL, DEVICE
Parameters can take on the following values:
IOCB - Any number from 0-7, Usually only 1-5 is best since the operating system uses IOCB 0 for the screen/editor, 6 for any graphics window (I'm sure you all have used a PRINT #6 statement), and 7 for LPRINT and Cassette I/O.
I/O CODE - 4=INPUT, 8=OUTPUT, 12=INPUT and OUTPUT, 6=DISK DIRECTORY INPUT, and 9=OUTPUT (APPEND TO END OF FILE)
SPECIAL - Is usually 0 but can be filled in based on the device you are using. If you are opening a screen mode other then GR.0, you would need to put the GR. mode number in the SPECIAL parameter. If you have a sideways printing printer (say that 10 times quickly), you could get it to print sideways by putting 83 as the SPECIAL parameter. When in doubt, use 0.
DEVICE - Devices which we can control and which BASIC knows about are the KEYBOARD "K:", GRAPHICS WINDOW "S:", PRINTER "P:", CASSETTE "C:", DISK FILE "D:filename.ext", SCREEN EDITOR "E:", and RS232 PORTS "R:"
When opening a device we must make sure that the parameters make sense. We wouldn't want to open a printer for INPUT and OUTPUT since most printers only allow OUTPUT. It also wouldn't make sense to open the graphics window for DISK DIRECTORY INPUT. See... it's not all that complicated now is it??
Once we have opened a device there are many things which can be done. Commands such as PUT #, GET #, PRINT #, etc can be executed by BASIC directly to the device we have opened. The only thing we have to remember is not to use an invalid command for the I/O CODE selected. If we opened the GRAPHICS WINDOW for OUTPUT for example, then we could not use the GET command. Experiment using OPEN with its associated commands and you'll soon become proficient in the mysterious world of ATARI I/O.
This issue's utility opens 2 IOCBs. IOCB 1 is opened for output to the printer LINE 220 and IOCB 2 is opened for disk directory input LINE 230. The filename to get has been set to "D: *,* " since we want them all. DEV$ is simply set to "P:" for the printer, I set all my codes to constants for easier reading. The values can be found in LINES 115 -125. With these two IOCBs open the rest of the utility is a snap. We input a file name in LINE 380 and output it to the printer. A nice thing about the directory input command is that it also returns the number of FREE SECTORS after the last filename has been input. Line 385 checks for this and routes us to LINE 420 when we are done. Another item to note is that the printer now recognizes ; and , so that we can format our output. LPRINT under certain circumstances will recognize these two characters but it's best to open a channel to the printer and do a PRINT # instead. This way we can be sure of obtaining the desired results. The remainder of the utility performs error checks and issues prompts for the user. All of the major sections have been block commented and should present no major problems when you try and figure out what is being done.
Type in the listing and save it to your disk. You can now run the program. If you forget to turn on your printer or disk you will be razzed until you do. Just follow the prompts and you'll soon have a listing of all your directories. You can even print a title (18 characters max) for each of your directories to help jog your memory. One last note. If your printer doesn't support the expanded print mode then you must change LINE 305 by deleting the ESC ESC CNTL N sequence and also deleting the *2) from the centering calculation. If you have an EPSON printer just change the code for expanded print to your appropriate code.
That wraps it up for this issue. Have fun and I hope I have provided you with another useful aid. Keep those ideas, questions, and comments rolling in. Till next issue HAPPY COMPUTING!!