Recent

Author Topic: Problems with getting Output of TProcess  (Read 6260 times)

cybermonkey342

  • New Member
  • *
  • Posts: 42
    • Home of EGSL interpreter
Problems with getting Output of TProcess
« 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)
--
Best regards

cybermonkey342

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: Problems with getting Output of TProcess
« Reply #1 on: September 07, 2010, 10:18:32 am »
Remove 'uses crt'
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

cybermonkey342

  • New Member
  • *
  • Posts: 42
    • Home of EGSL interpreter
Re: Problems with getting Output of TProcess
« Reply #2 on: September 07, 2010, 11:47:51 am »
Oh my! Thanks a lot that does the trick.
« Last Edit: September 07, 2010, 11:55:47 am by cybermonkey342 »
--
Best regards

cybermonkey342

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Problems with getting Output of TProcess
« Reply #3 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