Libraries
Sub file Source Code
 previous   up   next 

Types
subFile
File implementation type for a sub segment of a base file.

subFile

const type: subFile

File implementation type for a sub segment of a base file. A sub segment has a starting position and a length.


Function Summary
file
openSubFile (in file: baseFile, in integer: startPos, in integer: size)
Open a file to read from a sub segment of a base file.
char
getc (inout subFile: inSubFile)
Read a character from inSubFile.
string
gets (inout subFile: inSubFile, in integer: maxLength)
Read a string with maximum length from inSubFile.
boolean
eof (in subFile: inSubFile)
Determine the end-of-file indicator.
boolean
hasNext (in subFile: inSubFile)
Determine if at least one character can be read successfully.
integer
length (in subFile: aSubFile)
Obtain the length of a aSubFile.
boolean
seekable (in subFile: aFile)
Determine if the file aFile is seekable.
void
seek (inout subFile: aSubFile, in integer: position)
Set the current file position.
integer
tell (in subFile: aSubFile)
Obtain the current file position of aSubFile.

Function Detail

openSubFile

const func file: openSubFile (in file: baseFile, in integer: startPos, in integer: size)

Open a file to read from a sub segment of a base file.

Parameters:
baseFile - Base file in which the sub segment is situated.
startPos - Start position of the sub segment.
size - Size of the sub segment.
Returns:
the file opened.

getc

const func char: getc (inout subFile: inSubFile)

Read a character from inSubFile.

Returns:
the character read, or EOF at the end of the file.

gets

const func string: gets (inout subFile: inSubFile, in integer: maxLength)

Read a string with maximum length from inSubFile.

Returns:
the string read.
Raises:
RANGE_ERROR - The parameter maxLength is negative.

eof

const func boolean: eof (in subFile: inSubFile)

Determine the end-of-file indicator. The end-of-file indicator is set if at least one request to read from the file failed.

Returns:
TRUE if the end-of-file indicator is set, FALSE otherwise.

hasNext

const func boolean: hasNext (in subFile: inSubFile)

Determine if at least one character can be read successfully. This function allows a file to be handled like an iterator.

Returns:
FALSE if getc would return EOF, TRUE otherwise.

length

const func integer: length (in subFile: aSubFile)

Obtain the length of a aSubFile. The file length is measured in characters.

Returns:
the length of a file.

seekable

const boolean: seekable (in subFile: aFile)

Determine if the file aFile is seekable. If a file is seekable the functions seek and tell can be used to set and and obtain the current file position.

Returns:
TRUE, since a subFile is seekable.

seek

const proc: seek (inout subFile: aSubFile, in integer: position)

Set the current file position. The file position is measured in characters from the start of the file. The first character in the file has the position 1.

Raises:
RANGE_ERROR - The file position is negative or zero.

tell

const func integer: tell (in subFile: aSubFile)

Obtain the current file position of aSubFile. The file position is measured in characters from the start of the file. The first character in the file has the position 1.

Returns:
the current file position.


 previous   up   next