Subsections
19 The PRINTER unit.
printex
This chapter describes the PRINTER unit for Free Pascal. It was written for
DOS by Florian Klämpfl, and it was written for LINUX by Michaël Van
Canneyt, and has been ported to WINDOWS and OS/2 as well.
Its basic functionality is the same for al supported systems, although there
are minor differences on LINUX.
The chapter is divided in 2 sections:
- The first section lists types, constants and variables from the
interface part of the unit.
- The second section describes the functions defined in the unit.
var
lst : text;
Lst is the standard printing device.
On LINUX,
Lst is set up using AssignLst('/tmp/PID.lst').
You can change this behaviour at compile time, setting the DefFile constant.
1 AssignLst
-
Declaration
- Procedure AssignLst ( Var F : text; ToFile : string[255]);
-
Description
LINUX only.
Assigns to F a printing device. ToFile is a string with the following form:
- '|filename options' : This sets up a pipe with the program filename,
with the given options, such as in the popen() call.
- 'filename' : Prints to file filename. Filename can contain the string 'PID'
(No Quotes), which will be replaced by the PID of your program.
When closing lst, the file will be sent to lpr and deleted.
(lpr should be in PATH)
- 'filename|' Idem as previous, only the file is NOT sent to lpr, nor is it
deleted.
(useful for opening /dev/printer or for later printing)
-
Errors
- Errors are reported in Linuxerror.
-
See also
- lpr (1)
-
Example
program testprn;
uses printer;
var i : integer;
f : text;
begin
writeln ('Test of printer unit');
writeln ('Writing to lst...');
for i:=1 to 80 do writeln (lst,'This is line ',i,'.'#13);
close (lst);
writeln ('Done.');
{$ifdef Unix}
writeln ('Writing to pipe...');
assignlst (f,'|/usr/bin/lpr -m');
rewrite (f);
for i:=1 to 80 do writeln (f,'This is line ',i,'.'#13);
close (f);
writeln ('Done.')
{$endif}
end.
2004-02-13