Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

ORD-MAX - Ordinal position of maximum argument

The ORD-MAX function returns an integer value that indicates which of the specified arguments, seen from left to right, contains the maximum value.
The type of this function is integer.

Format


FUNCTION ORD-MAX ({argument-1}...)


Arguments

  1. If more than one argument is specified, all arguments must be of the same class.

  2. argument-1 may not be of the class "object“ or "pointer".

Returned values

  1. The returned value is the ordinal number that indicates the position of the argument having the greatest value in the argument series.

  2. The comparisons used to determine the greatest valued argument are made according to the rules for simple conditions (see section "Conditions").

  3. If more than one argument has the same greatest value, the number returned corresponds to the position of the leftmost argument having that value.

  4. The error default value is 0.


See also:
        ORD-MIN, MAX, MIN

Example 9-34

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  R PIC 9(3).
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    COMPUTE R = FUNCTION ORD-MAX (13 4 9 18 5 7).
    DISPLAY R UPON T.
    STOP RUN. 

Result:               004
                          The fourth argument (18) has the greatest value.