Printing and Formatting: Commanding the Printer

This is one of many selected Daisy.B6 program routines that will be excerpted and given to Public Domain. These routines will be selected for their generic value. This one provides PRINTER CONTROL. The need was perceived to Command the printer to CHANGE PRINT STYLES to do a LARGE CENTERED CAPTION, then to RESET to the original style. But it does more that that.

We enter the routines with some established Variables. PS=1=Pica Style. PS=2=Elite Style. PS=3=Micron Style. These are sometimes referred to a Pitch. LX=Max Printer Line for the PS style. QQ=computed Center of Page. TB=established TAB. The Printer Control codes (commands) used are for EPSON Compatable Printers. There are three Sub-routines. <GO SUB 2095> prints a CENTERED CAPTION. <GOSUB 2416 Changes the printer to ELITE DOUBLE HEIGHT CHARACTERS and prints a BILLBOARD as seen in the caption above this column. This routine also uses the next one. <GO SUB 2420> SETS a Print Style. Example: If you first type <LET PS=1> then GOSUB 2420, then the Printer is SET to PICA STYLE. The subroutine first CANCELLS Double Hi characters.

These routines, while in TS-2068 Basic, can easily be cloned for the Sinclair QL and the Z88. In fact, Quill and Pipedream both need such automatic printer control utilities.

<GO SUB 2416> does the following by line number: 2416 sets aside the page center var “QQ”: sets aside the control var “GG”: RESETS Var QQ for Page Center for ELITE style: SETS PRINTER to ELITE, then to DOUBLE HI: Prints the caption (M$) by GO SUB 2095: RESETS var QQ and GG. It is to be noted that while the printer’s style was changed, the style variable “PS” has not been changed. Therefore as the program moves on to line 2420 the PS= variable still represents the style of print that was in effect.

Line 2020 begins a dual purpose routine. First to reset the original print style after the 2416 routine has been used. OR, <GO SUB 2420 will set any print style represented by “PS= 1 through 3”. Explanation: Line 2020 first CANCELLS DOUBLE HI. Then if printing in the COLUMN PRINT MODE, cp is greater than 1, so Micron Print style is set to PS=3.

Print and Format Utilities

2095 LPRINT TAB qq-LEN m$/2;m$: LET nn=nn+1
2096 IF gg=1 THEN RETURN
2097 GO TO fm
2413 IF IN 127=253 THEN GO TO 2413
2414 RETURN
2416 LET a=2413: LET ga=gg: LET gg=1: LET qz=qq: LET qq=(qq*96/120 AND ps=3)+(qq*96/80 AND ps=1)+(qq AND ps=2): GO SUB a: OUT 127,27: GO SUB a: OUT 127,120: GO SUB a: OUT 127,1: GO SUB a: OUT 127,27: GO SUB a: OUT 127,77: GO SUB a: OUT 127,27: GO SUB a: OUT 127,119: GO SUB a: OUT 127,1: GO SUB 2095: LET qq=qz: LET gg=ga
2420 LET a=2413: GO SUB a: OUT 127,27: GO SUB a: OUT 127,119: GO SUB a: OUT 127,0: IF cp>0 THEN LET ps=3
2422 IF ps=1 THEN GO SUB a: OUT 127,27: GO SUB a: OUT 127,80
2424 IF ps=3 THEN GO SUB a: OUT 127,27: GO SUB a: OUT 127,103
2425 IF ps=2 THEN GO SUB a: OUT 127,27: GO SUB a: OUT 127,77
2426 GO SUB a: OUT 127,27: GO SUB a: OUT 127,120: GO SUB a: OUT 127,2: IF cp<1 THEN LET ll=(INT (80*ll/lx+.5) AND ps=1)+(INT (96*ll/lx+.5) AND ps=2)+(INT (120*ll/lx+.5) AND ps=3)
2427 LET lx=(80 AND ps=1)+(96 AND ps=2)+(120 AND ps=3)
2428 IF cp<1 THEN LET tb=INT ((lx-ll)/2+.5): LET qq=INT (lx/2+.5)
2430 IF cp>0 THEN LET tb=(8 AND cp<2)+(62 AND cp>1): LET qq=(34 AND cp<2)+(87 AND cp>1): LET ll=50
2434 RETURN
2436 REM ** For the QL, the Basic Interpreter doesn't accept some of the BOOLEAN Logic expresions that are in the above lines and the lines will have to be broken down into QL IF THEN LOGIC. "BOOLEAN LOGIC FOR QL PROGRAMMING" would make an interesting Article- Any Volenteers?

Lines 2422 thru 2425 SETS a print style, PS=1=Pica, PS=2=ELITE, PS=3=Micron (pitch). Line #2427 SETS Letter Quality Mode, then Computes a Line Length (LL) that Matches the length of line that was previously in use with the previous print style. Then the Maximum Printer line (LX) is assigned for the current PS=print style. LINE #2428 assigns a new TAB (TB) that will result in the new style’s print margins being aligned with the previously printed lines. At this point if Column printing is NOT in effect, the job is done.

Line 2430 works if Column Printing is in effect (CP is Greater than Zero). First Left tab is set for either Left column (CP=1) or Right Column (CP=2). Then Column Center (QQ) is set for either Left or Right Column. Then the Line Length is set to 50.

USAGE: <LET M$=”A Caption”> <GO SUB 2095> Prints a Centered Caption. <GO SUB 2416> Changes to ELITE DOUBLE HI, and then prints a Billboard Caption. <LET PS=1 thru 3> <GO SUB 2420> Changes the printer setting to the Style of “PS=”, computes MATCHING Line for the new style of print.

Line “BU” is line 2413 which checks the printers status. If the printer is BUSY then <IN 127=253> and the program continues to LOOP Line 2413 until the status changes to READY.

This utility is donated to Public Domain by Update Magazine.