MF 

Perform Expressions

You can use parameterized sections with the PERFORM statement, and when the parameterized section includes a returning item, a 'functional perform' can be invoked.

General Format:

Perform expression parameterized sectoin

where argument-list is:

parameterized section argument list

Syntax Rules:

  1. An argument must be specified for each non-optional parameter in the parameterized section.
  2. Each argument must be compatible with the type of the corresponding parameter.
  3. The BY VALUE/REFERENCE type for each argument must be of the same type as that of the corresponding parameter. If neither BY VALUE nor BY REFERENCE is specified, then BY VALUE is assumed.
  4. If an argument is passed BY CONTENT, the parameterized section passing mode must specify BY REFERENCE, where the passed item is moved to a temporary buffer, so the contents of the original data item remains unchanged.
  5. When a section parameter specifies BY REFERENCE:
    • Typed arguments passed to the section must be of the same TYPEDEF as the parameter. The exception is if the TYPEDEF is a one-byte PIC X definition; in which case, a non-TYPEDEF'd PIC X of any size can be used.
    • Non-typed arguments passed to the section must be of the same definition as the parameter.
    • A passing literal argument must be BY REFERENCE or BY CONTENT.
    • Pointer arguments passed to the section BY VALUE must be of the same TYPEDEF.
  6. When a section parameter specifies BY VALUE:
    • Typed pointer arguments passed to the section must be of the same TYPEDEF as the parameter.
    • When both the argument and parameter are specified BY VALUE, move compatibility checks are performed as per The MOVE Statement.
  7. When passing a pointer argument BY VALUE to the section, the parameter can specify an alphanumeric type BY REFERENCE.
  8. When passing an alphanumeric type BY REFERENCE to the section, the section parameter can be a pointer.
  9. NETJVM  If a parameter defined in the parameterized section is a reference parameter of object type, then the corresponding argument specified in the perform statement must be of the same object type.
  10. NETJVM  If a parameter defined in the parameterized section is a value parameter of object type, then the corresponding argument specified in the perform statement must be of a compatible type; that is, an assignment must be possible from the type of the perform argument to the type of the section parameter.

General Rules:

  1. A parameterized section that specifies a returning value can be invoked as a function and used as a sending item in most contexts where the type of the returning item of the parameterized section is valid; exceptions to this include:
    • The :: and AT operators cannot be applied to a functional perform invocation that returns a typed pointer.
  2. Where you have multiple functional performs specified in the same statement, the order of evaluation is not guaranteed. If those functional performs use the same working-storage or local storage items, results may be undesirable.

Example:

The following functional perform statement executes the m2 parameterized section to provide a returning value to a local variable:
       declare i0 as binary-long = m2(4)
       display "i0 = " i0
       goback.
       m2 section (i1 as binary-long) returning ret as binary-long.
         compute ret = i1 + 1.