[fpc-pascal] Where does Write(Ln) actually write to?

Jonas Maebe jonas.maebe at elis.ugent.be
Sun May 10 14:30:47 CEST 2009


On 05 May 2009, at 06:21, leledumbo wrote:

> 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.

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



More information about the fpc-pascal mailing list