Equinox Online Help - Language Reference - A to Z

Home

FileReadLine

Applies to
SyntaxFileReadLine HandleItem, LineItem
Action[Statement] Reads one line from a sequential file into a string
ScopeUsable anywhere
Notes

Data is read from the file into the LineItem specified as an argument. The item is read up to the end of line delimiter specified in the FileDelimiters statement. If the FileDelimiters statement has not been used within the Method the first end of line delimiter defaults to ASCII 13 and the second to ASCII 10 (ie CR followed immediately by LF).

This statement will not work if the file has been opened as a random file.

The HandleItem parameter must be of Equinox variable type Handle and is the handle of the file which was opened with the FileOpen statement.

After the statement has executed, SysReply contains the number of items read

The system workarea SysError is set to 4 if the end of file is detected and no items were read, 1 if an error occurs, otherwise zero.

CategoryFile IO
See Also FileClose, FileCloseAll, FileDelimiters, FileInput, FileInputLine, FileLock, FileMovePosition, FileOpen, FilePosition, FilePrint, FileRead, FileReadLine, FileReadBinary, FileReadFile, FileUnlock, FileWrite, FileWriteBinary, FileWriteFile
Example

This example reads two records from a sequential file which contains itemised call data from an office telephone system. The first line which contains an arbitrary transaction number is discarded.

handle hnd
string Buffer(100)

| Open the file and test for error
FileOpen "MYDATA.DAT", StreamReadOnly, hnd

if hnd = -1 then
Alert "File Opening Error"
exit method
end if

subtable Extension
| Read records from the sequential file
| and create table records
SetIndex iExt

while not syserror
FileReadLine hnd, Buffer

if syserror = 4 then exit while

| Find Extension record
Ext = mid(Buffer, 1, 5)
FindRecord EQ, Ext

if syserror then
Alert "Error Finding Record"
exit method
end if

| Insert a child record with the call data
subtable Items
BlankRecord

| Extract data from line
CallDate = mid(Buffer, 6, 8)
CallTime = mid(Buffer, 14, 5)
DestNo = mid(Buffer, 19, 16)
InsertRecord
end subtable | Items
end while
end subtable | Extension

FileClose hnd