Was this helpful?
OpenFile( )
Opens a file for writing.
Syntax
[returnfield =] [callproc] openfile(filename =
  filename
  [, filetype = type]
  [, filemode = mode]
  [, recordsize = size]
  [, delimiter = delim]
  , handle = byref(handle) | handle)
returnfield
Specifies the name of field to which the result is returned. Integer.
filename
Specifies the name of the file to be opened. The filename is a string expression containing the full path or a filename. filename is a string.The filename can be a logical name.
type
Specifies a type: text, binary, or stream. The default is text. type is a string. See File Types for a more detailed explanation of types.
mode
The value can be create, update, append or read. The default is read. mode is a string.
If the file does not exist, openfile( ) does not create a file unless the mode is create.
See File Modes for a more detailed explanation of modes.
size
Specifies the size, in bytes, of the records in the file. This parameter is optional and applies only to binary files. Integer.
If you do not specify size, 4GL calculates the record size based on the item list for the first read or write to the file.
The item list for each read or write must be the same size as the specified or calculated record size. If the total of the items is not the same as the record size, the read or write fails.
The record size is not stored when the file is closed and reopened.
delim
Specifies the delimiter used to separate data in a text file. It can be any printable character. The default is no delimiter.
handle
Specifies the file identifier used by the 4GL file access functions. Integer.
Description
The openfile() built-in function opens the specified file for reading or writing. The file must be on a local node.
The procedure returns 0 if the function completes without error.
Last modified date: 08/14/2024