Calling COBOL Functions [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
Calling COBOL Functions
To call any of the COBOL functions, simply put the function call in any
statement where a data item of the function type is valid. You must use
$CONTROL POST85 and the ANSI85 entry point to the HP COBOL II/XL compiler
when calling any COBOL function.
Examples
To change all the characters in a string to lower case, use the
LOWER-CASE function in a MOVE statement:
77 MY-NAME PIC X(5) VALUE "STEVE".
:
DISPLAY MY-NAME.
MOVE FUNCTION LOWER-CASE (MY-NAME) TO MY-NAME.
DISPLAY MY-NAME.
The above example displays the following:
STEVE
steve
To calculate the cosine of an angle, you can use the COS function in a
COMPUTE statement:
77 ANGLE-RADIANS PIC S99V9(5) VALUE 3.14159.
77 COS-OF-ANGLE PIC S9V9(5) VALUE ZERO.
:
COMPUTE COS-OF-ANGLE = FUNCTION COS (ANGLE-RADIANS).
DISPLAY ANGLE-RADIANS.
DISPLAY COS-OF-ANGLE.
The above example displays the following:
+03.14159
-0.99999
The rest of this chapter explains each of the COBOL functions.
MPE/iX 5.0 Documentation