OPEN AND CLOSE (OPEN AND CLOSE A FILE)


In Example 11.2, the HELPTEXT file is defined on line 1 as a combined, full-procedural, workstation file. Also, the file HELPTEXT is a user-controlled file open. The USROPN keyword indicates that the file is opened by the program code (not by the RPG cycle). The USROPN isn't required for the OPEN or CLOSE operations to be used on a file after the file is opened by RPG. Therefore, when a file is opened by RPG (i.e., the USROPN keyword is not specified) and then closed with the CLOSE operation, the OPEN operation should successfully open the file.

Example 11.2: Open and close a workstation file.

start example
 .....FFileName++IFEASFRlen+LKeylnKFDevice+.Functions++++++++++++++++++++++++++++ 0001 FHELPTEXT  CF   E             WORKSTN USROPN .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq.... 0002 C                   OPEN      HELPTEXT 73 0003 C                   EVAL      IOError = *IN73 0004 C                   IF        NOT (IOError) 0005 C                   EXFMT     HELPRECD      C                     .      C                     .      C                     . 0006 C                   CLOSE     HELPTEXT 0007 C                   ENDIF 
end example

Line 2 opens the file HELPTEXT. Line 6 closes the file HELPTEXT.

Remember, if the OPEN operation attempts to open a file that has already been opened, an error occurs. Resulting indicator 2, if it is specified, is set on. If the CLOSE operation attempts to close a file that is already closed, an error occurs. Resulting indicator 2, if it is specified, is set on. *ALL can be specified for factor 2. When *ALL is specified, all open files are closed by the operation.




The Modern RPG IV Language
The Modern RPG IV Language
ISBN: 1583470646
EAN: 2147483647
Year: 2003
Pages: 156
Authors: Robert Cozzi

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net