21. 4GL Statement Glossary : ReadFile( )
 
Share this page                  
ReadFile( )
Reads a file.
Syntax
[returnfield = ] [callproc] readfile(handle = handle
  , byref(item) {, byref(item) } )
returnfield
Specifies the name of field to which the result is returned. Integer.
handle
Specifies the file identifier used by the 4GL file access functions. Integer.
item
Specifies the data that you are retrieving from the file. String. Reads in as many bytes as are in the item datatype.
Description
The readfile() built-in function reads the data in a file that was previously opened with the openfile() function. The file must be open and the file's handle must be known to 4GL.
For a binary type file, the total size of the items read from a file must be the same as the file's record size. You can declare the record size in the openfile() statement, otherwise 4GL calculates it from the item list size indicated with the first read or write to the file.
4GL processes only string data types for files opened as a text file. 4GL issues an error if the item list returns data of types other than string.
The procedure returns 0 if the function completes without error.