Opens an operating system file for reading or writing.
OPEN {filename_lit|_var|_col} AS {filenum_num_lit|_var|_col} {FOR-READING|FOR-WRITING|FOR-APPEND} {RECORD=length_num_lit|_var|_col[:FIXED|:FIXED_NOLF|:VARY:BINARY]}] [STATUS=num_var]] [ENCODING={_var|_col|ASCII|ANSI|SJIS|JEUC|EBCDIC| EBCDIK290|EBCDIK1027|UCS-2|UTF-8|others... }]
The file name. The file name can be literal, variable, or column. This makes it easy to prompt for a file name at run time.
Number that identifies the file in the application. All file commands use the file number to reference the file. File numbers can be numeric variables as well as literals. The number can be any positive integer less than 64,000.
When a file is opened for reading, Production Reporting procures all data sequentially. Production Reporting does not allow for random access of information.
When a file is opened for writing, a new file is created. If a file of the same name already exists, it can be overwritten (this depends on the operating system).
When a file is opened in append mode, the current file contents are preserved. All data written is placed at the end of the file. Production Reporting creates the file if one does not already exist. For existing files, make sure the attributes used are the same as those used when the file was created. Failure to do this can produce unpredictable results.
For the VARY file type, this is the maximum size for a record. For the FIXED file type, this is the size of each record without the line terminator. For the FIXED_NOLF file type, this is the size of each record.
Defines that all records contained within the file are the same length. Terminate each record by a line terminator (system dependent). You can use this file type when writing or reading binary data.
Defines that all records contained within the file are the same length with no line terminators. When writing records, Production Reporting pads short records with blank characters to ensure each record is the same length. This file type can be used when writing or reading binary data.
Defines that the records can be of varying length. Each record is terminated by a line terminator (system-dependent). Only records containing display characters (no binary data) can be used safely. When reading records, any data beyond the maximum length specified is ignored. This is the default file type.
Sets the numeric variable to zero if OPEN succeeds and to -1 if it fails. Without the STATUS argument, a failure on OPEN causes Production Reporting to halt. By using a STATUS variable, you can control what processing should occur when a file cannot be opened.
Allows differently encoded files to be managed in a single run of Production Reporting. When no encoding is specified, Production Reporting uses the file input or output encoding specified in the INI file unless the file is UCS-2 encoded and auto-detection of UCS-2 files is enabled. Encoding is only allowed when converting to Unicode internally.
After a file is opened, it remains open until explicitly closed by the CLOSE command. A maximum of 256 files can be opened at one time.
open 'stocks.dat' as 1 for-reading record=100 open 'log.dat' as 5 for-writing record=70 open $filename as #j for-append record=80:fixed open $filename as 2 for-reading record=80:fixed_nolf open $filename as 6 for-reading record=132:vary status=#filestat if #filestat != 0 ... error processing ... end-if