PDA

View Full Version : How do you Redirect WriteLn and Write in FPC?



jdarling
16-10-2006, 08:58 PM
Is there a cross platform way of doing console method redirects? What I mean is, if I have an library that I'm using that does console writes they will fail within a graphical application. How can I redirect StdOut to, oh say a memo, control on my form?

I've done a bit of googling, but no avail :(. I know how to do this in Windows and Delphi, but the solution I use isn't even close to cross platform then.

dmantione
16-10-2006, 11:13 PM
You do it exactly like in Turbo Pascal. Write a procedure assign_xxx, that fills the fields of a textrec. Then close output, assign, and open.

If you need an example, look at the source code of the crt unit, assignCRT and friends.