[SOLVED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set? lazarus / 11-Options ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 14:54 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. ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 14:58 Sorry, forgot to say: Lazarus 2.2.2 (rev lazarus_2_2_2-0-g537f43754c) FPC 3.2.2 x86_64-win64-win32/win64 ---------------------------------------------------------------------- Thaddy · 2022-11-24 15:17 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$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. ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 15:24 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. Quote from: Thaddy on November 24, 2022, 04:17:51 pmWhen you encounter a console application example by me and others that often reads like this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifdef mswindows}{$define apptype console}{$endif}it should be like this to work Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifdef mswindows}{$apptype console}{$endif} ---------------------------------------------------------------------- Thaddy · 2022-11-24 16:14 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) ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 16:34 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. ---------------------------------------------------------------------- itblumi · 2022-11-24 16:42 Do you mean something like this https://wiki.freepascal.org/Project_Templates ? ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 20:03 Quote from: itblumi on November 24, 2022, 05:42:56 pmDo 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. ---------------------------------------------------------------------- PascalDragon · 2022-11-24 21:05 Quote from: KodeZwerg on November 24, 2022, 05:34:57 pmNow my question is, where does Lazarus take the template from when I do press the [OK] button? $lazarusdir/ide/projectdescriptortypes.pas Quote from: KodeZwerg on November 24, 2022, 09:03:51 pmQuote from: itblumi on November 24, 2022, 05:42:56 pmDo 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 · 2022-11-24 21:23 Quote from: PascalDragon on November 24, 2022, 10:05:07 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? ---------------------------------------------------------------------- Bart · 2022-11-24 21:23 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 · 2022-11-24 21:24 Quote from: KodeZwerg on November 24, 2022, 10:23:29 pmI 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 · 2022-11-24 21:30 Quote from: Bart on November 24, 2022, 10:24:15 pmQuote from: KodeZwerg on November 24, 2022, 10:23:29 pmI 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! ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 21:36 Nevermind, Tools -> Rebuild IDE ---------------------------------------------------------------------- KodeZwerg · 2022-11-24 22:27 Quote from: Bart on November 24, 2022, 10:23:34 pmMaybe 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  ) 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! ---------------------------------------------------------------------- KodeZwerg · 2022-12-17 13:00 Quote from: PascalDragon on November 24, 2022, 10:05:07 pmQuote from: KodeZwerg on November 24, 2022, 05:34:57 pmNow my question is, where does Lazarus take the template from when I do press the [OK] button? $lazarusdir/ide/projectdescriptortypes.pas Quote from: KodeZwerg on November 24, 2022, 09:03:51 pmQuote from: itblumi on November 24, 2022, 05:42:56 pmDo 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. Thanks again for your help, everything works like I wanted it to be. Can you please help me again, this time I searched for the template that is generated when I click on "Application" (a LCL template) I wanted to insert one line in the class template where it generate "private" and "public" line. The .lpr file is in file that you mentioned but I do not find where it takes the .pas file for "unit1.pas" template. ---------------------------------------------------------------------- KodeZwerg · 2023-01-18 22:50 Shy pushing this up again in hope to get an answer of my last post, if I was unclear just tell and I describe it further ---------------------------------------------------------------------- PascalDragon · 2023-01-19 20:42 You simply need to follow the necessary functions (I have just done that right now). In the end you'll land in TFileDescPascalUnitWithResource.GetInterfaceSource in unit $lazdir/components/buildintf/projectintf.pas. Please note however that this code is used for all templates involving a form. ---------------------------------------------------------------------- KodeZwerg · 2023-01-19 21:29 Quote from: PascalDragon on January 19, 2023, 09:42:22 pmYou simply need to follow the necessary functions (I have just done that right now). In the end you'll land in TFileDescPascalUnitWithResource.GetInterfaceSource in unit $lazdir/components/buildintf/projectintf.pas. Please note however that this code is used for all templates involving a form. Now I found it, yes I was too stupid to follow or find out how or where it take the source generation from. I am mega happy!    I appreciate your help!!