Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter SixFile Functions (continued)

ReadLine Function

Overview

The ReadLine function reads a line of text from a Mapped Text, Edit, Basic File or a String Pool Object.

Syntax/Parameters

Syntax

string = ReadLine ( handle hObject, [int index | position] );

Parameters

hObject

A handle to a Basic File, Mapped Text, Edit or String Pool Object.

index

An int parameter specifying a zero-based index to a specific line in the file. The index parameter is required if the object parameter references a Mapped Text object. If the index is out of range, an error will be returned.

position

An optional int specifying an absolute position within a Basic File or String Pool Object. If the parameter is omitted, the last position will be used and the object will be read serially.

Return Value

Returns a string containing the line of text or an empty string on failure. Use GetLastError to retrieve error information.

Remarks

The ReadLine function returns the line less any end-of-line codes such as return (0x0D) or newline (0x0A). The maximum size of a line is 1,048,575 characters.

Note that an empty string may not necessarily indicate an error occurred. The last line may also contain non-error information, which means checking the last error against zero is an invalid test. Use the IsError or IsNotError functions to determine if an error occurred.

When getting a line from a Basic File or a String Pool Object, the GetLastError function will return the size of the line and the code that terminated the line in the form 0x00ccssss, where cc is the code, such as 0x0D, and ssss is the size of the string returned less the zero terminator. For Basic File Objects, when a return is encountered, the function will check for the next line by a 0x0A character and skip that character, if present.

Reading from a Basic File Object by lines is inefficient. Avoid repeatedly reading large files using this method.

For Mapped Text Objects, the reciprocal for read is the ReplaceLine function to write a line.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic