11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Caché</strong> <strong>ObjectScript</strong> Special Variables$ETRAPContains a string of <strong>Caché</strong> <strong>ObjectScript</strong> commands to be executed when an error occurs.$ETRAP$ETDescription$ETRAP contains a string that specifies one or more <strong>Caché</strong> <strong>ObjectScript</strong> commands that areexecuted when an error occurs.You use the SET command to give $ETRAP the value of a string that contains one or more<strong>Caché</strong> <strong>ObjectScript</strong> commands. Then, when an error occurs, <strong>Caché</strong> executes the commandsyou entered into $ETRAP. For example, suppose you set $ETRAP to a string that containsa GOTO command to transfer control to an error-handling routine:SET $ETRAP="GOTO LOGERR^ERRROU"<strong>Caché</strong> then executes this command in $ETRAP immediately following any <strong>Caché</strong> <strong>ObjectScript</strong>command that generates an error condition. <strong>Caché</strong> executes the $ETRAP command(s) at thesame context level in which the error condition occurs.$ETRAP Commands Compared with XECUTE CommandsThe commands in a $ETRAP string are not executed in a new context level, unlike thecommands in an XECUTE string. In addition, the $ETRAP command string is always terminatedby an implicit QUIT command. The implicit QUIT command quits with a null-stringargument when the $ETRAP error-handling commands are invoked in a user-defined functioncontext where an argumented QUIT command is required.Setting $ETRAP Values in Different Context LevelsBy default, <strong>Caché</strong> carries the value of the $ETRAP special variable forward into new DO,XECUTE, and user-defined function contexts. However, you can create a new copy of$ETRAP in a context by issuing the NEW command, as follows:NEW $ETRAPWhenever you issue a NEW for $ETRAP, <strong>Caché</strong> performs the following actions:1. Saves the copy of $ETRAP that was in use at that point.2. Creates a new copy of $ETRAP.3. Assigns the new copy of $ETRAP the same value as the old, saved copy of $ETRAP.426 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!