SETGRC command

From m204wiki
Revision as of 01:05, 28 February 2013 by Alex (talk | contribs) (Automatically generated page update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Privileges
Any user
Function
Sets a global variable return code according to the presence or absence of counting errors in the execution of the preceding command

Syntax

SETGRC [rcname] [errstringname]

Where:

rcname is a global variable that holds the return code.
errstringname is a global variable that holds the string of the error message associated with the counting error. If multiple messages are issued as a result of the cascade effect of the initial error, the initial error message is retrieved.

Example

In the following example, SETGRC is followed by IF commands that test the success or failure of SETGRC and include different procedures depending on the value of the SETGTRC return code variable:

COPY PROC ALL TO FILEA SETGRC XRC XMSG IF XRC = 0, YES.PROC IF XRC = 1, NO.PROC

If the value of XRC is 1, the procedure NO.PROC, which does error processing and other recovery work, is included:

PROC NO.PROC BEGIN PRINT 'COPY PROC FAILED - ' WITH $GETG('XMSG') . . . error processing work . . . END END PROCEDURE

If the value of XRC is 0, the procedure YES.PROC is included:

PROC YES.PROC BEGIN PRINT 'PROCEDURES COPIED SUCCESSFULLY' . . . continue doing next logical work . . . END END PROCEDURE

Similarly, you can follow SETGRC with a request that executes different User Language statements depending on the value in the global variable:

COPY PROC ALL TO FILEA SETGRC YRC YMSG BEGIN IF $GETG('YRC') THEN PRINT 'COPY PROC FAILED - ' WITH $GETG('YMSG') . . . other error processing statements . . . ELSE PRINT 'COPY PROC RAN SUCCESSFULLY - PROCESSING CONTINUED' END IF

Usage notes

Use SETGRC to test for the success or failure of Model 204 command execution when you are working in User Language.

If there are no counting errors in the execution of the preceding command, SETGRC sets a global variable to 0. If there are counting errors, SETGRC sets a global variable to 1.