What Is the Input Source?

The PUTGET service routine obtains a line of input from either:
  • The REXX data stack
  • The input source described by the topmost element of the input stack.
A command processor executing in a REXX exec can use the data stack to communicate with the user using PUTGET in one of two methods:
  • With PUTGET prompt message processing, for example:
    /* rexx */
    x = prompt('on')      /* Prompting must first be enabled                 */
    queue "DISPLAY"       /* Responds to the prompt for an action            */
    address tso "ALTLIB"  /* Command processor that needs a prompt satisfied */
  • With PUTGET mode message processing, for example:
    /* rexx */
    queue "ALTLIB DISPLAY" /* Queued for later execution                     */
    queue "PROFILE"        /* Queued after the above command                 */
    exit                   /* Leave the exec and execute commands            */

In each of these cases, if you do not specify either the ATTN or TERM operand, PUTGET obtains input from the REXX data stack first, if there are elements on the REXX data stack, and if the topmost element on the input stack is either a terminal element or a barrier element. When PUTGET has processed all lines of input on the data stack, it then obtains input from the terminal.

When the topmost element on the input stack is an in-storage list element (including a command procedure), PUTGET obtains input from the source indicated by the in-storage list element. This ensures compatibility with applications that are not sensitive to the REXX data stack (for example, a CLIST invoked from within a REXX exec).

When you specify PUTGET with the TERM operand, PUTGET obtains input from the REXX data stack first, if there are elements on the REXX data stack. If there are no elements on the REXX data stack, PUTGET returns input from the terminal.

When you specify PUTGET with the ATTN operand, the input source is the terminal.

A command processor can determine the source of input with which PUTGET will satisfy an input request according to the following procedure:
  1. If you specify PUTGET OUTPUT=ATTN, the input is from the terminal.
  2. If you specify PUTGET OUTPUT=TERM, the input is from the REXX data stack (if elements exist on the REXX data stack), or from the terminal. To determine if elements exist on the REXX data stack, use step 4.
  3. Before you specify PUTGET without OUTPUT=ATTN or OUTPUT=TERM, first invoke the STACK macro with the INQUIRE=TYPE operand to determine the type of element on the top of the input stack.
    1. If the top element of the input stack is an in-storage list (for example, a command procedure), the source indicated by the in-storage list is the source of input.
    2. If the top element of the input stack is a barrier element that is not a NONEST barrier element (indicated by a decimal return code of 44 from STACK), the end of the substack has been reached. PUTGET returns a return code or considers the barrier a terminal element, depending on what was specified on the SUBSTACK operand. For more information on the SUBSTACK operand, see The Execute Form of the PUTGET macro instruction.
    3. If the top element of the input stack is a NONEST barrier element (indicated by a decimal return code of 80 from STACK) and if there are elements on the REXX data stack, the source of input is the REXX data stack. Otherwise, the NONEST barrier acts as a BARRIER=* element as described in step 3.b. To determine if elements exist on the REXX data stack, use step 4.
    4. If the top element of the input stack is a terminal element, the source of input is the REXX data stack (if there are elements on the REXX data stack), or the terminal. To determine if elements exist on the REXX data stack, use step 4.
  4. To determine if elements exist on the REXX data stack, invoke the REXX data stack replaceable routine, IRXSTK, with the QUEUED function. If the number of queued elements is greater than zero, elements exist on the REXX data stack. Otherwise, the source of input is the terminal.
    Note: If the source of input might be the REXX data stack, and if the command processor is invoked by a CLIST and a CLIST DATA-ENDDATA group exists, input is from the CLIST DATA-ENDDATA group.