Am 23.10.2013 17:06, schrieb Sven Barth:
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).
And I just found an example which already does this for TCustomEdit
descendants: http://kd5col.info/swag/DELPHI/0017.PAS.html
I've not tested it in FPC, so maybe small adjustments might be necessary...
Regards,
Sven
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus