Equinox Online Help - Language Reference - A to Z

Home

FileInputLine

Applies to
SyntaxFileInputLine HandleItem, Item1[, Item2, Item3 ... ]
Action[Statement] Reads a list of items from a sequential file up to the end of the line.
ScopeUsable anywhere.
Notes

This statement is identical to FileInput, except that a whole line is always read, ensuring that each input statement starts on a new line. This is convenient for reading lines which may contain different numbers of items.

After the call, the system workarea SysReply contains the number of items read.

The system workarea SysError is set to one of the following values

  • 0 No error
  • 1 An error occurred
  • 4 End of file detected - nothing read

If Equinox reads fewer items than the number of variables supplied as parameters, or if the delimiters supplied in the statement are different to those found in the file, SysError is set to one.

In all cases, SysReply is set to the number of items read.

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 records from a sequential file, line by line. The file was written by a small program controlling a weather station, which writes data collected from instruments into a line of a text file. Each line starts with the name of the instrument and the time of the event, followed by the data, which is different for each instrument. The instrument name is converted into a numeric type and the other information is stored in fields in the record.

handle hnd
number lineno(6,0)
string instrument, fld1, fld2, fld3

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

if hnd = -1 then
Alert "File Open Error"
Exit Method
end if

lineno = 0

subtable Records
lineno += 1
BlankRecord
FileInputLine hnd, instrument, RecTime, fld1, fld2, fld3

if syserror then exit subtable

if sysreply < 3 then
Print "Not enough fields on line",lineno
Continue subtable
end if

RecDate = today

Switch instrument
case "Anemometer"
RecType = 1
RecMax = fld1
RecMin = fld2
RecAverage = fld3
case "RainGauge"
RecType = 2 RecMax = fld1
case "Barometer"
RecType = 3
RecMax = fld1
RecMin = fld2
RecMaxChange = fld3
case "Thermometer"
RecType = 4
RecMax = fld1
RecMin = fld2
default
RecType = 0
Print "Unknown instrument",instrument
end switch

if RecType then
InsertRecord
if syserror then exit subtable
end if

Continue subtable
end subtable | Records

if syserror <> 4 then Print "An unexpected error occurred"
Print lineno,"records read"

FileClose hnd