Libraries
Strifile Source Code
 previous   up   next 

Types
striFile
File implementation type for files stored in a string.

striFile

const type: striFile

File implementation type for files stored in a string. String files are seekable, therefore they support the functions length, seek and tell.


Function Summary
file
openStriFile (in string: content)
Open a striFile with the given string content.
file
openStriFile
Open a striFile with an empty string content.
void
write (inout striFile: outStriFile, in string: stri)
Write the string stri to outStriFile.
char
getc (inout striFile: inStriFile)
Read a character from inStriFile.
string
gets (inout striFile: inStriFile, in integer: maxLength)
Read a string with maximum length from inStriFile.
string
getwd (inout striFile: inStriFile)
Read a word from inStriFile.
string
getln (inout striFile: inStriFile)
Read a line from inStriFile.
boolean
eof (in striFile: inStriFile)
Determine the end-of-file indicator.
boolean
hasNext (in striFile: inStriFile)
Determine if at least one character can be read successfully.
integer
length (in striFile: aStriFile)
Obtain the length of a aStriFile.
void
truncate (inout striFile: aStriFile, in integer: length)
Truncate aStriFile to the given length.
boolean
seekable (in striFile: aFile)
Determine if the file aFile is seekable.
void
seek (inout striFile: aStriFile, in integer: position)
Set the current file position.
integer
tell (in striFile: aStriFile)
Obtain the current file position of aStriFile.

Function Detail

openStriFile

const func file: openStriFile (in string: content)

Open a striFile with the given string content.

Returns:
the file opened.

openStriFile

const func file: openStriFile

Open a striFile with an empty string content.

Returns:
the file opened.

write

const proc: write (inout striFile: outStriFile, in string: stri)

Write the string stri to outStriFile.


getc

const func char: getc (inout striFile: inStriFile)

Read a character from inStriFile.

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

gets

const func string: gets (inout striFile: inStriFile, in integer: maxLength)

Read a string with maximum length from inStriFile.

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

getwd

const func string: getwd (inout striFile: inStriFile)

Read a word from inStriFile. Before reading the word it skips spaces and tabs. The function accepts words ending with " ", "\t", "\n", or EOF. The word ending characters are not copied into the string. When the function is left inStriFile.bufferChar contains ' ', '\t', '\n' or EOF.

Returns:
the word read.

getln

const func string: getln (inout striFile: inStriFile)

Read a line from inStriFile. A striFile works as if all lines end with '\n'. The line ending character is not copied into the string. When the function is left inStriFile.bufferChar contains '\n' or EOF.

Returns:
the line read.

eof

const func boolean: eof (in striFile: inStriFile)

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 striFile: inStriFile)

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 striFile: aStriFile)

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

Returns:
the length of a file.

truncate

const proc: truncate (inout striFile: aStriFile, in integer: length)

Truncate aStriFile to the given length. If the file previously was larger than length, the extra data is lost. If the file previously was shorter, it is extended, and the extended part is filled with null bytes ('\0;'). The file length is measured in characters.


seekable

const boolean: seekable (in striFile: 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 striFile is seekable.

seek

const proc: seek (inout striFile: aStriFile, 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 striFile: aStriFile)

Obtain the current file position of aStriFile. 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