Recent

Author Topic: Console In/Output Window Missing on Windows  (Read 1208 times)

nikel

  • Full Member
  • ***
  • Posts: 186
Console In/Output Window Missing on Windows
« on: January 21, 2023, 08:17:27 pm »
Hello, I've got a program I built on Linux. Now I switched to Windows but Console In/Output window is missing. How can I handle errors?

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Console In/Output Window Missing on Windows
« Reply #1 on: January 21, 2023, 08:45:23 pm »
You are not supposed to have errors. ;D

Don't worry, you will get a nice dialog box in front of you.
The only true wisdom is knowing you know nothing

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Console In/Output Window Missing on Windows
« Reply #2 on: January 21, 2023, 10:07:20 pm »
"Project Options" under "Config and Target" uncheck "Win32 GUI app"

Then you project compiles as console app, and when you launch it a console will be opened.

nikel

  • Full Member
  • ***
  • Posts: 186
Re: Console In/Output Window Missing on Windows
« Reply #3 on: January 22, 2023, 09:56:33 pm »
Thanks for the replies. Win32 gui app is already unchecked.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Console In/Output Window Missing on Windows
« Reply #4 on: January 23, 2023, 04:24:22 am »
Thanks for the replies. Win32 gui app is already unchecked.
But do you have
Code: Pascal  [Select][+][-]
  1. {$apptype gui}
in your .lpr?

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Console In/Output Window Missing on Windows
« Reply #5 on: January 23, 2023, 04:39:43 am »
"Project Options" under "Config and Target" uncheck "Win32 GUI app"

Then you project compiles as console app, and when you launch it a console will be opened.
That will not happen until he put "{$APPTYPE CONSOLE}" (without quotes) in his .lpr file.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Console In/Output Window Missing on Windows
« Reply #6 on: January 23, 2023, 04:43:48 am »
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. {$IFDEF MSWINDOWS}{$APPTYPE CONSOLE}{$ENDIF}
  3.  
  4. begin
  5.   WriteLn('Hello World.');
  6.   ReadLn;
  7. end.
Most basic "Hello World." example, crosscompile compatible.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Console In/Output Window Missing on Windows
« Reply #7 on: January 23, 2023, 04:48:47 am »
How can I handle errors?
Code: Pascal  [Select][+][-]
  1. try
  2.   // do something
  3. except
  4.   // handle error
  5. end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

tetrastes

  • Sr. Member
  • ****
  • Posts: 473
Re: Console In/Output Window Missing on Windows
« Reply #8 on: January 23, 2023, 11:49:03 am »
"Project Options" under "Config and Target" uncheck "Win32 GUI app"

Then you project compiles as console app, and when you launch it a console will be opened.
That will not happen until he put "{$APPTYPE CONSOLE}" (without quotes) in his .lpr file.
I don't have {$APPTYPE CONSOLE} in any of my console programs, and console is opened for them without any problem.

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Console In/Output Window Missing on Windows
« Reply #9 on: January 23, 2023, 12:13:36 pm »
I don't have {$APPTYPE CONSOLE} in any of my console programs
The issue is not about console programs, but gui programs.
If you want console output in a Windows GUI program, the easiest way to do that is simple add {$APPTYPE CONSOLE} instead of {$APPTYPE GUI}. It is subsequently possible to hide the console if not necessary.
The reason is, is that a GUI app on Windows does not create handles for stdin, stdout and stderr by default, while adding {$APPTYPE CONSOLE} dooes just that. It has no impact on your GUI app otherwise.

The other way is to create a console in code. NOT recommended.

All this is Windows only! On other platforms this is not necessary.
Specialize a type, not a var.

tetrastes

  • Sr. Member
  • ****
  • Posts: 473
Re: Console In/Output Window Missing on Windows
« Reply #10 on: January 23, 2023, 12:53:15 pm »
I don't have {$APPTYPE CONSOLE} in any of my console programs
The issue is not about console programs, but gui programs.
If you want console output in a Windows GUI program, the easiest way to do that is simple add {$APPTYPE CONSOLE} instead of {$APPTYPE GUI}. It is subsequently possible to hide the console if not necessary.

The same result is achieved by
"Project Options" under "Config and Target" uncheck "Win32 GUI app"

Then you project compiles as console app, and when you launch it a console will be opened.

What is the easiest way, this is a matter of taste. And after that program becomes console, not GUI. Windows defines it as "Subsystem: Console".

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Console In/Output Window Missing on Windows
« Reply #11 on: January 23, 2023, 10:40:43 pm »
"Project Options" under "Config and Target" uncheck "Win32 GUI app"

Then you project compiles as console app, and when you launch it a console will be opened.
That will not happen until he put "{$APPTYPE CONSOLE}" (without quotes) in his .lpr file.

If Win32 GUI application isn't checked in Lazarus and the main program file does not contain a {$AppType GUI} then FPC's default will win out which is Console.

nikel

  • Full Member
  • ***
  • Posts: 186
Re: Console In/Output Window Missing on Windows
« Reply #12 on: January 29, 2023, 10:36:56 pm »
Thanks for the replies. I'm going to try that.

 

TinyPortal © 2005-2018