Dec 202017
 
File Buffer object for Turbo Pascal. Source included.
File BUFER.ZIP from The Programmer’s Corner in
Category Pascal Source Code
File Buffer object for Turbo Pascal. Source included.
File Name File Size Zip Size Zip Type
BUFFERS.PAS 15242 3289 deflated
BUFFERS.TPU 10688 4773 deflated
READ.ME 1833 964 deflated

Download File BUFER.ZIP Here

Contents of the READ.ME file


*************** Generalized file I/O buffering *****************

The enclosed TP unit BUFFERS exports a new object BUFFERFILE. This
object allows to define a variable number of buffers with a buffersize
of up to $FFE0 bytes each. It exports a number of methods to tailor
the behaviour of the buffer to a specific applications needs - See the
following procedures for details in this area:

- SETWRITEBIAS
- SETREADBIAS
- RESETBIAS
- ENABLEINBOUND
- ENABLEOUTBOUND
- DISABLEINBOUND
- DISABLEOUTBOUND

The buffers may be allocated in expanded memory if desired. Performance
will be somewhat affected by this fact.

All methods use the same names as their counterparts in the system unit,
the there should not be any problem implementing them. The only minor
difference is the fact, that the READ and WRITE procedures do not accept
the optional fourth parameter, which in the system unit will return the
number of bytes actually read or written. This was done for performance
reasons but should be very easy to change.

The unit is implemented using some of Turbo Pascals object oriented
language constructs (actually my second step in this area). Some of the
object oriented stuff is not really very pure code - some access to the
imported data areas is direct, etc. This was done as to achieve some decent
performance.

Last but not least a small example on how to use the code:

Program Test;
VAR
BF : BufferFile;
L : LongInt;
begin
BF.Init(16384,5,True);
BF.SetWriteBias; {Purely optional - may improve performance}
BF.Assign('TEST.FIL');
BF.Rewrite(4);
For L:=1 to 20000 do BF.Write(L,1);
BF.Done;
end.

The code is herbey given to the public domain. If you discover any errors,
I would appreciate if you would let me know.

Rolf Ernst 72311,254


 December 20, 2017  Add comments

Leave a Reply