Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-04

(no subject)

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bihar Anwar

I have the following part of a unit code which can be compiled successfully under a normal GUI application.

  {$IFNDEF NOFORMSPLEASE}
  if soProcessMessages in oSearchOptions then
    Application.ProcessMessages;
  {$ENDIF}

My question is, how can I use this unit from my console application? I know that a console application won't receive that kind of notification, but since this is a unit for searching folders/files, I want to use it too in my console application.

Any help appreciated. Thanks.

Reply by email

Bart
to Bihar Anwar

Simply define the compiler directive NOFORMSPLEASE when compiling your console app.
The ProcessMessages is there (I guess) for allowing the Application object to update screens (WinControls).

Since a console application does not link in LCL this is not necessary.

Bart

Reply by email

Bihar Anwar
to Bart

Thanks Bart, I will try it.

Earlier message 14 lines
----- Original Message ---- From: Bart To: FPC-Pascal users discussions Sent: Sun, April 11, 2010 4:51:54 PM Subject: Re: [fpc-pascal] (no subject) Simply define the compiler directive NOFORMSPLEASE when compiling your console app. The ProcessMessages is there (I guess) for allowing the Application object to update screens (WinControls). Since a console application does not link in LCL this is not necessary. Bart

Reply by email

Bihar Anwar
to Bart: Simply define the compiler directive NOFORMSPLEASE when compiling your console app. The…

Yes it works, but the {$DEFINE NOFORMSPLEASE} clause must be put in the unit itself. If I put the clause in the first line of my console project, the unit won't catch it.

How can I define a compiler directive that can be understood by all units in my project?

Anyway, thanks.

Earlier message 14 lines
----- Original Message ---- From: Bart To: FPC-Pascal users discussions Sent: Sun, April 11, 2010 4:51:54 PM Subject: Re: [fpc-pascal] (no subject) Simply define the compiler directive NOFORMSPLEASE when compiling your console app. The ProcessMessages is there (I guess) for allowing the Application object to update screens (WinControls). Since a console application does not link in LCL this is not necessary. Bart

Reply by email

Bart
to Bihar Anwar
Bihar Anwar wrote
Yes it works, but the {$DEFINE NOFORMSPLEASE} clause must be put in the unit itself. If I put the clause in the first line of my console project, the unit won't catch it. How can I define a compiler directive that can be understood by all units in my project?

Commandline:
fpc -dNOFORMSPLEASE myprogram.pp

Not sure if this can be done from within FP IDE or Lazarus though.

Bart

Reply by email

Graeme Geldenhuys
to Bart
Bart wrote 5 lines
Commandline: fpc -dNOFORMSPLEASE myprogram.pp Not sure if this can be done from within FP IDE or Lazarus though.

Yes they do...

FP IDE:
Option > Compiler > Conditional Defines

Lazarus IDE:
Project > Project Options > Compiler Options > Other > Custom options
- add a new line: -d<your_define_here>

MSEide:
Project > Options > Make > Make Options
- add a new line: -d<your_define_here>

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Tomas Hajny
to Graeme Geldenhuys
Graeme Geldenhuys wrote 19 lines
On 12 April 2010 13:25, Bart wrote: > > Commandline: > fpc -dNOFORMSPLEASE myprogram.pp > > Not sure if this can be done from within FP IDE or Lazarus though. Yes they do... FP IDE: Option > Compiler > Conditional Defines Lazarus IDE: Project > Project Options > Compiler Options > Other > Custom options - add a new line: -d<your_define_here> MSEide: Project > Options > Make > Make Options - add a new line: -d<your_define_here>

These are obviously all valid. There's also another possibility though (having advantages and disadvantages compared to this) - you could have an include file specifying this define and reference this include file from all (relevant) source files. The advantage is that this works independently from the chosen compilation method (fpc from command line, makefile, all IDEs, etc.). The disadvantage is obviously that if you need to make sure that you don't forget the include file reference in any of your (relevant) files.

Tomas

Reply by email

Graeme Geldenhuys
to Tomas Hajny
Tomas Hajny wrote 5 lines
These are obviously all valid. There's also another possibility though (having advantages and disadvantages compared to this) - you could have an include file specifying this define and reference this include file from all (relevant) source files.

100% correct Tomas, and a very handy actually use this method in our company projects. Only downside - don't forget to specify the include file in each and every unit of your project.

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Bihar Anwar
to Graeme Geldenhuys

Thanks very much Bart, Thomas, and Graeme, they're precious information. I even didn't notice about the built-in feature within FPC and Lazarus IDE.

Thanks again.

Earlier message 27 lines
----- Original Message ---- From: Graeme Geldenhuys To: FPC-Pascal users discussions Sent: Mon, April 12, 2010 8:09:42 PM Subject: Re: [fpc-pascal] (no subject) On 12 April 2010 14:27, Tomas Hajny wrote: > > These are obviously all valid. There's also another possibility though > (having advantages and disadvantages compared to this) - you could have an > include file specifying this define and reference this include file from > all (relevant) source files. 100% correct Tomas, and a very handy actually use this method in our company projects. Only downside - don't forget to specify the include file in each and every unit of your project. -- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email