CHKOBJ2 CHECK OBJECT 2 TAAOBJP |
The Check Object 2 command is similar to the system command CHKOBJ
except that CHKOBJ2 sends an escape message if the object 'is found'.
The intent of the command is to simplify coding when it is considered
an error if the object exists. A similar function to check for a
member in existence is done by the CHKMBR2 tool.
CHKOBJ2 sends message ID TAA9891 as an escape message if the object
exists. If the object does not exist, no message is sent.
CHKOBJ2 internally issues the CHKOBJ command. All other escape
messages from CHKOBJ are resent.
A typical solution would be:
CHKOBJ2 OBJ(FILEA) OBJTYPE(*FILE)
MONMSG MSGID(TAA9891) EXEC(DO) /* File exists */
/* */
/* Your coding for the file exists */
/* */
ENDDO /* File exists */
Using CHKOBJ, the coding would be as follows:
CHKOBJ OBJ(FILEA) OBJTYPE(*FILE)
MONMSG MSGID(CPF9801) EXEC(DO) /* No file */
RCVMSG MSGTYPE(*EXCP) /* Remove the escape */
GOTO ENDCHK
ENDDO /* No file */
/* */
/* Your coding for the file exists */
/* */
ENDCHK: /* File exists */
Note that with the CHKOBJ solution, you have to branch around the
code that the application considers an error. The GOTO with label
solution operates correctly, but can also be a cause of coding
errors. CHKOBJ2 allows you to code the condition more normally.
Command parameters *CMD
------------------
OBJ The qualified object name. The library value
defaults to *LIBL. *CURLIB may also be specified.
OBJTYPE The object type to be checked. Any value that is
valid on CHKOBJ may be used.
Restrictions
------------
None.
Prerequisites
-------------
None.
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
CHKOBJ2 *CMD TAAOBJP QATTCMD
TAAOBJPC *PGM CLP TAAOBJPC QATTCL
|
Added to TAA Productivity tools April 1, 1995