NEWSTACK
creates a new data stack and basically hides or isolates the current data stack. Elements on the previous data stack cannot be accessed until a DELSTACK command is issued to delete the new data stack and any elements remaining in it.
The NEWSTACK command can be used in REXX execs that execute in both the TSO/E address space and non-TSO/E address spaces.
After an exec issues the NEWSTACK command, any element that is placed on the data stack with a PUSH or QUEUE instruction is placed on the new data stack. If an exec calls a routine (function or subroutine) after the NEWSTACK command is issued, that routine also uses the new data stack and cannot access elements on the previous data stack, unless it issues a DELSTACK command. If you issue a NEWSTACK command, you must issue a corresponding DELSTACK command to delete the data stack that NEWSTACK created.
When there are no more elements on the new data stack, PULL obtains information from the terminal (TSO/E address space) or the input stream (non-TSO/E address space), even though elements remain in the previous data stack (in non-TSO/E address spaces, the default input stream is SYSTSIN). To access elements on the previous data stack, issue a DELSTACK command. If a new data stack was not created, DELSTACK removes all elements from the original data stack.
For information about the PULL instruction, see PULL.
Multiple new data stacks can be created, but only elements on the most recently created data stack are accessible. To find out how many data stacks have been created, use the QSTACK command. To find the number of elements on the most recently created stack, use the QUEUED () built-in function.
If multiple language processor environments are chained together in a non-TSO/E address space and a new data stack is created with the NEWSTACK command, the new data stack is available only to execs that execute in the language processor environment in which the new data stack was created. The other environments in the chain cannot access the new data stack.
Examples
- To protect elements placed on the data stack from a subroutine that might also use the data
stack, you can use the NEWSTACK and DELSTACK commands as follows:
PUSH element1 PUSH element2 ⋮ "NEWSTACK" /* data stack 2 created */ CALL sub "DELSTACK" /* data stack 2 deleted */ ⋮ PULL stackelem ⋮ PULL stackelem EXIT
- To put elements on the data stack and prevent the elements from being used as prompts for a
TSO/E command, use the NEWSTACK command as follows:
"PROFILE PROMPT" x = PROMPT("ON") PUSH elem1 PUSH elem2 "NEWSTACK" /* data stack 2 created */ "ALLOCATE" /* prompts the user at the terminal for input. */ ⋮ "DELSTACK" /* data stack 2 deleted */
- To use MVS™ batch to execute an exec named ABC, which is a
member in USERID.MYREXX.EXEC, use program IRXJCL and include the exec name after the PARM parameter
on the EXEC statement.
//MVSBATCH EXEC PGM=IRXJCL, // PARM='ABC' //SYSTSPRT DD DSN=USERID.IRXJCL.OUTPUT,DISP=OLD //SYSEXEC DD DSN=USERID.MYREXX.EXEC,DISP=SHR
Exec ABC creates a new data stack and then put two elements on the new data stack for module MODULE3."NEWSTACK" /* data stack 2 created */ PUSH elem1 PUSH elem2 ADDRESS LINK "module3" ⋮ "DELSTACK" /* data stack 2 deleted */ ⋮