Equinox Online Help - Language Reference - A to Z

Home

FileRead

Applies to
SyntaxFileRead HandleItem, Item1[, Item2, Item3 ... ]
Action[Statement] Reads a list of items in internal Equinox format from a random file.
ScopeUsable anywhere
Notes

This statement reads items in internal format from a file into Equinox variables or fields. A list of mixed types can be read from the file in one operation; however the types of the items in the file must match the types of variable passed as arguments.

Strings are preceded by a 16-bit length and memos by a 32-bit length.

This statement will not work if the file has been opened as a sequential 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 records from a random file and creates transaction log records in a table. NextDate and NextTranNo are fields whilst ulSectionLength is a variable.

uLong ulSectionLength
handle hnd

| Open the file and test for error
FileOpen "LOG.DAT", RandomReadOnly, hnd

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

subtable TRANLOG
| Read records from a random file
| and create table records
while not syserror
BlankRecord

FileRead hnd, ulSectionLength, NextDate, NextTranNo

if syserror = 4 then exit while
InsertRecord
end while
end subtable | TRANLOG

FileClose hnd