OPENTEMP |
|
|
The OPENTEMP statement creates and opens a temporary dynamic file by pathname, associating it with a file variable.
Format
OPENTEMP {pathname} {options} TO file.var {ON ERROR statement(s)} {THEN statement(s)} {ELSE statement(s)}
where
At least one of the THEN and ELSE clauses must be present.
A file opened by the OPENTEMP statement may be referenced using the file variable in subsequent statements that operate on the file. The file is opened for exclusive use by the QM session in which the OPENPATH statement is executed and remains open so long as the file variable remains intact. Overwriting this variable or discard of the variable on return from a subroutine will implicitly close the file. The file will be deleted automatically when it is closed.
The optional NON.TRANSACTIONAL clause indicates that updates to the file are not to be treated as part of any transaction within which they occur.
If the file is opened successfully, the THEN clause is executed. If the open fails the ELSE clause is executed and the STATUS() function may be used to determine the cause of the failure.
The ON ERROR clause is taken only in the case of serious errors such as damage to the file's internal control structures. The STATUS() function will contain an error number. If no ON ERROR clause is present, a fatal error results in an abort.
Examples
OPENTEMP "\TEMP\MYFILE" TO TEMP.F ELSE ABORT "Cannot open temporary file"
This statement opens a temporary file as pathname \TEMP\MYFILE. If the open fails, the program aborts with an error message.
OPENTEMP TO TEMP.F ELSE ABORT "Cannot open temporary file"
This statement opens a temporary file in the QM temporary directory. If the open fails, the program aborts with an error message.
See also: |