Previous Topic: SYSIN and Stacks in Batch Mode

Next Topic: GoalNet

Work Stacks

When using stacks, it is sometimes useful for a subroutine to be able to obtain a new work stack, use it, and then delete it, returning the environment to exactly the state it was in when the subroutine was called.

Example: Work Stack Usage

The work stack is made the current stack so that REXX instructions such as PUSH, PULL, QUEUE, and so on can operate on it. Access to other stacks (those created by the calling IMOD) can be gained by using the extended functions, PUSH(), PULL(), QUEUE(), and so on.

entry_pt:
orig = swapstak()        /* obtain existing current stack id */
work = swapstak('new')   /* obtain an empty stack; make it   */
                         /* the current stack                */
processing …
…
x = swapstak('delete')   /* eliminate work stack             */
x = swapstak(orig)       /* return environment to the        */
                         /* original stack                   */
return