Classic Computer Magazine Archive COMPUTE! ISSUE 86 / JULY 1987 / PAGE 98

IBM Printer Control

Ronald Dorchester

Now you can send printer control codes from DOS with a program that understands your own commands.

One of the most common, and sometimes bothersome, tasks for any IBM PC/PCjr user is sending control codes to a printer prior to printing. "IBM Printer Control" is a compact, convenient program which is customized exactly for your needs. It can send a variety of different commands to the printer, using command names that you have devised.

Before you type in the program, decide what control codes you want to use. Consult your printer manual to determine the control codes for the features you want. For each feature, select a descriptive name to be used when you invoke the printer control program from DOS. For instance, you might use the names DS-ON and DS-OFF for the commands that turn double-strike printing on and off.

Lines 1200-1231 of the program contain DATA statements with example commands and control sequences. The commands are the words you will type from the DOS prompt to invoke the corresponding features, and the numbers following the commands are the control characters for those commands. Some commands, such as BKSPC (backspace) are very simple, consisting of only a single character. Others contain a sequence of several control characters. If you frequently use a certain sequence of commands, you might want to put the entire sequence into a single command. The NORMAL command in line 1209 is an example of one such sequence.

Notice that each control sequence ends with the value —1, which is a marker indicating the end of the sequence. The last control character is a carriage return (character 13). The carriage return causes the control sequence to take effect immediately, allowing each command to execute independently.

When you type in the program, edit lines 1200–1231, adding or substituting your commands for the example commands. The name of the command must come first, followed by its control characters, and the value —1. The command names can be any legal DOS name; however, no name extensions are allowed.

After making all the necessary modifications, save a copy and then run the program. If you made no typing errors in your DATA statements, an executable machine language program called PRNCTRL.COM will be written to disk. Like other machine language programs, this one is run from the DOS prompt by typing its name (the .COM extension is optional). If you type PRNCTRL from the DOS prompt and press RETURN, the program prints all the command names which it understands. This is a convenience in case you forget some of the command names. The normal usage is to supply the name of one or more commands. For instance, assuming you included a command named NORMAL, the following invokes PRNCTRL, sending the NORMAL command to reset the printer to its default condition:

PRNCTRL NORMAL

You can send more than one control sequence at a time. For instance, you might use this command to turn on compressed and double-strike mode:

PRNCTRL CMP-ON DS-ON

If you supply an invalid command name, the program displays the error message Invalid Option and returns to the DOS prompt.

PRNCTRL.COM Filemaker

For instructions on entering this program, please refer to "COMPUTE!'s Guide to Typing In Programs" elsewhere in this issue.

HE 100 ' Printer Control
BN 110 ' Copyright 1987
FN 111 ' Compute! Publications, Inc.
LK 120 ' All Rights Reserved.
HH 125 '
BD 126 CLS : PRINT"Copyright 1987" : PRINT"Compute! Publications, Inc." : PRINT"All Rights Reserved." : FOR X = 1 TO 1500 : NEXT
PJ 130 CLS : DEFINT I : FOR I = 0 TO 5 : READ MSG$(I) : NEXT
BM 131 READ PGM$, I1MAX, I2MAX, GRTOTCK, ILOF
ND 140 IPASS = IPASS+1 : PRINT MSG$(IPASS) : IF IPASS = 0 OR IPAS S = 3 THEN 1000
BI 150 PRINT : IF IPASS = 2 THEN OPEN PGM$ AS #1 LEN = 1 : FIELD #1, 1 AS BYTE$
BH 160 RESTORE 501 : GRTOT = 0 : FOR I 1 = 1 TO I1MAX : FOR I2 = 1 TO I2MAX
FP 170 READ H$ : IBYTE = VAL ("&H"+H$) : ITOT = ITOT+IBYTE
PF 180 IF IPASS = 2 AND ICLOF < ILOF THEN LSET BYTE$ = CHR$(IBYTE) : PUT #1 : ICLOF = 1CLOF+1
JL 190 NEXT 12 : READ ICHECK : IF ICHECK = ITOT GOTO 210
JL 200 PRINT MSG$(4) ; 500+I1 : IPASS = -1
BM 210 GRTOT = GRTOT+ITOT : ITOT = 0 : NEXT I1 : PRINT
BN 220 IF IPASS>0 AND GRTOTCK = GRTOT GOTO 140
AH 230 IF IPASS<>-1 THEN PRINT MSG$(5) : END ELSE GOTO 140
HA 300 DATA Correct Errors., Checking DATA Lines., Creating Program.
HB 310 DATA Program Created., Error(s) On Line -, Check Line 500.
BI 500 DATA "A : PRNCTRL.COM", 24, 16, 34236, 381
MM 501 DATA E9, AC, 00, 0D, 09, 0D, 0A, 50, 52, 4E, 43, 54, 52, 4C, 20, 20, 1063
FD 502 DATA 2D, 20, 20, 4F, 75, 74, 70, 75, 74, 20, 50, 72, 69, 6E, 74, 65, 1424
LM 503 DATA 72, 20, 43, 6F, 6E, 74, 72, 6F, 6C, 20, 43, 6F, 64, 65, 73, 2E, 1455
CC 504 DATA 0D, 0A, 43, 6F, 70, 79, 77, 72, 69, 74, 65, 20, 52, 6F, 6E, 61, 1421
NI 505 DATA 6C, 64, 20, 44, 6F, 72, 63, 68, 65, 73, 74, 65, 72, 20, 31, 39, 1421
NN 506 DATA 38, 36, 0D, 0A, 09, 20, 20, 31, 30, 39, 34, 37, 20, 43, 72, 6F, 791
HP 507 DATA 77, 6E, 20, 50, 61, 72, 6B, 0D, 0A, 09, 20, 20, 53, 61, 6E, 20, 1077
FN 508 DATA 41, 6E, 74, 6F, 6E, 69, 6F, 2C, 20, 54, 58, 20, 20, 37, 38, 32, 1201
KA 509 DATA 33, 39, 0D, 0A, 1A, 0D, 0A, 56, 61, 6C, 69, 64, 20, 4F, 70, 74, 1015
JH 510 DATA 69, 6F, 6E, 73, 20, 41, 72, 65, 3A, 0D, 0A, 0D, 0A, 49, 6E, 76 1158
CK 511 DATA 61, 6C, 69, 64, 20, 4F, 70, 74, 69, 6F, 6E, 3A, 20, 07, 01, BE, 1363
BE 512 DATA 80, 00, AC, 3C, 00, 77, 12, 80, 3E, AE, 01, 01, 75, 06, E8, 7A, 1340
QI 513 DATA 00, E8, 86, 00, B8, 00, 4C, CD, 21, BF, 5C, 00, B8, 03, 29, CD, 1580
JL 514 DATA 21, 80, 3E, 5D, 00, 20, 74, DF, 56, BB, 7D, 02, 83, 3F, 00, 74, 1397
EK 515 DATA 2B, BF, 5D, 00, 8B, F3, B9, 08, 00, F3, A6, 74, 08, 8B, 77, 08, 1701
FN 516 DATA 8D, 58, 0A, EB, E7, C6, 06, AE, 01, 00, 8B, 4F, 0B, 8B, D3, 83, 1791
CN 517 DATA C2, 0A, BB, 04, 00, B4, 40, CD, 21, 5E, EB, BD, EB, 2C, 00, BA, 1857
DI 518 DATA 9B, 01, B9, 13, 00, E8, 17, 00, C7, 06, 65, 00, 0D, 0A, BA, 5D, 1223
II 519 DATA 00, B9, 0C, 00, E8, 08, 00, E8, 20, 00, B8, FF, 4C, CD, 21, 50, 1534
KI 520 DATA 53, BB, 02, 00, B4, 40, CD, 21, 5B, 58, C3, C6, 06, 84, 01, 20, 1497
HN 521 DATA BA, 05, 01, B9, 80, 00, E8, E6, FF, C3, BA, 85, 01, B9, 16, 00, 1944
DK 522 DATA E8, DC, FF, BB, 7D, 02, B8, 20, 20, 83, 3F, 00, 74, IE, 8B, D3, 1959
KJ 523 DATA 8D, 7F, 08, 8B, 35, 8D, 58, 0A, 83, 3F, 00, 75, 03, B8, 0D, 0A, 1228
KF 524 DATA 87, 05, B9, 0A, 00, E8, B7, FF, 87, 05, EB, DD, C3, 00, 00, 00, 1796
LJ 1000 IF IPASS = 0 THEN END
PA 1010 DIM IB (128) : RESTORE 1200 : PRINT "Adding Printer Control Statements…"
CH 1020 CMD$ = SPACE$(8) : READ RD$
ON 1030 IF RD$ = "/*" THEN LSET BYTE$ = CHR$(0) : PUT #l : PUT #1: PRINT "Done." : END
MD 1040 	MID$(CMD$, 1) = RD$ : PRINT SPC(5) ; CHR$(34); CMD$; CHR$(34)
HI 1050 	FOR I = 1 TO 8 : IC = ASC(MID$ (CMD$, I, 1)) : IF IC > 96 AND IC < 123 THEN IC = IC-32
LC 1060 	LSET BYTE$ = CHR$(IC) : PUT #l : NEXT
HA 1070 IBX = 0 : READ IC : WHILE IC > = 0 AND IC < = 255 : IBX = IBX + 1 : IB(IBX) = IC : READ IC : WEND
HI 1080 LSET BYTE$ = CHR$ (IBX MOD 256) : PUT #1 : LSET BYTE$ = CHR$ (IBX\256) : PUT #1
OL 1090 FOR I = 1 TO IBX : LSET BYTE$ = CHR$ (IB(I)) : PUT #1 : NEXT : GOTO 1020
HN 1100 '
JD 1110 'Printer Control Statements.
QM 1120 ' Format: DATA cmd-name, code, <code,…>-l
HG 1130 '
OM 1200 DATA CR, 13, -1
IG 1201 DATA-LF, 10, -1
NJ 1202 DATA FF, 12, 08, 13, -1
KE 1203 DATA BKSPC, 08, -1
BE 1204 DATA LPI-6, 27, 50, 08, 13, -1
CK 1205 DATA LPI-8, 27, 48, 08, 13, -1
FK 1209 DATA NORMAL, 18, 27, 70, 27, 72, 27, 50, 08, 08, 08, 08, 13, -1
DL 1210 DATA CMP-ON, 15, 08, 13, -1
NB 1211 DATA CMP-OFF, 18, 08, 13, -1
FK 1220 DATA EMP-ON, 27, 69, 08, 13, -1
KJ 1221 DATA EMP-OFF, 27, 70, 08, 13, -1
EO 1230 DATA DS-ON, 27, 71, 08, 13, -1
BH 1231 DATA DS-OFF, 27, 72, 08, 13, -1
PP 1500 DATA /* : 'Marks End of Printer Control Statements