I'm almost there to have Write(Ln) works for my OS. I've made SysInitStdIO call OpenStdIO(Output,fmOutput,StdOutputHandle); and calling Write(Ln) gives no error (i.e. IOResult = 0). But where does it actually write to? If I can access the buffer, I can display it on the screen.
Mailing lists / fpc-pascal / 2009-05
Where does Write(Ln) actually write to?
7 messages · 3 people · –
- Lleledumbo 4
- TTomas Hajny 2
- JJonas Maebe 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
leledumbo wrote 6 lines
access the buffer, I can display it on the screen.
It writes to whatever the text file variable called "stdout" in rtl/ inc/systemh.inc is assigned to. Standard I/O is indeed buffered, see the routines in rtl/inc/text.inc. The actual writing from the buffer to the associated file/device is done by FileWriteFunc(), which calls Do_Write() (the latter is an OS-specific function that you have to implement).
Also note that if textrec.FlushFunc is nil, then write(ln) will not automatically flush after each operation. As you can see in FileOpenFunc(), it is only assigned in case Do_Isdevice() returns true for the handle of the opened "file".
Jonas
Jonas Maebe-2 wrote 13 lines
Roger that, implementation begins...
leledumbo wrote 15 lines
I guess that you should have a look at some of the other Do_??? functions, in particular Do_Open coming to my mind. Unfortunately, the description for these functions in our Wiki
(http://wiki.freepascal.org/System_unit_structure) has not been finished yet. :-(
Tomas
Tomas Hajny wrote 7 lines
Currently, I implement them as empty functions just to make the rtl compiles without choking. I agree that wiki things need to be finished, I feel lost on what those things do.
It works... but only for the first call, after that IOResult gives 103. Does rtl closes stdout handle after every write or what?
leledumbo wroteIt works... but only for the first call, after that IOResult gives 103. Does rtl closes stdout handle after every write or what?
No, certainly not. As suggested yesterday, you need to implement some of the other Do_* functions, at least Do_Open, otherwise some of the fields in the TextRec/FileRec are not initialized properly (e.g. the input/output mode). Just have a look at one of the existing implementations.
Tomas
