I'm learning Pascal in Lazarus. Could someone help me with printing, please. How do you send output to a printer? Do you have an example you could post that I could run and learn from?
I can't get this to work:
program Project2;
{$MODE Delphi}
// Exercise 10.03
{$APPTYPE CONSOLE} // written by Sylvia Langfield
uses
SysUtils, Printers, Graphics;
var PrintFile: TextFile;
Message: String;
procedure SetPrintStyles
(Font: String; Size: Integer; Style: TFontStyles);
begin
Printer.Canvas.Font.Name := Font;
Printer.Canvas.Font.Size := Size;
Printer.Canvas.Font.Style := Style;
end;
begin
Write ('Enter a message to print: ');
Readln (Message);
AssignPrn (PrintFile);
Rewrite (PrintFile);
SetPrintStyles('Times New Roman',14,[fsBold, fsItalic]);
Writeln (PrintFile, Message);
SetPrintStyles('Arial',20,[fsBold, fsUnderline]);
Writeln (PrintFile, Message);
SetPrintStyles('Times New Roman',14,[]);
Writeln (PrintFile, Message);
CloseFile (PrintFile);
Readln
end.
I get this when tryimng to run it:
Project2.lpr(26,13) Error: Identifier not found "AssignPrn"
Project2.lpr(27,21) Hint: Variable "PrintFile" does not seem to be initialized
Project2.lpr(37) Fatal: There were 1 errors compiling module, stopping
Any ideas, please?