%LIST (item { : item { : item ... } } )

%LIST returns a temporary array whose elements have the values of the items listed in its operands.

%LIST can be used in calculation expressions wherever an array can be used except:
  • SORTA
  • %ELEM
  • %LOOKUP
  • %SUBARR
Rules for %LIST:
  • An operand cannot be an array or a data structure.
  • The operands must all have a compatible type.
  • There must be at least one operand.
  • There is no practical limit to the number of operands.
  • If the operands have type Object, they must all be defined with the same class.
  • The data type of the array returned by %LIST depends on the data type of the operands. See Determining the Common Type of Multiple Operands.

Examples of %LIST

  • In the following example, the programmer is assigning data to an array.
    
    DCL-S colors VARCHAR(20) DIM(5);
    
    colors = %LIST('red' : 'blue' : 'yellow' : 'green': 'orange');
    
  • In the following example, the programmer is checking whether one of the items in the list has the value 'Y':
    
    
    IF 'Y' IN %LIST(hadError : notFound : alwaysReport);
       report (hadError : notFound : alwaysReport);
    ENDIF;
    
  • In the following example, the programmer is processing the elements in the list one at a time:
    
    DCL-S type VARCHAR(20);
    
    FOR-EACH type in %LIST(OVERDUE : PENDING : CANCELLED);
       printReport (type);
    ENDFOR;