Equinox Online Help - Language Reference - A to Z

Home

FileInput

Applies to
SyntaxFileInput HandleItem, Item1[, Item2, Item3 ... ]
Action[Statement] Reads a delimited list of items from a sequential file.
ScopeUsable anywhere
Notes

Data is read from the file directly into the items specified in the parameter list, taking account of the delimiters specified in the statement.

During the input operation, all quotes are stripped and no account is taken of data types in the file. The items are treated as strings and converted automatically into the destination data types passed as parameters. Arrays and vector expressions are allowable destination types, although the array must be of fixed size.

Each item is read up to the item delimiter specified after it in the statement. The delimiters recognised are:

  • , the inter-item delimiter (default comma)
  • ;; end of line delimiter (default Linefeed - Return ignored)
  • ; either delimiter

If no delimiter is supplied after the last item, end-of-line is assumed. The delimiters are set up via the FileDelimiters statement.

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

This statement is only supported for files opened for sequential access.

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
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 containing names and telephone numbers and creates records in a table.

handle hnd

| 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 CONTACTS
| Read records from the sequential file
| and create table records.
| The code is expecting to see comma delimiters

while not syserror
BlankRecord
FileInput hnd, Surname, ChrName, Initials, TelNo
if syserror = 4 then exit while
InsertRecord
end while
end subtable | CONTACTS

FileClose hnd

The next examples demonstrate the different ways items can read from a file into arrays.

The first example is successful if each array element is on a separate line

int a[4], n

FileInput hnd, a

This example is successful if the array elements are comma seperated on one line.

int a[4], n

FileInput hnd, a;;