Virtual Pascal

Classic Object Pascal for free

G'day Folks,


Correct way to redirect StdOut .. please?




I cannot get output redirection to work, using...

  Assign (Output, '');



Same problem if I change it to ..


  Assign (StdOut, '');





WriteLn is used (always) thus ... WriteLn(Output, "whatever");


ie: just WriteLn("whatever");  ..does not work!  (when redirecting output)



What is the correct way to redirect StdOut .. please?


Many Thanks



Views: 435

Reply to This

Replies to This Discussion

I've no answer, but mentioning the OS could be beneficial to other answers. I assume you use Crt for kbd only and want to get ordinary output back?

Fair enough .. it's Windows XP....


And I want to use standard redirection at the command-line thus...

(AFAIK .. this is pretty standard)..


C:\>  MyExe  parm1  parm2  >  X:\MyOutputfile.txt


So that any WriteLn output goes to MyOutputfile.txt, instead of the screen.


But I wouldn't have thought that it was OS-specific .... or is it?


Surely I'm not the only one using/wanting re-direction .. am I?  :-)




Don't use the CRT unit. If you use the CRT unit, everything gets sent directly to the screen. When not using it, everything gets sent to StdOut.
On TP, the code that Barry posted undoes the effect output (video) effects of Crt. That's why I assumed he used Crt for keyboard related purposes only

G'day Folks


Arrgggghhhhh!   I forgot ....         (It *does* work)...


The "Assign (Output, '')" statement has to be the very *first* statement ... and I was burying it in an initialisation routine - which is why it didn't work at that time.


So... Very sorry ... mea culpa   or ..      a case of..... RTFM ..!  :-))


My apologies to all for what amounts to a "red herring" ...


Please don't hit me :-)





© 2022   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service