Category : Pascal Source Code
Archive   : TFDD.ZIP
Filename : TFDD.DOC

Output of file : TFDD.DOC contained in archive : TFDD.ZIP

This is the documentation file for an archive also holding Turbo Pascal 5.5
source for four object-oriented units that illustrate and apply TFDD's --
text file device drivers:
tfdd.pas, a generic TFDD class meant only for inheritance. but suitable
for any TFDD;
kbdEdit.pas, a tfdd descendant that implements a decent line editor for
Read's and Readln's (like the editor the TP IDE uses for option
strWrite.pas, a second tfdd descendant that simply allows writes to go
to a string instead of to any output; the string can then be
retrieved later
writAttr.pas, a third tfdd descendant that allows display attributes to
be specified right in the middle of a write.

The point of using text file device drivers to do this is that a TFDD is simply
invoked as a file variable whithin any Read, Readln, Write or Writeln, so:
1) you can still use the special flexibility of these Pascal commands,
which can't be reproduced in normal in procedures;
2) pre-existing code is extremely easy to convert;
3) for quick work, no new procedures have to be learned -- you simply
add the proper unit to the Uses clause, and call the proper file

Tfdd.pas makes use of the User Data field in a text record to pass the
address of Self to the various driver functions. TFDD's are older than OO
facilities in TP, so they do not directly allow for object implementation. But,
simply by using User Data as it's intended to be used, they can integrate quite
well with objects. Both KbdEdit and StrWrite use the Self pointer, and in
KbdEdit the tfdd's work is actually done by a class method.
Each of the three descendant units automatically initializes one instance of
the class it defines, as part of its unit initialization code. In the case
KbdEdit and WritAttr, it's hard to imagine why you'd need more than one
instance of the class. But for StrWrite you might. All you'd have to do is
VAR otherStr: strWriteC;
then call
KbdEdit and WritAttr use TP's Crt unit. Take care to replace the mention, in
the implementation Uses lists, with OpCrt or TpCrt if you use those.

Copyright notice:
I claim copyright on this file and the four source files mentioned.
These units are not put into the public domain, so as to prevent the
diffusion of half-modified versions. The source code may be distributed by any
means in complete form and as is, including the present notice, or not at all.
Modifications, etc. may be ADDED to the distributed code, as separate texts, of
As author and copyright owner I waive all legal rights on object or
executable code compiled using part or all of these units. This is to avoid any
administrative complication for users.
However, I request that any programmer using this source code for paid work
or for sold programs send me a $5 contribution at:
Philippe Ranger
P. O. Box 48017
5678 Park Avenue
Montreal QC H2V 4S8

Comments would be much appreciated. My CompuServe user ID is 71531,1350.

Philippe Ranger
July 13, 1990