[Lazarus] WriteLn back to the GUI
Sven Barth
pascaldragon at googlemail.com
Wed Oct 23 17:06:06 CEST 2013
Am 23.10.2013 08:59, schrieb ListMember:
> Hello,
>
> I am trying to find where WriteLn is declared; but, apparently,
> WriteLn is among the select few that Lazarus will ignore 'Find
> Declaration' requests --at least that's how it behaves (latest Lazarus
> stable) on my side.
>
> My ultimate goal, after finding where it is declared, is to locally
> modify that part of the sources so that (instead of writing to the
> console) it will use a global callback to display whatever WriteLn'ed
> in a TMemo.
Write(Ln), Read(Ln), WriteStr and ReadStr are compiler magic functions
which are not available in Pascal source.
> Or, is there already an alternative to redirect console output to the
> running GUI?
The Pascal IO mechanism relies on variables of type "file" or of type
"text". For the latter you can specify your own "textdriver" with which
you can replace the e.g. "Output" variable (which is used by "Write(Ln)"
without a file argument) which can then redirect the output to something
else. For an example of how to implement a text driver you can take a
look at the "StreamIO" (
http://www.freepascal.org/docs-html/fcl/streamio/index.html ) unit
provided with Free Pascal (in
$fpcdir/packages/fcl-base/src/streamio.pp). There a text driver is
implemented which allows to "assign" streams to TextFile variables and
thus to use Write(Ln)/Read(Ln) on them. You'll need to implement
something similar for e.g. a memo (or whatever method you want to use to
display the output).
Regards,
Sven
More information about the Lazarus
mailing list