Sign in Join

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

Mailing lists / fpc-pascal / 2016-09

Windows console

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Santiago A.

Hello:

I have a little watchdog utility for windows that runs each five minutes, like a unix cron ("Tareas programadas" in Spanish, scheduled tasks?). It opened a console window for a second and that was very annoying. So I used the switch -GW and there is no more flashing console bothering. But then I can't show any help or any output for debug from the prompt.

I can live with it, in fact, it usually uses a log file, but some times, when I'm installing, testing paramters etc, it's more handy to run the program from the prompt and see the result immediately or display the help instead of having to open logs.

Is there any way to open a console on the fly and send the output to the console?

FPC 3.0.0 for Windows 7 and Windows XP

Santiago A.

Reply by email

José Mejuto
to Santiago A.
Santiago A. wrote 16 lines
Hello: I have a little watchdog utility for windows that runs each five minutes, like a unix cron ("Tareas programadas" in Spanish, scheduled tasks?). It opened a console window for a second and that was very annoying. So I used the switch -GW and there is no more flashing console bothering. But then I can't show any help or any output for debug from the prompt. I can live with it, in fact, it usually uses a log file, but some times, when I'm installing, testing paramters etc, it's more handy to run the program from the prompt and see the result immediately or display the help instead of having to open logs. Is there any way to open a console on the fly and send the output to the console?

Hello,

I would create a .bat file in temp folder and run a new shell execute of that .bat. This .bat simply display some echo lines and finally autokill itself.

If your system for security reasons do not allow run bats then you can create a .txt file and launch a shell execute cmd with "type \path\file.txt" (keeping session open or it will clear the screen). You main program can wait 2-5 seconds and delete the .txt file to not pollute the temp folder.

Of course this is a "home made" solution :) Another is have a different exe just for the help, have a .bat or .txt in your app folder just to show the help if it is always the same, ...

Reply by email

Santiago A.
to José Mejuto
José Mejuto wrote 33 lines
El 05/09/2016 a las 15:01, Santiago A. escribió: > Hello: > > I have a little watchdog utility for windows that runs each five > minutes, like a unix cron ("Tareas programadas" in Spanish, scheduled > tasks?). It opened a console window for a second and that was very > annoying. So I used the switch -GW and there is no more flashing console > bothering. But then I can't show any help or any output for debug from > the prompt. > > I can live with it, in fact, it usually uses a log file, but some times, > when I'm installing, testing paramters etc, it's more handy to run the > program from the prompt and see the result immediately or display the > help instead of having to open logs. > > Is there any way to open a console on the fly and send the output to the > console? Hello, I would create a .bat file in temp folder and run a new shell execute of that .bat. This .bat simply display some echo lines and finally autokill itself. If your system for security reasons do not allow run bats then you can create a .txt file and launch a shell execute cmd with "type \path\file.txt" (keeping session open or it will clear the screen). You main program can wait 2-5 seconds and delete the .txt file to not pollute the temp folder. Of course this is a "home made" solution :) Another is have a different exe just for the help, have a .bat or .txt in your app folder just to show the help if it is always the same, ...

I have found a solution here:

http://stackoverflow.com/questions/20134421/can-a-windows-gui-program-written-in-lazarus-create-a-console-and-write-to-it-at

At least it works for windows

uses
  Windows;
begin
  AllocConsole;      // in Windows unit
  IsConsole := True; // in System unit
  SysInitStdIO;      // in System unit
  // Now you can do Writeln, DebugLn, ...
end.

Reply by email

Marcos Douglas
to Santiago A.
Santiago A. wrote 14 lines
I have found a solution here: http://stackoverflow.com/questions/20134421/can-a-windows-gui-program-written-in-lazarus-create-a-console-and-write-to-it-at At least it works for windows uses Windows; begin AllocConsole; // in Windows unit IsConsole := True; // in System unit SysInitStdIO; // in System unit // Now you can do Writeln, DebugLn, ... end.

This is very useful to show whats going on in a Windows application when is processing in background, thanks.

Regards,
Marcos Douglas

Reply by email