ListMember schrieb:
On 2013-10-23 23:20, Hans-Peter Diettrich wrote:
ListMember schrieb:

Frankly, I agree that I should not have to modify the compiler or the RTL; especially for something like redirecting the WriteLn output from console to my own application.

But, doing it through text drivers etc. is --how can I put it-- almost inhuman.

It's basic OOP to derive classes from existing ones. Writing an text driver is exactly the same task, even if the "class" keyword is not used here - for historical reasons.

Thank you for that gem.

But, why would I have to write 100+ lines of code just to capture the output of WriteLn.

Then you're doing something very, very wrong.

Have you looked at the code Sven linked to, or are you saying this just because it is the usual thing to say under these circumstances?

Writing an text driver was about my first project in D4, all I can contribute is from that time and environment.


Plus, I keep getting segfaults when I close the application --something is calling InOutFunc when the app closes and still tries to write to a destroyed TMemo.

No wonder. You should understand what you have to implement, before writing bogus code.

Again, rather than the high horse you seem to be riding (which even Sven doesn't, despite the fact that he is a compiler developer), thereby adding nothing of value to the solution of the problem, I'd appreciate it very much if you could offer focused help.

Sorry, my bad :-(

I'd suggest that you write an file driver first, to get familiar with the functions to implement. Play around using an file buffer, or with direct file I/O. Then it should be easier to replace the file by another (GUI) component, in the next step. If you have problems with that code, you can look up the RTL implementation of such I/O.

Next comes a decision of direct (write-through) or buffered output. When the output goes into a Memo like control, I'd simply append all output immediately to memo.Text. AFAIR I ended up using a TStrings object, as obtainable from e.g. a ListBox, and implemented line buffering capabilities. In this case only full lines (up to EOL, or when the buffer is filled entirely) are added to the TStrings object and removed from the buffer.

Bidirectional (console-like?) I/O deserves more considerations, if you want to implement something like that.

DoDi


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to