Lazarus

Programming => Operating Systems => Windows => Topic started by: cybermonkey342 on September 07, 2010, 09:58:53 am

Title: Problems with getting Output of TProcess
Post by: cybermonkey342 on September 07, 2010, 09:58:53 am
I have a problem with TProcess in Windows which works fine in Linux, though. I have a Pascal program which "writelns" to the console, of course compiled with $apptype console. The output works fine. Then I have another program which should read the output. This does not work. (I use the third example as a reading program of: http://wiki.lazarus.freepascal.org/Executing_External_Programs). This works fine on Linux. Of course it works fine on Windows except for reading the output of Pascal programs.
So this C program works:
Code: [Select]
#include <stdio.h>
 
int main(int argc, char** argv)
{
   printf ("Hello World\n");
   return 0;
}
Output is: Hello World.

This does not work:
Code: [Select]
{$apptype console}
program Helloworld;
 
uses crt;
 
BEGIN
writeln ('Hello World');   
END.

No output at all is recognized. (But if I start this program solely "Hello World" is written to the console ...)
So what can I do? I don't want to re-implement my program in C. ("Hello World" is just an example)
Title: Re: Problems with getting Output of TProcess
Post by: eny on September 07, 2010, 10:18:32 am
Remove 'uses crt'
Title: Re: Problems with getting Output of TProcess
Post by: cybermonkey342 on September 07, 2010, 11:47:51 am
Oh my! Thanks a lot that does the trick.
Title: Re: Problems with getting Output of TProcess
Post by: Leledumbo on September 07, 2010, 12:36:45 pm
Please stop writing Pascal based console programs using Crt unit. It overrides the video driver and messes up the default buffering system. Most of the time you don't need any of it's functionality and even if you do, they can be replaced with KVM units (keyboard, Video, Mouse).
TinyPortal © 2005-2018