home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / info / dostips3.arc / DOSPRINT.TXT < prev    next >
Encoding:
Text File  |  1985-11-25  |  26.6 KB  |  548 lines

  1.                   Program Performs Print Screen
  2.          (PC Magazine Vol 2 No 6 Nov 1983 User-to-User)
  3.  
  4.      Using IBM PC BASIC 2.0, it is possible to duplicate the 
  5. function of the Ctrl-PrtSc key combination under program control.  
  6. To turn ON echo of screen output to the printer:
  7.  
  8.           DEF SEG:POKE &H758,&HFF
  9.  
  10. To turn this printer echo OFF:
  11.  
  12.           DEF SEG:POKE &H758,0
  13.  
  14. -----------------------------------------------------------------
  15.                         Ctrl-PrtSc Toggle
  16.        (from PC Magazine Vol 4 No 16 Aug 6, 1985 PC Tutor)
  17.  
  18.      Writing batch files, for example, to execute timing programs 
  19. that do speed tests on various tests and doing a Ctrl-PrtSc first 
  20. will send all results to the printer.  The following is a small 
  21. assembly language routine that will toggle Ctrl-PrtSc.  This
  22. program will only work on IBM PCs and very close compatibles,
  23. since it assumes IBM's specific placement of the keyboard buffer,
  24. and it also assumes that the PrtSc flag is located 7200 hex.
  25.      A>DEBUG PRINTTOG.COM
  26.      File not found
  27.      -A100
  28.      xxxx:0100 B84000    MOV AX,0040    ;set data segment
  29.      xxxx:0103 8EC0      MOV ES,AX      ;to BIOS area
  30.      xxxx:0105 BB1A00    MOV BX,001A    ;set buffer head to
  31.      xxxx:0108 B81E00    MOV AX,001E    ;first pos (flush)
  32.      xxxx:010B 26        ES:
  33.      xxxx:010C 8907      MOV [BX],AX    ;
  34.      xxxx:010E 40        INC AX         ;set to next pos ...
  35.      xxxx:010F 40        INC AX
  36.      xxxx:0110 26        ES:
  37.      xxxx:0111 894702    MOV [BX+02],AX  ;the buffer tail
  38.      xxxx:0114 B80072    MOV AX,7200     ;put PrtSc flag
  39.      xxxx:0117 26        ES:
  40.      xxxx:0118 894704    MOV [BX+04],AX  ;into buffer
  41.      xxxx:011B B8000B    MOV AX,0B00     ;read bfr status
  42.                                          ;(set ctlpt)
  43.      xxxx:011E CD21      INT 21
  44.      xxxx:0120 B8004C    MOV AX,4C00     ;exit gracefully
  45.      xxxx:0123 CD21      INT 21
  46.      -RCX
  47.      CX 0000
  48.      : 30
  49.      -w
  50.      Writing 0030 bytes
  51.      -q
  52.  
  53. -----------------------------------------------------------------
  54.                       Optimizing Print 3.0
  55.          (PC Magazine Vol 4 No 21 Oct 15, 1985 PC Tutor)
  56.  
  57.      PRINT.COM was introduced with DOS 2.0.  It is a resident program
  58. that prints disk files while other programs are running.  It is thus
  59. fundamentally different from other "background" (or spooler) printing
  60. programs.  Most of the latter create a software print buffer by
  61. allocating a large chunk of user memory to act as a holding area for
  62. text that is to be sent to the printer.  The print buffer program
  63. intercepts printer output, stores it in the created memory buffer, and
  64. then later transfers it to the printer.  This frees up the system for
  65. other activities.
  66.      DOS PRINT.COM transfers disk files to the printer directly and so
  67. takes up much less memory than a buffer-based program.  The size of the
  68. files is limited only by disk space, not by the size of a preallocated
  69. spooling buffer.  Once a regular print RAM buffer becomes full, further
  70. transfer into the buffer slows down to the speed of the printer.
  71.      Although PRINT can be used with a diskette system, it is best
  72. suited for a hard disk system.
  73.      DOS 2.x PRINT.COM programs had problems which is why people chose
  74. to ignore it.  Directory paths could not be specified with the filename
  75. and the operation of PRINT could not be optimized for particular
  76. printers, for example.  But the DOS 3.x PRINT corrected these problems.
  77. The new parameters are designed to help optimize PRINT for your system,
  78. your printer and your needs.
  79.      The /D (device name) and /Q (queue size) parameters are simple
  80. enough.  Normally, /D:PRN or /D:LPT1 will be specified, so you'll print
  81. to the first parallel printer.  /Q can be set to the largest number of
  82. files you'll want to print at one time.
  83.      The /B parameter sets the buffer size; its default is 512 bytes.
  84. This is the amount of memory PRINT will set aside for reading the disk
  85. file.  The default value means that the print file will be 512 bytes at
  86. a time.  If the buffer is too small, you'll see frequent disk accesses,
  87. particularly with a fast printer.  If the buffer is too large, the disk
  88. accesses will be less frequent but will take longer, and PRINT will
  89. occupy more memory -- more than a traditional spooler.
  90.      For a hard disk system with 640K, I recommend setting the buffer
  91. size at something like 4,096 or 8,192, both of which will work
  92. efficiently because they are multiples of 512.
  93.      To understand the /S, /M and /U parameters, we'll have to take a
  94. look at how PRINT works.
  95.      During operation of the PC, the 8253 timer chip invokes a hardware
  96. interrupt (08h) 18.2 times per second, or about once every .055 second.
  97. This interrupt executes a short routine in the ROM BIOS.  The main job
  98. of that routine is to count the number of times it has been called, so
  99. DOS can know what time it is.  Additionally, the Interrupt 08h routine
  100. invokes Interrupt 1Ch, often called the "Timer Tick."  PRINT intercepts
  101. the Timer Tick interrupt to trigger its own operation.
  102.      The /S parameter, which the IBM manual calls the "Time Slice," is
  103. the number of timer ticks during which PRINT will sit idle.  During
  104. this time the rest of the PC system operates normally, as if PRINT had
  105. not been called at all.  Thus, the /S parameter should really be called
  106. the "System Time Slice."
  107.      The /M parameter, called "Max Tick," is the number of timer ticks
  108. during which PRINT actively tries to shovel characters out to the
  109. printer.  This is really the time slice allocated to PRINT.  Assuming
  110. that the printer is ready to receive these characters, PRINT will have
  111. nearly total control during this period, and any other programs that
  112. are running will be suspended.
  113.      The default settings are /M:2 and /S:8.  This means that PRINT is
  114. alternately active for 0.11 second and inactive for 0.44 second
  115. (assuming that the printer is ready to accept characters when PRINT
  116. tries to send them down the line).  Consequently, PRINT will be working
  117. 20 percent of the time; any other program will work at 80 percent of
  118. normal speed.
  119.      The /U parameter, which IBM calls the "Busy Tick," only comes into
  120. play if the printer happens to be busy at the moment PRINT attempts to
  121. send it a character.  The default value is /U:1, which means that PRINT
  122. will wait one clock tick (0.055 second) before relinquishing its /M
  123. time slice.  The rest of the system then goes back to work for /S timer
  124. tick before PRINT makes another attempt to feed the printer.
  125.      PRINT also gives up its time slice if a disk access is in
  126. progress.  The reason for this is obvious: if PRINT has to get another
  127. piece of the file during this time, then real problems develop should
  128. another program be accessing the disk.  PRINT's time slice is also
  129. forfeited if a DOS function call is in progress.
  130.      If /M is very high in relation to /S, you'll notice a significant
  131. degradation in system speed.  If /M is too low, printing will not
  132. proceed as fast as the printer can manage.  If /U is too high, PRINT
  133. may spend too much time just checking the printer without actually
  134. printing anything if the printer is busy.
  135.      One problem with PRINT.COM is that all these parameters may only
  136. be specified when PRINT is first loaded.  So, unless you like doing
  137. little three-finger exercises repeatedly, you would normally have a
  138. very difficult time optimizing the parameters for your system.  There
  139. is a solutino for that.
  140.      I'll discuss the "standard" (though recently discontinued) IBM
  141. Personal Computer Graphics Printer.  The IBM Graphics Printer has an
  142. 80-character internal buffer.  It will not begin printing until the
  143. buffer is full or until the printer receives a carriage return or a
  144. form feed.  When the printer does begin printing, it remains busy and
  145. cannot accept any more characters until its internal buffer is empty.
  146.      The optimum parameter settings for this printer, then, consist of
  147. an /M value equal to the number of timer ticks needed for PRINT to
  148. fill the printer's buffer, and an /S value equal to the timer ticks
  149. required for the printer to print the contents of the buffer.
  150.      The short PRINTSET.BAS program (below) will let you experiment
  151. with PRINT settings after PRINT has been loaded.  Load PRINT for a
  152. reasonably large average file of the type you usually print:  PRINT
  153. bigfile.  Go into BASICA, load the PRINTSET program, and run it.  The
  154. program will ask whether DOS 3.0 or 3.1 is being used.  The PRINTSET
  155. program shows the current settings of the /S, /M, and /U parameters.
  156. You may change any parameter by entering the letter (S, M, or U in
  157. either upper- or lowercase), followed by a comma, followed by the new
  158. value from 1 to 255.  To exit PRINTSET, press Ctrl-Break.
  159.      For the IBM Graphics Printer, start off by setting /M and /U equal
  160. to 1, and /S to 90 timer ticks, which is equivalent to about 5 seconds.
  161. This means that PRINT will be in charge for only one clock tick out of
  162. every 91.  You should get one line printed about every 15 or 20
  163. seconds.  Obviusly, then, that one /M clock tick is not long enough
  164. for PRINT to fill the printer's internal buffer.  Gradually increase
  165. the value of /M until one line is printed every 5 seconds.  You may
  166. notice that most lines print once every 5 seconds, but that some lines
  167. take longer.  Try increasing the value of /U to 2 to get a steady one
  168. line every 5 seconds.  Now gradually decrease /S until the printer
  169. prints continuously.
  170.      For the IBM Graphics Printer, using 80-character lines, good
  171. values are /S:20, /M:4, and /U:2.  These values resulted in better
  172. performance than the DOS default values, even though for most lines,
  173. PRINT is active only one-sixth of the total system time.  The PRINT
  174. command in my AUTOEXEC.BAT file is:
  175.           PRINT /D:PRN /Q:20 /B:8192 /S:20 /M:4 /U:2
  176.      Unlike the IBM Graphics Printer, many other printers have internal
  177. buffers much larger than 80 characters.  If you tried to set /M equal
  178. to the time it takes for PRINT to fill up a large buffer, you may find
  179. it to be something like 20 clock ticks or more.  In operation, this
  180. would be intolerable, since the rest of your system would be halted
  181. during that time.
  182.      For printers with large internal buffers, set /U equal to 1 and
  183. /M equal to 4 or 5 (about 0.25 second), and then experiment with /S.
  184. For very fast printers, you may find /S to be low in relation to /M.
  185. You may want to deliberately slow down the printing so you can get
  186. some work done, or speed up the printing if that's what's important.
  187. In any case, you can use PRINTSET.BAS at any time to adjust PRINT.
  188.      PRINT can be used to print any text file, with or without control
  189. chracters, stored on a disk.  Tabs are expanded, and ASCII 1Ah is taken
  190. to be an end of file, however, so PRINT cannot be used for graphics.
  191. PRINT will be active during any program that does not replace Interrupt
  192. 1Ch with its own interrupt routine.  (Some compiled BASIC programs do
  193. this.)  Using PRINT with Lotus's 1-2-3 is fine.  To actually print
  194. 1-2-3 files in the background while using 1-2-3 may prove a little
  195. clumsy, however.  You'll have to print your worksheet to a file with
  196. the extension .PRN, exit to the system, execute PRINT for that file,
  197. and then reenter 1-2-3.
  198.      Programs that allow going to and returning from the DOS command
  199. level, such as XyWrite or Symphony or Word, make this process a lot
  200. easier.  Be sure, though, to initially load PRINT before you use it
  201. from within another program, since you don't want to make it resident
  202. on top of another application.
  203.      Here's the real kicker: at the DOS command level, and during
  204. execution of any program that uses DOS function calls to obtain
  205. keyboard input, PRINT operates in a totally different manner, and none
  206. of the good stuff explained above about timer ticks is applicable.
  207.      Check it out.  You could set completely wrong values for PRINT
  208. (/S to 255 and /M to 1) and when you exit BASIC to DOS, your printer
  209. will churn away, printing your text as fast as possible.  To understand
  210. why this is so, we'll have to take a look at the more technical
  211. internal workings of PRINT.
  212.      Because PRINT works with disk files, it must make DOS calls to
  213. pull these files into memory.  During a DOS function call, DOS switches
  214. to an internal stack.  DOS actually maintains three stacks: one for
  215. function calls 01h through 0Ch; another for function calls 0Dh and
  216. above (which includes the file accesses); and a third for function
  217. calls 01h through 0Ch when a Critical Error is in progress.
  218.      Because of this internal stack, PRINT (or any other multitasking
  219. utility triggered by a hardware interrupt) cannot arbitrarily make DOS
  220. function calls to access a disk file.  If another program is making a
  221. DOS function call, PRINT's function calls may clobber the internal
  222. stack and eventually cause the system to crash.
  223.      To prevent this, PRINT uses the undocumented DOS Interrupt 21h
  224. function call 34h when it is first loaded.  This function call returns
  225. registers ES:BX pointing to a byte in DOS.  Whenever this byte is
  226. nonzero, a DOS function call is in progress.  When PRINT is triggered
  227. by a timer tick, it checks this byte.  If it's nonzero, PRINT just
  228. returns from the interrupt without attempting to print anything.
  229.      Now this creates a real problem, because on the DOS command level,
  230. COMMAND.COM executes a DOS function call 0Ah for keyboard input, and
  231. this DOS call remains in progress until the user presses the Enter key
  232. at the end of a line.  Many other DOS programs, such as DEBUG or EDLIN,
  233. also use this function call.
  234.      So, PRINT takes advantage of still another undocumented feature of
  235. DOS: Interrupt 28h.  PC-DOS itself continually executes an Interrupt
  236. 28h whenever it is in a wait state (that is, when it is waiting for
  237. keyboard input) during a function call of 01h through 0Ch.
  238.      When an Interrupt 28h is invoked, PRINT knows that a function call
  239. of 01h through 0Ch is in progress.  Because a separate stack is used
  240. for function calls of 0Dh and above, which includes all the file access
  241. calls, PRINT knows that it's safe to retrieve a file if necessary.
  242.      PRINT will always grind to a halt during any disk access.  But
  243. you'll also see it stop during a TYPE command after the disk has been
  244. accessed.  This is because TYPE uses function call 40h to write the
  245. file to the display, and PRINT cannot use DOS during that time.
  246.      Anyone who believes that multitasking is simple to implement in
  247. PC-DOS should dissassemble PRINT.COM and take a look at the backflips
  248. and contortions required for simple background printing from disk
  249. files.  When the rumored PC-DOS 4.0 gives us a true multitasking
  250. operating system (we hope), PRINT will be dramatically outclassed, but
  251. until that time, it's one of the most interesting parts of the
  252. operating system.
  253.      One final note about PRINTSET.BAS: the program uses the segment
  254. address of Interrupt 2Fh to find the location of PRINT in memory.  This
  255. interrupt allows subsequent PRINT runs to transfer filenames to the
  256. initially loaded PRINT.  But SHARE also uses Interrupt 2Fh, so if you
  257. want to use PRINTSET and you also use SHARE, run SHARE before PRINT.
  258. That way PRINTSET won't change bytes in the SHARE program.
  259. - - - - -
  260. 100 'PRINTSET.BAS:  For setting DOS 3.x PRINT parameters
  261. 110 DEFINT A-Z
  262. 120 INPUT "Enter 0 for PC-DOS 3.0, 1 for PC-DOS 3.1: ",V
  263. 130 V=V*11
  264. 140 DEF SEG=0
  265. 150 DEF SEG=PEEK(4*&H2F+2)+256*PEEK(4*&H2F+3)
  266. 170 CLS:PRINT"PRINT.COM Timer Values":PRINT
  267. 180 PRINT "S (Time Slice) = ";PEEK(&H2CF+V)
  268. 190 PRINT "M (Max Tick)   = ";PEEK(&H2D0+V)
  269. 200 PRINT "U (Busy Tick)  = ";PEEK(&h2D1+V)
  270. 210 PRINT
  271. 220 INPUT "Enter S, M, or U, a comma, and the new value:",A$,X
  272. 230 IF (A$="S") OR (A$="s") THEN POKE &H2CF+V,X
  273. 240 IF (A$="M") OR (A$="m") THEN POKE &H2D0+V,X
  274. 250 if (A$="U") OR (A$="u") THEN POKE &H2D1+V,X
  275. 260 GOTO 170
  276.  
  277. -----------------------------------------------------------------
  278.                           A Better Way
  279.         (PC Magazine Vol 4 No 14 July 9, 1985 Power User)
  280.  
  281.      When printing on single-sheet paper in an Epson MX100, the
  282. printer's paper-out switch causes the printer to stop printing before
  283. a document is done.  You can use BASIC to send the printer command
  284. sequence to disable the paper-out switch (CHR$(27)+"8"), but that
  285. requires keeping BASIC on your word processing disk.  A better way
  286. is a 12-byte .COM program created with DEBUG.  Running this program
  287. before printing disables the paper-out switch and offers the luxury
  288. of printing on single sheets.
  289.      Editor's Note:  You can create a companion (PAPERIN.COM) program
  290. that re-enables the paper-out switch when you go back to tractor-feed
  291. paper.  Just replace the "8" on the fourth line of PAPEROUT.COM (38H)
  292. with a "9" (39H).
  293.  
  294. -A
  295. 0B28:0100 MOV DL,1B
  296. 0B28:0102 MOV AH,05
  297. 0B28:0104 INT 21
  298. 0B28:0106 MOV DL,38
  299. 0B28:0108 INT 21
  300. 0B28:010A INT 20
  301. 0B28:010C
  302. -N PAPEROUT.COM
  303. -RCX
  304. CX 0000
  305. :0C
  306. -W
  307. -Q
  308.  
  309. -----------------------------------------------------------------
  310.                       Perforation Problems
  311.        (PC Magazine Vol 4 No 15 July 23, 1985 Power User)
  312.  
  313.      Many programs don't bother to skip over the perforations when
  314. printing on continuous form paper resulting in characters printed half
  315. on one page and half on the next.  You can change the DIP switch
  316. settings on an Epson MX, RX or FX to enable a "skip over perforation"
  317. of about 1/2 inch on either side, but that's time consuming and can
  318. ruin the efforts of programs that are smart enough to skip the page
  319. breaks.
  320.      Use an editor to make a pair of batch files (PGBRKON.BAT and
  321. PGBRKOFF.BAT).  Run PGBRKON before you print yout listing and PGBRKOFF
  322. afterwards.  PGBRKON copies a file name PGBRK.BEG to the printer, which
  323. enables a "skip over perforation," and PGBRKOFF copies a file named
  324. PGBRK.END to the printer, which disables it.  This is PGBRKON.BAT:
  325.           copy pgbrk.beg prn:
  326. And this is PGBRKOFF.BAT:
  327.           copy pgbrk.end prn:
  328.      All you need are the two files and the BASIC program below creates
  329. them for you.  PGBRK.BAS will generate files that tell you Epson to
  330. skip over SKIPLINES% lines.  The lines will be divided evenly between
  331. the current and next pages.  If SKIPLINES% is set to 12, six lines will
  332. be skipped on one page and six on the next.  The only restriction to
  333. correct operation is that SKIPLINES% cannot be less than 0 or greater
  334. than 127.  PGBRK.BAS will work correctly for all IBM printers and all
  335. compatibles.
  336.  
  337. 10 'PGBRK.BAS
  338. 20 SKIPLINES%=12  'SKIPLINES% cannot be less then 0 or greater than 127
  339. 30 OPEN "PGBRK.BEG" FOR OUTPUT AS 1
  340. 40 PRINT #1,USING "\ \";CHR$(27)+"N"+CHR$(SKIPLINES%);
  341. 50 CLOSE 1
  342. 60 OPEN "PGBRK.END" FOR OUTPUT AS 1
  343. 70 PRINT #1,USING "\ \";CHR$(140)+CHR$(27)+"O";
  344. 80 CLOSE 1
  345. 90 END
  346.  
  347. -----------------------------------------------------------------
  348.                    Way to Set Printer Options
  349.       (PC Magazine Vol 4 No 22 October 29, 1985 Power User)
  350.  
  351.      A way to set printer options is to use DOS's ability to redirect
  352. ECHO statements in batch files to the printer.  For example, if your
  353. batch file contains: ECHO string > lpt1, the character string "string"
  354. will be printed on the default printer.  You can send printer command
  355. sequences by specifying them as "string."  All you need is an editor
  356. that lets you enter the Escape character (ASCII 27) and other non-
  357. printing ASCII characters.
  358.      SETPRINT.BAT sets the options for an Okidata Microline printer.
  359. If you don't enter any parameters on SETPRINT's commmand line, a help
  360. screen is presented (see the label :HELP) that tells you which
  361. parameters are valid and what they do.  SETPRINT will send any number
  362. of valid options to your printer.  You just type in the sequences you
  363. want sent.
  364.      Editor's Note:  All characters in SETPRINT.BAT that are to be
  365. directed to the printer are enclosed in braces ({}).  Except for the
  366. Escape character, which is listed as {esc}, nonprinting codes are
  367. shown as a-xxx, where the notation xxx represents the ASCII code, and
  368. "a-" means that you use the Alt key in conjunction with the keypad to
  369. enter the number.  As an alternative to using an editor to generate
  370. the ECHO statements, you might use a short BASIC program that prints
  371. them to a file.  Such a program would contain statements such as:
  372.           PRINT #1, "echo "+chr$(27)
  373. where file number 1 is the open file.
  374.  
  375. SETPRINT.BAT:
  376. echo off
  377. if "%1" == "" goto HELP
  378. echo Setting Printer Options:
  379. goto %1
  380. :HELP
  381. cls
  382. echo The following printer commands are available:
  383. echo .
  384. echo WIDE  - Double Width     COND  - Condensed Mode
  385. echo ULON  - Underline On     ULOFF - Underline Off
  386. echo BOLD  - Double Strike    CORR  - Correspondence Mode
  387. echo DATA  - Data Proc Mode   ELITE - Elite Mode
  388. echo RESET - Resets Printer   PAGE  - Page Feed
  389. echo .
  390. echo Enter: %0 command1 command2 .....commandN
  391. goto END
  392. :WIDE
  393. echo {a-31}  > lpt1
  394. goto SPEAK
  395. :COND
  396. echo {a-29}  > lpt1
  397. goto SPEAK
  398. :ULON
  399. echo {esc}{C}  > lpt1
  400. goto SPEAK
  401. :ULOFF
  402. echo {esc}{D}  > lpt1
  403. goto SPEAK
  404. :BOLD
  405. echo {esc}{T}  > lpt1
  406. goto SPEAK
  407. :DATA
  408. echo {esc}{0}  > lpt1
  409. goto SPEAK
  410. :CORR
  411. echo {esc}{1}  > lpt1
  412. goto SPEAK
  413. :ELITE
  414. echo {a-28}  > lpt1
  415. goto SPEAK
  416. :RESET
  417. echo {a-24}  > lpt1
  418. goto SPEAK
  419. :PAGE
  420. echo {a-12}  > lpt1
  421. :SPEAK
  422. echo . "%1" sent to printer
  423. shift
  424. if not "%1" == "" goto %1
  425. :END
  426.  
  427. -----------------------------------------------------------------
  428. DOS PRINT tip:  DOS 2.0 and later versions contain a utility called
  429. GRAPHICS.COM that augments the original screen dump routine.  Put a
  430. copy of GRAPHICS.COM in drive A: and, at the DOS prompt, type GRAPHICS
  431. and press Enter.  Shift-PrtSc will now dump graphics screens to a
  432. graphics printer.
  433.  
  434. -----------------------------------------------------------------
  435.                Switching Between Parallel Printers
  436.             (PC World November 1985 The Help Screen)
  437.  
  438.      SWAPLPTS.BAS permits switching between two parallel ports, LPT1
  439. and LPT2, to run two printers.
  440.  
  441. 10 DEF SEG=&H40
  442. 20 A=PEEK(8):B=PEEK(9)
  443. 30 POKE 8,PEEK(10):POKE 9,PEEK(11)
  444. 40 POKE 10,A:POKE 11,B
  445. 50 SYSTEM
  446.  
  447. Whenever you want to switch printers, run this program from DOS with
  448. the command:  BASIC SWAPLPTS.
  449.      Each parallel port installed in a PC is configured with a unique
  450. port address value.  When you start the computer it checks its slots
  451. for parallel port addresses and builds a table in a specific portion
  452. of low RAM, listing the port addresses for LPT1, LPT2 and LPT3.  An
  453. application's request to DOS to send output to LPT1, for example,
  454. requires that DOS read the first entry in the parallel port address
  455. table and direct output to that port.
  456.      SWAPLPTS.BAS exchanges the values of the first and second entries
  457. in the port address table, thereby changing the port address used for
  458. LTP1 output.  Thus, output is directed to the other printer.
  459.      Running SWAPLPTS.BAS, of course, requires that BASIC be available.
  460. Using DEBUG.COM, you can easily assemble a .COM file that can be run
  461. directly from DOS:
  462.  
  463. A>DEBUG
  464. -A
  465. xxxx:0100  MOV AX,40
  466. xxxx:0103  MOV DS,AX
  467. xxxx:0105  MOV BX,[8]
  468. xxxx:0109  MOV CX,[A]
  469. xxxx:010D  MOV [8],CX
  470. xxxx:0111  MOV [A],BX
  471. xxxx:0115  INT 20
  472. xxxx:0117
  473. -R CX
  474. CX 0000
  475. :17
  476. -N SWAPLPTS.COM
  477. -W
  478. Writing 17 bytes
  479. -Q
  480.      SWAPLPTS.COM accomplishes the same task as SWAPLPTS.BAS but does
  481. so without BASIC.
  482.  
  483. -----------------------------------------------------------------
  484.                      Printer Check Perfected
  485.                (PC World Star-Dot-Star March 1985)
  486.  
  487.      If a BASIC program attempts to print while the printer is off, the
  488. program will halt and the message "Device Fault" will be displayed.
  489. The PC can support three parallel printer adapters.  When the system
  490. is started, it determines which adapters are present and creates a
  491. list of pointers to indicate the location (base port) of each one
  492. found.  The standard printer device designator, PRN:, is set to use the
  493. printer connected to the first adapter in the list (LPT1:).  The
  494. printer check subroutine should check the adapter indicated by the
  495. first pointer in the list.  The PRTRCHEK.BAS subroutine does that.
  496. You can change the value of PRNTR in line 8000 if you wish to check
  497. the status of one of the other adapters.
  498.  
  499. PRTRCHEK.BAS:
  500. 100 GOSUB 8000:END
  501. 8000 PRNTR=1:DEF SEG=&H40:BASE=(PRNTR*2)+6
  502. 8010 IF PEEK(BASE)=0 THEN PRINT "No printer adapter present.":RETURN
  503. 8020 STAT=INP(PEEK(BASE)+PEEK(BASE+1)*256+1) AND 160
  504. 8030 IF STAT=128 THEN PRINT "Printer ready.":RETURN
  505. 8040 IF STAT=0 THEN PRINT "Printer not ready."
  506. 8050 IF STAT=32 THEN PRINT "Out of paper."
  507. 8060 IF STAT=160 THEN PRINT "Printer not on."
  508. 8070 RETURN
  509.  
  510. -----------------------------------------------------------------
  511.                   Sending Printer Control Codes
  512.         (PC Magazine Vol 4 No 26 Dec 24, 1985 Power User)
  513.  
  514.      It's a simple matter to send printer control sequences while in
  515. DOS itself.  All you have to do is use the COPY command to send
  516. characters, including control codes, to the printer.  Only one real
  517. "trick" needs to be used, and that is for sending the Escape character
  518. and the ASCII character 0.
  519.      All characters, except ASCII 0, can be generated by using the Alt
  520. key combined with the numeric keypad.  Just hold the Alt key down while
  521. typing the desired character's ASCII code on the numeric keypad.
  522. Besides ASCII 0, Escape (ASCII 27) also causes problems because DOS
  523. has special uses for it (it "escapes" the current command line as
  524. entered so far).
  525.      Both difficulties can be solve for Epson (and many other) printers
  526. by using the "high order" versions of these two characters.  Just add
  527. 128 (high-order ASCII 0) to the character code, and peck away at the
  528. numeric keypad.  For example, to set an Epson printer into compressed
  529. mode with subscripts and small (18/216 inch) line heights -- a very
  530. tiny print size handy for small-size directory listings -- use:
  531.  
  532. A>copy con:lpt1:
  533. <alt>155 S <alt>128 <alt>15 <alt>155 3 <alt>018 F6
  534. A>
  535.  
  536. The Alt key combined with 155 (shown as <alt>155) is the same as
  537. Escape (since 128 + 27 = 155), and Alt combined with 128 is the same
  538. as ASCII 0.  Ordinary characters are typed where they can be used
  539. without trouble.  Don't forget to press the F6 key at the end to close
  540. off communications between the console and the printer.
  541.      Now you can simply use the printer in the mode set.  In this case,
  542. pressing Ctrl-P to enable simultaneous printing makes it easy to print
  543. out a directory listing in tiny print.
  544.      Editor's Note:  This works with nearly all Epson-compatible
  545. printers, including IBM's models.  Be careful to check yours for
  546. compatibility, since Escape codes can be more troublesome than they
  547. first appear.
  548.