[fpc-pascal] Make FPC closer to hardware

Frank Peelo f26p at eircom.net
Mon Nov 17 12:45:03 CET 2008

leledumbo wrote:
> Micha Nelissen wrote:
> Let Write(Ln) work without file system support? Perhaps just by supplying a
> routine to write one character, and let other write routines use it.

I think it already has what you want there.

Doesn't call a function for each char, though. That was last seen in 
TurboPascal 3. TurboPascal v4 introduced Text File Device Drivers. These 
do the same thing, but much more efficiently and flexibly.

Basically, you write 4 functions for your device to handling opening the 
file, doing I/O, flushing any internal buffers and closing (e.g. if you 
were writing a device driver to send output via carrier pigeon, they 
might be called PigeonOpen, PigeonInOut, PigeonFlush and PigeonClose), 
and then an Assign... procedure (AssignPigeon) to associate these 
functions with a text file. Then use Write(Ln) to that text file, and 
the stuff goes through your driver procedures. If you want to just use 
Writeln('blablabla') instead of Writeln(f, 'blablabla') then your Assign 
procedure will assign the file the '' name.

You've already guessed from the name of the InOut function that this can 
be used to replace the keyboard input as well as screen output.

Googling for
Pascal "text file device driver" example
finds links like the following:


(see section 8.4)

Or here's an example of creating routines which take chars from 
Write(Ln) and sending them to somewhere else (to a stream):

There's the CRT unit source code, crt.pp, as well.


More information about the fpc-pascal mailing list