next up previous contents index search.gif
Next: 13. The SOCKETS unit. Up: Unit reference for Free Previous: 11. The Objects unit.

Subsections


12. The PRINTER unit.

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. Its basic functionality is the same for both systems. The chapter is divided in 2 sections:

12.1 Types, Constants and variables :


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.

12.2 Procedures and functions


12.2.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:

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 linux}
  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.


root
1999-06-10