A QL LList Utility

See all articles from Update April 1989

This routine may be of particular interest to those such as Bill and myself who do QL listing printouts in column format as master copies for publication. A simple OPEN #n,ser1: LIST #n: CLOSE #n will send a listing to the printer but unless your printer has right-margin setting or column/line setting, long listing lines will splatter the full width of the page. If the left margin is set far enough over to allow only the desired number of columns to be printed before the printer does an end-of-line CR/LF the listing lines will be done properly but will require a cut-and-paste job to prepare a copy master containing more than one column of listings.

Of course, anyone who paid close attention to Bill’s tutorial in the January UPDATE on importing files into QUILL no doubt has figured out how to do this with listings. Once in QUILL, they may then be edited, have margins re-set, and be printed out as any other QUILL file. However, since QL command-words are treated as real words the printed right-hand margins will either be unjustified, with no word wrap-around, or if justified will have spaces inserted so the printout will not quite correspond with the on-screen listing. Also, there is a considerable amount of footwork involved in all this.

All we actually need is to somehow get each line of the listing into a string which can then be sliced any way we want it. The following LLIST was done by reading each line of the Basic listing as data for input into p$. The command codes to set line-spacing, font, etc. may be inserted into line 20 for your printer or else that line may be omitted if you elect to use the pre-set ones or use panel settings.

The routine begins with the selection of the drive no. containing the program to be LLISTed, then displays a directory of the files in that source drive. Key F5 for more than one screenful. An error repeats drive and title entries, or Q (or q) to quit. The entire Basic file is loaded into RAM as data and the printout then is done from a succession of p$ definitions obtained by accessing this data from RAM.

After the data is loaded, the first prompt asks for the number of lines to be printed in this pass (including a title line and one space-line if the title option is selected). An input of 0 at this first prompt allows the program to be aborted with all channels properly closed. This is done automatically if an end-of-file (EOF) takes place before the selected number of lines is printed.

The second and third prompts ask, respectively, for the desired column-width and left-margin settings. Since these are done with string-slices and string-spaces instead of command codes they will work with all printers.

Repeat passes allow re-inserting a page and changing these settings to print side-by-side listing columns that begin with the next line after the last previous one which was printed from the same file-loading.

QL_LLIST

10 REMark Enter YOUR printer codes in line 20 or omit 20 if  not  needed
20 OPEN #7,ser1: PRINT #7,CHR$(27);'Q';CHR$(27);'T11';CHR$(27);'A';CHR$(27);'!': CLOSE #7
30 WHEN ERRor : PRINT #0y$;' not found--check entry': PAUSE 200: GO TO 30: END WHEN
40 CLS: CLS #0: INPUT #0;'Q to quit'\'LLIST program in drive #';drv$: md$='mdv' & drv$ & '_': IF drv$='q' OR drv$='Q' THEN STOP: END IF
50 PRINT 'Key F5 TO SCROLL DIRECTORY': PAUSE 100: DIR md$
60 INPUT #0; 'File Name? ';y$: md$=md$ & y$
70 CLS #0: curln=0: remln=0: REMark current line; remaining line
80 OPEN_IN #8,md$
90 OPEN #7,ser1
100 CLS: INPUT 'Enter zero to cancel ';(y$)\'No. lines this page-column: ';lines: IF lines=0 THEN CLOSE #7: CLOSE #8: GO TO 30: END IF
110 INPUT "Columns per line: ";col
120 INPUT 'Left-margin setting: ';lm: lm$='': lm$=lm$ & FILL$(' ',lm)
130 INPUT 'Key ENTER to skip title-print any chr to print ';t$: IF t$ <>'' THEN tl$='': tl$=tl$ & FILL$(' ',INT(col/2+lm)-INT(LEN(y$)/2)): PRINT #7,tl$;y$: PRINT #7: END IF
140 cnt=0: IF t$<>''THEN cnt=2: END IF : REMark count print-lines
150 IF remln<>0 THEN cnt=cnt+curln-remln: GO TO 250
160 IF EOF(#8) THEN CLOSE #7: CLOSE #8: GO TO 30: END IF
170 INPUT #8,p$
180 lp=LEN(p$): IF p$(lp)=' ' THEN lp=lp-1: END IF
190 IF lp<=col THEN PRINT #7,lm$;p$: cnt=cnt+1: IF cnt=lines THEN GO TO 100: ELSE GO TO 160: END IF : END IF
200 curln=INT(lp/col)
210 DIM lin$(curln,col)
220 FOR n=0 TO curln
230 lin$(n,1 TO col)=p$(col*n+1 TO lp)
240 END FOR n
250 FOR k=remln TO curln
260 PRINT #7,lm$;lin$(k,1 TO col)
270 cnt=cnt+1: IF cnt=lines THEN remln=k+1: IF remln>curln THEN remln=0: END IF : GO TO 100: END IF
280 END FOR k
290 remln=0
300 GO TO 160
310 DEFine PROCedure sv: SAVE mdv1_QL_LLIST: END DEFine

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