RANGE Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
RANGE Function
The RANGE function returns a value that is equal to the value of the
maximum parameter minus the value of the minimum parameter. The function
type is either integer or numeric depending on the type of the
parameters, as follows:
Parameter Type Function Type
All parameters integer Integer
Numeric (some parameters may be Numeric
integer)
Syntax
FUNCTION RANGE ({parameter-1}...)
Parameters
parameter-1 Must be class numeric.
Return Value
The returned value is equal to the greatest value of parameter-1 minus
the least value of parameter-1. The comparisons used to determine the
greatest and least values are made according to the rules for simple
conditions. See the section "Simple Conditions" in Chapter 8 for
additional information.
Example
01 TAB.
05 ELEMENT PIC S999V99
OCCURS 4 TIMES VALUE ZERO.
01 NUM-RANGE PIC S999V99 VALUE ZERO.
:
MOVE 1.25 TO ELEMENT (1).
MOVE 3.50 TO ELEMENT (2).
MOVE 8.75 TO ELEMENT (3).
MOVE 0.25 TO ELEMENT (4).
COMPUTE NUM-RANGE = FUNCTION RANGE (1, 7, 9, 23, 85).
DISPLAY NUM-RANGE.
COMPUTE NUM-RANGE = FUNCTION RANGE ( ELEMENT (ALL) ).
DISPLAY NUM-RANGE.
The above example displays the following:
+084.00
+008.50
MPE/iX 5.0 Documentation