GetLine

InstallShield 2022 ยป InstallScript Language Reference

The GetLine function reads a line of text from a text file opened in read-only mode. Before you call GetLine, you must first call OpenFileMode to set the file mode to read-only and then call OpenFile to open the file (which can be a file on the Internet). The first call to GetLine reads the first line of text from the file. After reading a line, GetLine repositions the file pointer to the next line. The second call to GetLine reads the second line, and so forth. GetLine strips the carriage return and line feed characters from the end of the line it returns.

When GetLine has read all the lines in a file, it returns an end-of-file error. If you open a file in append mode, the GetLine function fails if you call it because the file pointer is at the end of the file. The function also fails if the file specified by nvFileHandle was opened in a binary mode.

The maximum size of a line is 4,096 characters. To read multiple lines from a file, use a separate GetLine call for each line or place the GetLine statement in a loop.

Tip:To write to a text file, use the WriteLine function. WriteLine always produces lines that have a carriage return and line feed character combination at the end of the line.

Syntax

GetLine ( nvFileHandle, svLine );

Parameters

GetLine Parameters

Parameter

Description

nvFileHandle

Specifies the handle of a file that has been opened by a call to OpenFile.

svLine

Returns a line of text from the file specified by nvFileHandle.

Return Values

GetLine Return Values

Return Value

Description

0

Indicates that the function successfully retrieved a line of text from an open text file.

< 0

Indicates that the function failed due to an end-of-file error or another error condition. This condition also indicates GetLine has read all the lines in the file.

See Also