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.

ExamplesThe following example demonstrates how the value of $STACK is incremented as newcontexts are create and decremented as contexts are exited.The sample code is as follows:STAWRITE !,"Context level in routine STA = ",$STACKDO AWRITE !,"Context level after routine A = ",$STACKQUITAWRITE !,"Context level in routine A = ",$STACKDO BWRITE !, "Context level after routine B = ",$STACKQUITBWRITE !,"Context level in routine B = ",$STACKXECUTE "WRITE !,""Context level in XECUTE = "",$STACK"WRITE !,"Context level after XECUTE = ",$STACKQUITA sample session using this code might run as follows:USER>DO ^STAContext level in routine STA = 1Context level in routine A = 2Context level in routine B = 3Context level in XECUTE = 4Context level after XECUTE = 3Context level after routine B = 2Context level after routine A = 1NotesContext levels in Application Mode and Programmer ModeA routine that is invoked in application mode starts at a different context level than a routineinvoked from the programmer mode prompt with a DO command. The DO command typedat the programmer mode prompt causes a new context to be created. The following exampleshows the routine START invoked in application mode and in programmer mode.Consider the following routine:START; Display the context level and exitWRITE !,"Context level in routine START is ",$STACKQUITWhen you run START in application mode, you see the following display:Context level in routine START is 0$STACK<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 447

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

Saved successfully!

Ooh no, something went wrong!