On 20 March 2015 at 20:54, Sven Barth <pascaldra...@googlemail.com> wrote:

> On 20.03.2015 21:18, vfclists . wrote:
>
>>
>>
>> On 20 March 2015 at 19:34, Sven Barth <pascaldra...@googlemail.com
>> <mailto:pascaldra...@googlemail.com>> wrote:
>>
>>     Am 20.03.2015 19:19 schrieb "vfclists ." <vfcli...@gmail.com
>>     <mailto:vfcli...@gmail.com>>:
>>
>
snip

> How do you ensure own implementation overrides the system's
>> implementation, does the compiler take care of that automatically, or
>> will you have to name your function differently?
>>
>
> There is no need to ensure that. Here is an example:
>
> === code begin ===
>
> var
>   f, oldout: TextFile;
> begin
>   Writeln('Hello Output as StdOut');
>
>   oldout := Output;
>
>   Assign(Output, 'test.txt');
>   Rewrite(Output);
>
>   Writeln('Hello Output as file');
>
>   Close(f);
>
>   Output := oldout;
>
>   Writeln('Hello Output as StdOut again');
> end.
>
> === code end ===
>
> To see how such a TextFile is implemented you can take a look at unit
> StreamIO which is part of FPC's units.
>
> (Though I wonder why "Assign(f, 'test.txt'); Output := f; Writeln('Hello
> Output as file');" does not work :/ )
>
> Regards,
> Sven
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>

I need to get the output of a program which uses a lot of Write and Writeln
commands into the GUI in realtime, by that I not having to output it to a
text file and reading it afterwards, but by capturing the output of each
Write command into a variable and displaying it in the GUI immediately.

If each Write or Writeln could trigger an event, I could use the event to
capture the output. My other option is to replace the calls to write with
my own function, but Write has different number of call parameters and it
may require as many variants of the function as are used in the program,
assuming that the call syntax is regular, not something like this one -
write(JSValToDouble(cx,pom^)):1:scale).

-- 
Frank Church

=======================
http://devblog.brahmancreations.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to