Ch 10. COBOL Functions [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation
HP COBOL II/XL Reference Manual
Chapter 10 COBOL Functions
This chapter describes the built-in COBOL functions and how to call them.
These functions were defined in 1989 by Addendum 1 of the ANSI COBOL '85
standard. The built-in functions provide the capability to reference a
data item whose value is derived automatically at the time of reference
during the execution of the program.
The following tables list and briefly describe each function:
Table 10-1. Date Functions
-----------------------------------------------------------------------------------------------
- Function - Type - Value Returned -
-----------------------------------------------------------------------------------------------
| CURRENT-DATE | Alphanumeric | Current date and time and difference from Greenwich Mean |
| | | Time. |
-----------------------------------------------------------------------------------------------
- DATE-OF-INTEGER - Integer - Standard date equivalent (YYYYMMDD) of integer date. -
-----------------------------------------------------------------------------------------------
- DAY-OF-INTEGER - Integer - Julian date equivalent (YYYYDDD) of integer date. -
-----------------------------------------------------------------------------------------------
- INTEGER-OF-DATE - Integer - Integer date equivalent of standard date (YYYYMMDDD). -
-----------------------------------------------------------------------------------------------
- INTEGER-OF-DAY - Integer - Integer date equivalent of Julian date (YYYYDDD). -
-----------------------------------------------------------------------------------------------
- WHEN-COMPILED - Alphanumeric - Date and time program was compiled. -
-----------------------------------------------------------------------------------------------
Table 10-2. String Functions
-----------------------------------------------------------------------------------------------
- Function - Type - Value Returned -
-----------------------------------------------------------------------------------------------
| CHAR | Alphanumeric | The character in a specified position of the program |
| | | collating sequence. |
-----------------------------------------------------------------------------------------------
- LENGTH - Integer - Length, in character positions, of the parameter. -
-----------------------------------------------------------------------------------------------
| LOWER-CASE | Alphanumeric | The same parameter with all uppercase letters replaced by |
| | | lowercase letters. |
-----------------------------------------------------------------------------------------------
- NUMVAL - Numeric - Numeric value of a simple numeric string. -
-----------------------------------------------------------------------------------------------
| NUMVAL-C | Numeric | Numeric value of a numeric string with optional commas and |
| | | currency sign. |
-----------------------------------------------------------------------------------------------
- ORD - Integer - Ordinal position of the parameter in collating sequence. -
-----------------------------------------------------------------------------------------------
- REVERSE - Alphanumeric - Same parameter with characters in reverse order. -
-----------------------------------------------------------------------------------------------
| UPPER-CASE | Alphanumeric | Same parameter with all lowercase letters replaced by |
| | | uppercase letters. |
-----------------------------------------------------------------------------------------------
Table 10-3. General Functions
-----------------------------------------------------------------------------------------------
- Function - Type - Value Returned -
-----------------------------------------------------------------------------------------------
| MAX | Depends on | Maximum value of all parameters. |
| | parameters. | |
-----------------------------------------------------------------------------------------------
| MIN | Depends on | Minimum value of all parameters. |
| | parameters. | |
-----------------------------------------------------------------------------------------------
- ORD-MAX - Integer - Ordinal position of maximum parameter. -
-----------------------------------------------------------------------------------------------
- ORD-MIN - Integer - Ordinal position of minimum parameter. -
-----------------------------------------------------------------------------------------------
Table 10-4. Arithmetic Functions
-----------------------------------------------------------------------------------------------
- Function - Type - Value Returned -
-----------------------------------------------------------------------------------------------
| INTEGER | Integer | The greatest integer not greater than the given numeric |
| | | value. |
-----------------------------------------------------------------------------------------------
- INTEGER-PART - Integer - Integer part of the given numeric value. -
-----------------------------------------------------------------------------------------------
- LOG - Numeric - Natural logarithm of a numeric value. -
-----------------------------------------------------------------------------------------------
- LOG10 - Numeric - Logarithm to base 10 of a numeric value. -
-----------------------------------------------------------------------------------------------
- MOD - Integer - Modulo of two integer parameters. -
-----------------------------------------------------------------------------------------------
- RANDOM - Numeric - Pseudo-random number. -
-----------------------------------------------------------------------------------------------
- REM - Numeric - Remainder after division. -
-----------------------------------------------------------------------------------------------
- SQRT - Numeric - Square root of a numeric value. -
-----------------------------------------------------------------------------------------------
| SUM | Integer or | Sum of parameters. |
| | Numeric | |
-----------------------------------------------------------------------------------------------
Table 10-5. Financial and Statistical Functions
-----------------------------------------------------------------------------------------------
- Function - Type - Value Returned -
-----------------------------------------------------------------------------------------------
| ANNUITY | Numeric | Ratio of an annuity paid for a specified number of |
| | | periods at a specified interest rate, to an initial |
| | | investment of one. |
-----------------------------------------------------------------------------------------------
- FACTORIAL - Integer - Factorial of an integer value. -
-----------------------------------------------------------------------------------------------
- MEAN - Numeric - Arithmetic mean of parameters. -
-----------------------------------------------------------------------------------------------
- MEDIAN - Numeric - Median of parameters. -
-----------------------------------------------------------------------------------------------
- MIDRANGE - Numeric - Mean of smallest and largest parameters. -
-----------------------------------------------------------------------------------------------
| PRESENT-VALUE | Numeric | Present value of a series of future period-end amounts |
| | | at a given discount rate. |
-----------------------------------------------------------------------------------------------
| RANGE | Integer or | Value of largest parameter minus value of smallest |
| | Numeric | parameter. |
-----------------------------------------------------------------------------------------------
- STANDARD-DEVIATION - Numeric - Standard deviation of parameters. -
-----------------------------------------------------------------------------------------------
- VARIANCE - Numeric - Variance of parameters. -
-----------------------------------------------------------------------------------------------
Table 10-6. Trigonometric Functions
-----------------------------------------------------------------------------------------------
- Function - Type - Value Returned -
-----------------------------------------------------------------------------------------------
- COS - Numeric - Cosine of an angle in radians. -
-----------------------------------------------------------------------------------------------
- SIN - Numeric - Sine of an angle in radians. -
-----------------------------------------------------------------------------------------------
- TAN - Numeric - Tangent of an angle in radians. -
-----------------------------------------------------------------------------------------------
- ACOS - Numeric - Arccosine, in radians, of a numeric value. -
-----------------------------------------------------------------------------------------------
- ASIN - Numeric - Arcsine, in radians, of a numeric value. -
-----------------------------------------------------------------------------------------------
- ATAN - Numeric - Arctangent, in radians, of a numeric value. -
-----------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation