SIMPOL Documentation

fsfileinputstream

Description

Provides an interface to open a file in a file system for sequential reading.

Type Tags

None

Object Value

The value of an object of type fsfileinputstream is undefined and it is an error to attempt to get or to set it.

fsfileinputstream.new()

Description

Opens the specified file system file for reading and creates a new object.

Prototype

fsfileinputstream.new ( string filename, integer error )

Parameters

ParameterDefault valueType nameDescription
filename.nulstring The name of the file to open.
error.nulinteger Specifies an object that is used to output any error code generated during the execution of the method. This parameter must be an object, not an integer value. If error is not specified or is .nul then any error that occurs during object creation will halt the program. If an error object is specified and an error occurs during execution then the error code is output into that object and the method returns .nul.

Properties

PropertyTypeDescription
_type(*) This property is provided for use by the user to attach any object of any type to the type in which this property is provided.
__type(*) This property is provided for use by the user to attach any object of any type to the type in which this property is provided. It has the additional feature of being marked with the resolve keyword, so that object resolution can continue down this property.
endofdataboolean Contains the value .false until reading has failed because the end of the file has been found, at which point it is set to .true.
filenamestring Contains the name of the file that is being read.
typetype Specifies the fsfileinputstream type object.

Methods

getblob()

Description

Returns a blob containing bytes read from the file.

Prototype

fsfileinputstreamvar.getblob ( integer length )

Parameters
ParameterDefault valueType nameDescription
length1integer The number of bytes to read from the file. If this value is .nul then the result will also be .nul. If the value is .inf, then bytes will be read until the end of the file.

getinteger()

Description

Returns an integer read from the file.

Prototype

fsfileinputstreamvar.getinteger ( integer length, boolean lbo, boolean signed )

Parameters
ParameterDefault valueType nameDescription
length1integer The number of bytes to read from the file. If this value is .nul then the result will also be .nul. If the value is .inf, then bytes will be read until the end of the file and then interpreted as a single integer value.
lbo.trueboolean Indicates whether integers have been stored with the least significant byte first (.true) or with the most significant byte first (.false). If this value is .nul or .inf then the result will also be .nul.
signed.falseboolean Indicates whether the bytes will be interpreted as a signed or unsigned integer. If this value is either .nul or .inf then the result will also be .nul.

getstring()

Description

Returns a string containing characters read from the file. If the string is stopped by a terminator (see the 'terminator' parameter) then the terminating character is not included in the returned string.

Prototype

fsfileinputstreamvar.getstring ( integer length, integer charsize, boolean lbo, string terminator, string terminatedby )

Parameters
ParameterDefault valueType nameDescription
length1integer The number of characters to read from the file. If this value is .nul then the result will also be .nul. If the value is .inf, then characters will be read to the end of the file, or until a terminator is found (see the terminator parameter).
charsize2integer The number of bytes per character, which must be greater than 0. If this value is either .nul or .inf then the result will be .nul.
lbo.trueboolean Indicates whether characters have been stored with the least significant byte first (.true) or with the most significant byte first (.false). If this value is .nul or .inf then the result will be .nul.
terminator""string A string made up of all the characters which can terminate the string being read. As soon as any one character in the string of terminators is read then reading stops and the string is returned. If this value is .nul then no character will terminate the reading. If it is .inf then the result will be .nul.
terminatedby.nulstring This parameter must be an object, not a string value such as a literal or expression. If the reading of the string is terminated by finding a character in the terminator string then that character is returned in the terminatedby object.