[Lazarus] WriteLn back to the GUI

ListMember listmember at letterboxes.org
Wed Oct 23 21:14:15 CEST 2013


On 2013-10-23 21:46, Sven Barth wrote:
> "Writeln" is a complex functionality. So you should better trust us 
> (hint: I'm a compiler developer) when we say this is more difficult 
> than you imagine.

I know you're a compiler developer; and, I have no intention of 
challenging you on that front --actually, I don't want to challenge 
anyone on any front at all, I have enough challenges as it is.

And, I am not trying to replace all of WriteLn functionality with my own 
code.

I am guessing, just guessing, FPC uses WriteLn to communicate with other 
modules (perhaps Lazarus too), but I also need its output directly in my 
app.

How about this:

Instead of redirecting all of its output through the callback, I only 
use callback to redirect a copy of its output --leaving the rest of its 
functionality intact?

>
>>> As I wrote in my post: See the CRT unit.
>>>
>>> It does exactly that. You need maybe 20 lines of code to do as you 
>>> want.
>>
>> Will do, thanks.
>>
>> But, let me ask this:
>>
>> If I used the CRT unit, would I need to add it to every single unit in
>> the project that uses WriteLn?
>
> Michael did not say that you should use the CRT unit, but that the 
> unit implements something similar and that you should take a look at 
> it to implement your own variant of it.
> And then you need to include your own unit only once (e.g. either you 
> put the "hooking" into the initialization section or you do it at the 
> start of your program)

I took a look at crt.pas and AFAIC it is not significantly less complex 
than finding the place of WriteLn in compiler code and altering it to 
use a callback ;)




More information about the Lazarus mailing list