Recent

Author Topic: [SOLVED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?  (Read 4742 times)

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
[SOLVED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« on: November 24, 2022, 03:54:47 pm »
Hello community,

I do code on/for Windows Operating System using Lazarus/FPC/WidgetSet for Windows.

Where can I enable that Lazarus does apply {$APPTYPE CONSOLE} or {$APPTYPE GUI} to the .lpr file please?
Whenever I do say "Create a new project" I would want to have that in my .lpr file added.
Are there templates I can edit?
Please help a beginner.
« Last Edit: November 24, 2022, 11:27:39 pm by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #1 on: November 24, 2022, 03:58:57 pm »
Sorry, forgot to say: Lazarus 2.2.2 (rev lazarus_2_2_2-0-g537f43754c) FPC 3.2.2 x86_64-win64-win32/win64
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #2 on: November 24, 2022, 04:17:51 pm »
You should do that in the lpr file - on the top - or in the Lazarus IDE indeed.
When you encounter a console application example by me and others that often reads like this:
Code: Pascal  [Select][+][-]
  1. {$ifdef mswindows}{$define apptype console}{$endif}
This is only necessary for the Windows platform.
What happens is that it links in support to read and write to/from the console, so error 103 will not be triggered.
OTOH you can also define {$apptype gui} which means that the console support code is skipped.
On many supported OS's this is not an issue, but for windows it is.
« Last Edit: November 24, 2022, 04:24:21 pm by Thaddy »
Specialize a type, not a var.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #3 on: November 24, 2022, 04:24:29 pm »
Thanks for your reply.
My question still is, where can I enable an option that Lazarus add this automatic for me without need to check/edit the .lpr afterwards.
Or where does Lazarus take the clean/empty template from so I add those line within to never need to think about it anymore please.

When you encounter a console application example by me and others that often reads like this:
Code: Pascal  [Select][+][-]
  1. {$ifdef mswindows}{$define apptype console}{$endif}
it should be like this to work
Code: Pascal  [Select][+][-]
  1. {$ifdef mswindows}{$apptype console}{$endif}
« Last Edit: November 25, 2022, 01:01:09 am by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #4 on: November 24, 2022, 05:14:10 pm »
file | new | simple program
but there are at least two more options I am aware of. (but note I do not use Lazarus very much, since my code is centered around networks and do not need a GUI, except for control)
Specialize a type, not a var.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #5 on: November 24, 2022, 05:34:57 pm »
Maybe I express myself not that clear enough.

In attachment you do see a picture.

Now my question is, where does Lazarus take the template from when I do press the [OK] button?

Your text about what it does = I do know.
Your text about where it belong to = I do know.
A text about how I can have it automatic = I do miss.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

itblumi

  • New Member
  • *
  • Posts: 29
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #6 on: November 24, 2022, 05:42:56 pm »
Do you mean something like this https://wiki.freepascal.org/Project_Templates ?
Jan

Delphi XE6, Lazarus 2.2.4, Visual Studio, Eclipse
Platforms: Ubuntu 22.10, Windows 7, 10
Progarmming languages: Pascal, C, C++, C#, Java

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #7 on: November 24, 2022, 09:03:51 pm »
Do you mean something like this https://wiki.freepascal.org/Project_Templates ?
I give up. Even when I show a picture of where I would like to modify something I get answers that not lead in the direction that I need.
I read your link and I do understand like nothing since I never have done such, really, all I want to do is to edit the original thing that I showed on Picture, nothing more nothing less.
I closed now this thread since I can not express myself more clearly.
Thanks.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #8 on: November 24, 2022, 10:05:07 pm »
Now my question is, where does Lazarus take the template from when I do press the [OK] button?

$lazarusdir/ide/projectdescriptortypes.pas

Do you mean something like this https://wiki.freepascal.org/Project_Templates ?
I give up. Even when I show a picture of where I would like to modify something I get answers that not lead in the direction that I need.

The projtemplates package is to add your own templates using simple description files. Some other packages also add additional project templates using code like the core templates do.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #9 on: November 24, 2022, 10:23:29 pm »
$lazarusdir/ide/projectdescriptortypes.pas
Perfect!
I found that file, it was exact what I wanted to "patch".
How do I make it now that Lazarus is using it please?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: [CLOSED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #10 on: November 24, 2022, 10:23:34 pm »
Maybe you can file a feature request in the bugtracker to add {$apptype console} to TProjectSimpleProgramDescriptor.InitProject and TProjectProgramDescriptor.InitProject in $lazarusdir/ide/projectdescriptortypes.pas.

Or maybe (if possible) disable -WG switch there.

I agree with you that is is annoying that by default a console project on Windows is compiled with -WG

Bart

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #11 on: November 24, 2022, 10:24:15 pm »
I found that file, it was exact what I wanted to "patch".
How do I make it now that Lazarus is using it please?

Rebuild the IDE?

Bart

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #12 on: November 24, 2022, 10:30:10 pm »
I found that file, it was exact what I wanted to "patch".
How do I make it now that Lazarus is using it please?

Rebuild the IDE?

Bart
How?
Thanks in advance!
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: [CLOSED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #13 on: November 24, 2022, 10:36:07 pm »
Nevermind, Tools -> Rebuild IDE  :-[
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: [CLOSED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?
« Reply #14 on: November 24, 2022, 11:27:07 pm »
Maybe you can file a feature request in the bugtracker...
I tried my best up to the point where I finally gave up. ( Watch image, thats how it ended for me  >:D )
Anyway, in attachment is my patched version that does do what I tried to achieve.
Thank you PascalDragon for leading me where I wanted to go!
Thank you Bart for tell what I needed to do after that!
Thank you Thaddy and itblumi for trying to help!
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

 

TinyPortal © 2005-2018