Windows console

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Windows console

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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Windows console

José Mejuto
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, ...

--

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Windows console

Santiago A.
El 05/09/2016 a las 16:26, José Mejuto escribió:

> 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.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Windows console

Marcos Douglas B. Santos
On Tue, Sep 6, 2016 at 6:44 AM, Santiago A. <[hidden email]> wrote:

> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal