20. Writing 4GL Statements : Accessing Files from 4GL
 
Share this page                  
Accessing Files from 4GL
You can use 4GL to access files at the operating system level, without leaving 4GL or calling a 3GL procedure. Use the following built-in functions to access files:
CloseFile()
Closes a file. To delete a file, use the closefile() statement with the clause disposition='delete'.
FlushFile()
Writes the contents of a file to disk
InquireFile()
Retrieves information about a file
OpenFile()
Opens a file. To create a file, use the openfile() statement.
PositionFile()
Positions a file
ReadFile()
Reads a file
RewindFile()
Positions a file to 0
WriteFile()
Writes data to a file
The file-access functions are called with the callproc statement. The functions follow the syntax for the callproc statement, which is:
[returnvalue = ][callproc] function(param = value
    {, param = value})
A parameter can be passed as a string, an integer, a variable or a variable by reference. Parameters are case-insensitive.
The returnvalue is an integer that indicates the function's return status. A return value of 0 means the function completed without error. A return value of < 0 indicates the function failed. A runtime error displays a specific error message, including an operating system-specific error, if available.
For the complete syntax for each of these statements, see 4GL Statement Glossary.
The file-access statements are not affected by database transaction handling. (For example, the rollback statement does not affect these statements.) These statements also cannot be called from a 3GL using the exec 4gl syntax.