Please enable JavaScript to view this site.

ESL Documentation

FILEIO Subroutine

Change the I/O index buffer size.

call SetIndexSize(FILE_ID_IV, INDEX_SIZE_IV)

FILE_ID_IV

An integer variable for the file id.

INDEX_SIZE_IV

An integer variable containing the index buffer size in bytes.

Description

SetIndexSize( ) allows you to modify the buffer used by the File I/O input subroutines to keep track of the number of lines in a file. This allows you to adjust the size of the index buffer to optimize the speed at which the file is read, while keeping the buffer size as small as possible.

Program speed can be improved in some cases by increasing the index buffer size for one or more files. Conversely, the amount of memory needed can be reduced by decreasing the index buffer size for one or more files. The default value is 1K. If you choose to resize the buffer, make the modifications only once, just after opening the file.

Decreasing the index size can be beneficial if you are using the sequential input subroutines, since they do not use the index. Once the index has been reduced, however, some degradation in speed can result that cannot be recovered by increasing the index. Reducing the index size results in fewer "place markers", which are used by ReadLineNumber( ). This means that typically more scanning must be done to satisfy a ReadLineNumber( ) request, which slows response time. Increasing the index size, conversely, will shorten the typical scanning time, and thus speed up response time. Although index size is in bytes, an index entry takes four bytes, so the number of lines that can be "remembered" equals the index size divided by four.

Errors

FIO_E_NOTOPEN

File has not been opened. A file must be opened before a read attempt is made.

FIO_E_REALLOCMEM

Insufficient system memory. Not enough system memory to set buffer or index to size requested.

Example

integer FileID

integer BufferSize is 1024

integer IndexSize is 1024

integer TabSize is 5

include "fileio.inc"

 

# To be brief, error handling is omitted

response to line "Double Buffer" from keyboard

 copy (BufferSize * 2) to BufferSize

 call SetBufferSize (FileID, BufferSize)

 

response to line "Halve Buffer" from keyboard

 copy (BufferSize / 2) to BufferSize

 call SetBufferSize (FileID, BufferSize)

 

response to line "Double Index Size" from keyboard

 copy (IndexSize * 2) to IndexSize

 call SetIndexSize (FileID, IndexSize)

 

response to line "Halve Index Size" from keyboard

 copy (IndexSize / 2) to IndexSize

 call SetIndexSize (FileID, IndexSize)

 

response to line "Set Tab Size" from keyboard

 call SetTabSize (FileID, TabSize)