Use REXX for simple lists

This describes the format in which elements in a simple list are passed when a command is run using REXX.

When the same command is run, the elements in a simple list are passed to the REXX procedure in the argument string in the following format where valueN is the last value in the simple list.:
 . . . USER(value1 value2 
 . . . valueN) . . .

For example, if two user names (BJONES and TBROWN) are specified for the USER parameter, the following is passed:

 . . . USER(BJONES 
TBROWN) . . .

When a simple list is passed, only the number of elements specified on the command are passed. Therefore, when the CPP processes a simple list, it uses the number of elements passed to determine how many elements can be processed.

The REXX example below produces the same result as the CL procedure in Example: Create a command:

Figure 1. REXX Simple List Example
        .
        .
        .
        PARSE ARG . 'USER(' user ')' .
        .
        .
        CT = WORDS(user)
        IF CT > 0 THEN user1 = WORD(user,1) else user1 = '
        IF CT > 1 THEN user2 = WORD(user,2) else user2 = '
        IF CT > 2 THEN user3 = WORD(user,3) else user3 = '
        IF CT > 3 THEN user4 = WORD(user,4) else user4 = '
        IF CT > 4 THEN user5 = WORD(user,5) else user5 = '
        IF CT > 5 THEN
          DO
            /* If CT is greater than 5, the values passed
               is greater than the program expects, and error
               logic should be performed */
        .
        .
        .
          END
        ELSE
          DO
            /* The correct number of values are passed
               and the program can continue processing */
          END
        EXIT

This same procedure can be used to process other lists in a REXX program.

For a simple list, a single value such as *ALL or *NONE can be entered on the command instead of the list. Single values are passed as an individual value. Similarly, if no values are specified for a parameter, the default value, if any is defined, is passed as the only value in the list. For example, if the default value *ALL is used for the USER parameter, the following is passed:

 . . . USER(*ALL) . . .

If no default value is defined for an optional simple list parameter, the following is passed:

 . . . USER() . . .
Related information
REXX/400 Programmer's Guide PDF
REXX/400 Reference PDF