Recent

Author Topic: Identifier not found "AssignPrn(POutput)" [SOLVED]  (Read 3903 times)

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 328
  • Love my Wife, My Kids and Lazarus/Freepascal.
Identifier not found "AssignPrn(POutput)" [SOLVED]
« on: February 17, 2017, 11:02:42 pm »
Hi. Want to print all lines in a memo but, I tried with Uses Printer,Printers but nothing works!  :(
I have got this errormessage from Lazarus!

Identifier not found "AssignPrn(POutput)"

Can anyone see what's wrong?

Uses ?

var
  POutput : TextFile;
  I       : LongInt;
begin
  if PrintDialog1.Execute then begin     // if Print Dialog OK
    AssignPrn(POutput);                 // assign printer
    ReWrite(POutput);                   // open printer
    Printer.Canvas.Font := Memo1.Font;   // assign current font
    for I := 0 to Memo1.Lines.Count - 1 do begin  // loop
      WriteLn(POutput,Memo1.Lines);   // print one line
    end;
    CloseFile(POutput);                 // close printer
  end
end; // mfPrintClick




Thanks in advance
« Last Edit: February 17, 2017, 11:48:41 pm by Bob the Swede »
Rob

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Identifier not found "AssignPrn(POutput)" ???
« Reply #1 on: February 17, 2017, 11:26:34 pm »
Unless you know the language your printer talks (i really doubt it for this day and age), you are using the wrong (low tech directly communicating to your printer) functions.
Please have a look at this wiki page and the examples listed. See if that is able to help you further.

J-G

  • Hero Member
  • *****
  • Posts: 953
Re: Identifier not found "AssignPrn(POutput)" ???
« Reply #2 on: February 17, 2017, 11:29:56 pm »
Can't give you chapter & verse about what's wrong but I can suggest the you do a search on Printer4Lazarus.

With that installed and a uses declaration of 'Printers' I found printing a breeze with this structure:

Code: Pascal  [Select][+][-]
  1. begin
  2.   with Printer do
  3.    try
  4.      BeginDoc;
  5.  
  6. // create data to print
  7.  
  8.    finally
  9.      EndDoc;
  10.    end;
  11. end;
  12.  

I see Molly has given you a link to Printer4Lazarus - that will certainly put you on the right path.
FPC 3.0.0 - Lazarus 1.6 &
FPC 3.2.2  - Lazarus 2.2.0 
Win 7 Ult 64

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 328
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Identifier not found "AssignPrn(POutput)" ???
« Reply #3 on: February 17, 2017, 11:48:20 pm »
Thanks. :)
Rob

 

TinyPortal © 2005-2018