COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

argument
is an alphabetic, alphanumeric, integer, or numeric argument. If you specify more than one
argument, they must all be of the same class. Integer and numeric arguments can be mixed,
because integers are of the class numeric.
argument can be an array; for example,
FUNCTION ORD-MAX (ARRAY1(ALL))
returns the ordinal number of the largest element of the array ARRAY1.
The returned value is the ordinal number of the argument with the greatest value (according to
the rules for evaluating simple conditions). If more than one argument has the same greatest
value, the returned value is the ordinal number of the leftmost argument with that value. The
returned value is at least one.
Example 208 ORD-MAX Function
Code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NUMERIC-ARRAY.
05 PICTURE 9(1) VALUE 4.
05 PICTURE 9(1) VALUE 9.
05 PICTURE 9(1) VALUE 3.
05 PICTURE 9(1) VALUE 7.
05 PICTURE 9(1) VALUE 5
01 NUM-ARRAY REDEFINES NUMERIC-ARRAY.
05 NUM OCCURS 5 TIMES PICTURE 9(1).
01 ALPHABETIC-ARRAY.
05 PICTURE X(5) VALUE "dog".
05 PICTURE X(5) VALUE "cat".
05 PICTURE X(5) VALUE "horse".
05 PICTURE X(5) VALUE "sheep".
05 PICTURE X(5) VALUE "goat".
01 ALPHA-ARRAY REDEFINES ALPHABETIC-ARRAY.
05 ALPHA OCCURS 5 TIMES PICTURE X(5).
PROCEDURE DIVISION.
DISPLAY FUNCTION ORD-MAX (NUM(ALL))
DISPLAY FUNCTION ORD-MAX (ALPHA(ALL))
DISPLAY FUNCTION ORD-MAX (NUM(1) NUM(4))
DISPLAY FUNCTION ORD-MAX (ALPHA(3) "bird" "fish")
DISPLAY FUNCTION ORD-MAX (3.4 5 6.2 9)
Output:
0000000002
0000000004
0000000002
0000000001
0000000004
ORD-MIN Function
ORD-MIN, an integer function, returns the ordinal number of its minimum argument.
ORD-MIN Function 683