A Full Window Directory for the Sinclair QL

See all articles from Sinc-Link v7 n5
Author(s): Mike Ferris
Publication: Sinc-Link
Pub Details: Sinc-Link v7 n5 (Volume 7, Issue 5)
Date: September/October 1989
Pages: 17-19

Hello fellow QL users. I am new to the club and this is my first contribution. I hope you find it helpful.

I’m sure most of you have found it frustrating to take a directory of a microdrive or floppy and have it scroll up when it reaches the bottom of the screen. Even if you have the TOOLKIT II, which stops the window from scrolling until you hit a key, wouldn’t it be nice to be able to see the whole directory at once (or at least a good portion of it)?

This little program lets you do this. It will display a directory in four columns on the screen and lets you print the directory to a printer the same way.(Isn’t it annoying when you print a directory and it uses up loads of paper by printing only down the left side?)

The program is designed to work in MONITOR or WTV mode 4 with window #1 defined as: WINDOW 450,190,25,15. It will print the directory in four columns of sixteen lines each. If you are using a domestic TV and don’t have WTV (found on TOOLKIT II), you will need to alter some of the variables. See the section on Program Details.

The procedure PRINTIT (lines 350 to 570) prints the directory. It assumes your printer is connected to SER1 and is able to print 80 columns of characters. If your printer is connected to SER2, change line 360 to read OPEN #3,ser2.

Program Details

Lines 120 to 140 open a file on the device specified called ‘directory’. For example, if you enter mdv1_ when asked for the device in line 110, then a file will be opened called mdv1_directory and will be on mdv1_. Keep this in mind since you will need enough empty space on the device for this file. Once you have done this the first time, the file will always be present. If you need to use this program on a device without enough space, change line 120 to open a file on another device. For example, if mdv1_ is full then ‘OPEN_OVER #4,mdv2_directory_for_mdv1’.

Line 170 opens the newly created directory file for input.

Lines 180 and 190 initialize the variables. ‘a’ and ‘b’ are the y and x co-ordinates used in line 230 for the PRINT position. ‘x’ is the index for the array line$() in line 180. This array is used primarily in the PRINTIT procedure. Note that this array truncates strings to 15 chars. and is only large enough for 128 strings. If you have more than 126 files on a device you will have to increase the size of this array .

Lines 200 to 320 inputs a string from the directory file into the array and prints the string on the screen at position a,b until the end-of-file is reached. If you have a different sized window #1 than I do, then take a look at line 310. You will see that if ‘a’ is greater than 16 then ‘b’ is increased by 18 and ‘a’ is set back to 1. If your window is not large enough to hold 16 lines, then change ‘a>16’ to ‘a>no1’ where ‘no1’ is the number of lines you want. Also, if your screen is not wide enough to handle the four columns, you can change ‘b=b+18’ to ‘b=b+no2’ where ‘no2’ is the number of spaces between the first character of one column and the first character of the next. If you chose ‘no2’ to be less than 16, you may want to redefine the array line$() to truncate strings to less than 15 characters. Eg. DIM line$(128,10) will truncate strings to 10 characters. As it stands, the program requires a window wide enough to display 71 characters.

Lines 350 to 570 will print the directory. After running the program to display the directory on the screen, type in PRINTIT to have it print. What this procedure does is to take four elements in the array line$() and make a string, text$.It then prints text$ to the ser1 and then takes the next four elements in the array and so on. If you want to alter the number of columns, you can modify line 470. This line checks to see if ‘t’ is a multiple of 4 where ‘t’ is the number of files in the directory to that point. If ‘t’ is a multiple of four then text$ is printed, creating four columns. If you wish to have 5 columns, change ‘MOD 4’ to ‘MOD 5’ or any other number depending on the number columns you want.

You can also move the columns closer together by modifying line 450. The variable ‘fil’ is the number of blank spaces required to fill in text$ to the start of the next column. You will notice that ‘fil’ is 20 minus the ‘length’ of line$(t). This makes the columns left hand side of the columns on the printer 20 spaces apart. You can change 20 to any number you wish. Eg, making line 450 ‘fil=15-length’ will make the columns on the printer 15 spaces apart.

Note that the program fills the screen by columns (ie. fills column 1 first and then starts the next) where as the PRINTIT procedure fills in by rows (fills the top row first and then starts the next).

Program Listing

10 REMark ** A full window directory **
20 REMark ****** by Mike Ferris *******
30 REMark *****************************
100 CLS
110 INPUT 'Enter device:'!a$
120 OPEN_OVER #4,a$&'directory'
130 DIR #4,a$
140 CLOSE #4
150 CLS
160 AT 0,2:PRINT a$
170 OPEN_IN #4,a$&'directory'
180 DIM line$(128,15)
190 x=0:a=2:b=2
200 REPeat getline
210 IF EOF(#4) THEN EXIT getline
220 INPUT #4,line$(x)
230 AT a,b:PRINT line$(x)
240 IF a=16 and b=56
250 PRINT #0,'PRESS ANY KEY FOR MORE...'
260 z$=INKEY$(-1)
270 CLS
280 a=2:b=2
290 ENDIF
300 a=a+1:x=x+1
310 IF a>16 THEN b=b+18:a=3
320 END REPeat getline
330 CLOSE #4
340 STOP
350 DEFine PROCedure printit
360 OPEN #3,ser1
370 t=1
380 FOR i=0 to 1
390 PRINT #3,line$(i)
400 NEXT i
410 PRINT #3
420 text$=''
430 FOR i=2 to x
440 length=LEN(line$(x))
450 fil=20-length
460 text$=text$&line$(i)
470 IF (t MOD 4)=0
480 PRINT #3,text$
490 text$=''
500 ELSE
510 FOR k=1 to fil:text$=text$&' ':NEXT k
520 ENDIF
530 t=t+1
540 NEXT i
550 PRINT #3,text$
560 CLOSE #3
570 END DEFine

Well, that’s all for now.

If anyone out there is having problems writing a program or if anyone has an idea of a program but are not sure how to go about it, feel free to contact me and I’ll be happy to try to help.

Mike Ferris
[address omitted]
[phone number omitted]

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