In Textmode the ^Z #$1A is treated as End Of File. This historic "feature" must be switched off for random character printing. This is very similar to the /b switch in the COMMAND.COM - COPY command.
Btw.: You should also consider the MODE command for printer redirection, where applicable!
Note: The acronym LST is the abbreviation of LiST device. LPT means
LinePrinTer, and PRN is simply PRiNter. These come from the very early
CP/M times, when the serial ports were named RDR: and PUN: for tape reader
and punch, later named AUX: for auxiliary terminals. The teletype was connected
to the TTY: port (the operators CON:sole, outputting on paper) and later
the terminal with its CathodeRayTube CRT was the CON:sole. Note the colon,
it was the symbol for devices, now (in MSDOS...) only used for disks, with
some lack of logic.
Bitfields for printer status:
Bit(s) Description
7
not busy 80H
6
acknowledge 40H
5
out of paper 20H
4
selected 10H
3
I/O error 8H
2-1 unused
0
timeout 1H
More about Printing
Dr. John Stockton's Printing article: http://www.merlyn.demon.co.uk/pas-norm.htm#Print |
12345678 | {
This Unit is a replacement for the Printer unit that }
{ came with Turbo Pascal Version 4.0 and 5.0. Its purpose is } { fourfold. } { } { First: It will allow a user to change the printer port that } { the LST file is writing to on the fly. This takes the } { place of LstOutPtr and the routine on page 369 of the Turbo } { Pascal Version 3.0 manual. } { } { Second: This unit will free the programmer from the need to } { check to see if the printer is ready to accept characters. } { If the printer is not ready, the unit will place a line on } { the screen prompting the user to fix the printer and press } { a key. This process will continue until the printer is } { made ready or the user Aborts or Ignores the printing } { operation. NOTE: BIOS does not return correct error codes } { for Non-Existent printers or printer ports because the } { printer is not there to return any error codes at all. } { } { Third: This unit will also circumvent DOS's stripping of a } { Ctrl-Z ($1A, the End Of File character) when writing to the } { printer as an ASCII device. Ctrl-Z was usually sent as part } { of a graphics string to a printer. In version 3.0 of Turbo } { Pascal, an ASCII device was opened in binary mode. In } { version 4.0, an ASCII device is opened in ASCII mode and } { DOS thus strips a Ctrl-Z. } { } { Fourth: This also provides a good example of a Text file } { device driver. } { Warning: This Driver has not been tested on a non-buffered } { printer, as the smallest buffer I could find was 80 chars. } { Type this to a file called PRINTIT4.PAS
}
{ Written by the Lizard King, Clifford Roche email fluffy200@hotmail.com} {$R-}
Unit Print_it_4; Interface Uses DOS,CRT;
Procedure SetPrinter( Port:Byte );
Implementation Function PrinterCheck( PortNum, Error:Byte; Var Pos:Word):Boolean;
Function PrinterReady(PortNum:Byte):Boolean;
{ The following routines MUST be FAR
calls because they }
{$F+}
{ LSTNoFunction performs a NUL operation
for a Reset or }
Function LSTNoFunction( Var F: TextRec ): integer;
{ LSTOutputToPrinter sends the output
to the Printer }
Function LSTOutputToPrinter( Var F: TextRec ): integer;
{$F-}
{ AssignLST both sets up the LST text
file record as }
Procedure AssignLST( Port:Byte );
function VerifyPortL (LPT: Word): Byte;
Procedure SetPrinter( Port:Byte ); { Documented above
}
Begin { Initialization }
This file is available in textmode for download with the right mouse button.printit4pas.txt |
Glaser |
Subject: Re: HELP WITH PRINTING!!!
Date: Sat, 11 Jul 1998 11:28:35 GMT From: horst.kraemer@snafu.de (Horst Kraemer) Organization:Unlimited Surprise Systems, Berlin Newsgroups: comp.lang.pascal.borland On Sat, 11 Jul 1998 09:26:58 +0100, Jim Barr
>>:>And do not forget that if you are reading from a file and printing
to
Clearly, what you said, cannot be true. You are reading data from a file (read(f,blah)) and sending them
If you _did_ read data from the file the data are in your variable
Things are dramatically different if you _write_ something _to_
a TEXT
var f:TEXT;
After executing this program you will have and empty file 'bla'
(0
a) the buffer is full
In the above case the buffer is not full, i.e. the data in the buffer
The action of flush(f) is : commit the buffer data to DOS.
There are very few situations why you would ever use flush(f) in
a TP
You are keeping a log file which you rewrite/append at program startup
In this case it is advisable to flush it after every writeln. writeln(log,message);flush(log); to be sure that everything what was "written" by the program up
to the
There is a trick to avoid the necessity of flush(log). _After_
with textrec(f) do FlushFunc:=InOutFunc; Now every write(f,..)-command will automatically execute an implicit
Regards
|
Franz Glaser
http://geo.meg-glaser.at/tp.html
http://members.eunet.at/meg-glaser