Fileread, Filereadline – Campbell Scientific CR9000X Measurement and Control System User Manual
Page 386

Section 9. Program Control Instructions
FileRead
Reads a file referenced by a FileHandle and stores the results in a variable or
variable array.
Syntax
BytesRead = FileRead(FileHandle, Dest, Length)
Remarks
The FileRead function returns the number of bytes successfully read. This
function reads to the end of the file or to the maximum number of bytes
(Length parameter). To read only one line of a file, use the FileReadLine
function.
Parameter
& Data Type
Enter
FILEREAD PARAMETERS
FileHandle
variable
Variable that holds the result of the FileOpen function.
Dest
String Variable
Variable in which the results of the read should be stored.
Length
Variable array
The Length parameter specifies the maximum number of characters to be read in to the Destination
variable. If Destination is an array, Length must equal to at least the total of the number of bytes for
all elements in the array. For example, if you are reading 3 elements of an array and each element is
4 bytes, Length must be at least 12.
FileReadLine
Reads a line in a file referenced by a FileHandle and stores the result in a
variable or variable array.
Syntax
BytesRead = FileReadLine(FileHandle, Dest, Length)
Remarks
The FileReadLine function reads to the end of a line (as indicated by a
carriage return or line feed) or until the maximum number of bytes is reached
(specified by Length). The FileReadLine function returns the number of bytes
successfully read or -1 if the end of the file is reached. To read multiple lines
or an entire file, use the FileRead function.
Parameter
& Data Type
Enter
FILEREADLINE PARAMETERS
FileHandle
variable
Variable that holds the result of the FileOpen function.
Dest
String Variable
Variable in which the results of the read should be stored.
Length
Variable array
The Length parameter specifies the maximum number of characters to be read in to the
Destination variable. If Destination is an array, Length must equal to at least the total of
the number of bytes for all elements in the array. For example, if you are reading 3
elements of an array and each element is 4 bytes, Length must be at least 12.
9-56