ReadLine

Reads a line from the text file.

Syntax

ReadLine(fileID, lineString)

Parameters

Parameter

Type

Description

fileID

number

File ID received from OpenFile function.

lineString

string

String that receives the text from the file

Return

Returns 1 if more text to read is available in the file, otherwise, returns 0.

Note

In Python, use Python native file readlines() method. See Python code below.

Examples

Python

# open a file in read mode
f = open("C:\\Data\\parameters.txt", "r")
# read all the lines in the file and print them
if f:
    lines = f.readlines()
    f.close()
    for line in lines:
        print(line.rstrip()) # rstrip() removes end-of-line character from line

NexScript

% open a file in read mode
file = OpenFile("C:\Data\parameters.txt", "r")
% read all the lines in the file and print them
if file > 0
    line = " " % make line a string variable
    while ReadLine(file, line) > 0
        Trace(line)
    end
    CloseFile(file)
end