z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Passing Information Between a Routine and the Main Exec

z/OS TSO/E REXX User's Guide
SA32-0982-00

You can use the data stack to pass information from an exec to an external routine without using arguments. The exec pushes or queues the information on the stack and the routine pulls it off and uses it as in the following example.

Example of Using the Data Stack to Pass Information

/***************************** REXX ********************************/
/* This exec helps an inexperienced user allocate a new PDS.  It   */
/* prompts the user for the data set name and approximate size,    */
/* and queues that information on the data stack.  Then it calls   */
/* an external subroutine called newdata.                          */
/*******************************************************************/

 message = 'A data set name for a partitioned data set has three',
'qualifiers separated by periods.  The first qualifier is usually',
'a user ID.  The second qualifier is any name.  The third qualifier',
'is the type of data set, such as "exec".  Generally the user ID',
'is assumed, so you might specify a data set name as MYREXX.EXEC.',
'A new data set name cannot be the same as an existing data set',
'name.  Please type a name for the new data set or type QUIT to end.'

 SAY 'What is the new data set name?  If you are unsure about'
 SAY 'naming data sets, type ?.  To end, type QUIT.'

 PULL name
 DO WHILE (name = '?') | (name = 'QUIT')
   IF name = '?' THEN
     DO
       SAY message
       PULL name
     END
   ELSE
     EXIT
 END

 SAY 'Approximately how many members will the data set have:'
 SAY '6  12  18  24  30  36  42  48  54  60?'

 PULL number
 QUEUE name
 QUEUE number
 CALL newdata

 IF RESULT > 0 THEN
   SAY 'An error prevented' name 'from being allocated.'
 ELSE
   SAY 'Your data set' name 'has been allocated.'

Example of the External Subroutine NEWDATA

/***************************** REXX ********************************/
/* This external subroutine removes the data set name and the      */
/* number of members from the stack and then issues the ALLOCATE   */
/* command.                                                        */
/*******************************************************************/

 PULL name
 PULL number

 "ALLOCATE DATASET("name") NEW SPACE(50,20) DIR("number%6") DSORG(PO)",
 "RECFM(V,B) LRECL(255) BLKSIZE(5100)"

 RETURN RC    /* The return code from the TSO/E command sets the   */
              /* REXX special variable, RC, and is returned to the */
              /* calling exec. A 0 return code means no errors.    */

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014