11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

$ZTRAPMainNEW $ESTACKSET $ZTRAP="OnError"WRITE !,"$ZTRAP set to: ",$ZTRAPWRITE !,"Main $ESTACK= ",$ESTACK // 0WRITE !,"Main $ECODE= ",$ECODEDO SubAWRITE !,"Returned from SubA" // not executedWRITE !,"MainReturn $ECODE= ",$ECODEQUITSubAWRITE !,"SubA $ESTACK= ",$ESTACK // 1WRITE !,6/0 // Error: division by zeroWRITE !,"fine with me"QUITOnErrorWRITE !,"OnError $ESTACK= ",$ESTACK // 0WRITE !,"$ECODE= ",$ECODEQUITThe following example is identical to the previous example, with one exception: The $ZTRAPlocation is prefaced by an asterisk (*). When the error occurs in SubA, this asterisk causes<strong>Caché</strong> to call the OnError routine at the context level of SubA (where the error occurred),not at the context level of Main (where $ZTRAP was set). Therefore, when OnError completes,execution returns to Main at the line following the DO command.MainNEW $ESTACKSET $ZTRAP="*OnError"WRITE !,"$ZTRAP set to: ",$ZTRAPWRITE !,"Main $ESTACK= ",$ESTACK // 0WRITE !,"Main $ECODE= ",$ECODEDO SubAWRITE !,"Returned from SubA" // executedWRITE !,"MainReturn $ECODE= ",$ECODEQUITSubAWRITE !,"SubA $ESTACK= ",$ESTACK // 1WRITE !,6/0 // Error: division by zeroWRITE !,"fine with me"QUITOnErrorWRITE !,"OnError $ESTACK= ",$ESTACK // 1WRITE !,"$ECODE= ",$ECODEQUITSee Also• ZQUIT command• ZINSERT command• $ETRAP special variable• $ECODE special variable• $ESTACK special variable• $STACK special variable<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 497

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

Saved successfully!

Ooh no, something went wrong!