Recent

Author Topic: Problem with Printing Unit  (Read 435 times)

Neville

  • New Member
  • *
  • Posts: 37
Problem with Printing Unit
« on: January 28, 2023, 06:10:03 pm »
I have a unit (MISPREV) which provides preview and printing.
  Its USES clause is shown below.

uses
  Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, Buttons, ComCtrls, Printers, PrintersDlgs;   
 
 
The LPR file contains the following USES clause

uses
            {$IFDEF UNIX}{$IFDEF UseCThreads}
            cthreads,
            {$ENDIF}{$ENDIF}
            Interfaces, // this includes the LCL widgetset
            Forms, DPUnit, MISPrev, printer4lazarus
            { you can add units after this };

Every time I try to use the MISPREV unit in a new project,
despite reproducing the uses clauses exactly,
I am given the following error.

Fatal Unit PrintersDlgs searched but Printers found

I can't seem to unravel what is going wrong.

Can anyone help?



 
 

jamie

  • Hero Member
  • *****
  • Posts: 5203
Re: Problem with Printing Unit
« Reply #1 on: January 28, 2023, 06:33:52 pm »
maybe because PRINTERS should be PRINTER?

I know the compiler generates strange messages about unit names not found like you have encounted.
 
 They seem to be related to the length of a name if there is another that has the same length at the start. it's strange for sure, like names with 8 letters.

The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 10676
Re: Problem with Printing Unit
« Reply #2 on: January 28, 2023, 06:54:06 pm »
Just some ideas:

The LPR file contains the following USES clause

uses
            {$IFDEF UNIX}{$IFDEF UseCThreads}
            cthreads,
            {$ENDIF}{$ENDIF}
            Interfaces, // this includes the LCL widgetset
            Forms, DPUnit, MISPrev, printer4lazarus
            { you can add units after this };
Are you calling functions of MISPrev in the project file? Or do you need the printer there? I guess: no - remove these units from the LPR file, keep only the units which are needed directly.

But I think this is not your problem...

Every time I try to use the MISPREV unit in a new project
How do you "use the MISPREV unit in a new project"? Is it in a package? Then you must add the package to the requirements. Or do you just copy the MISPREV unit to the new project? Then you should add the package Printer4Lazarus to the requirements of the project, otherwise it is not clear whether the Printers unit will be found.

Another idea: Sometimes you also must add the unit OSPrinters to the uses clause of the unit in which you access the printer. Otherwise the application will crash when you access the Printer variable.

Neville

  • New Member
  • *
  • Posts: 37
Re: Problem with Printing Unit
« Reply #3 on: January 30, 2023, 04:08:31 pm »
MISPrev.pas is a unit held in a library folder, as many other homespun library units.

I think that I may have solved the problem, rather deviously.  I have done a "SaveAs" on a working program using the MISPrev, and cleared out all the specific stuff in the main unit.  I'm expecting that I can create a new project by doing a SaveAs on this ghost project, and get going from there.  It's a but sneaky, and I still don't really know what the issue is, but if I can continue to develop using MISPrev, I'm happy.

 

TinyPortal © 2005-2018