Summary of Intrinsic Functions
This summarizes the intrinsic functions that are available in P3/COBOL. It is essentially a superset of the 1985 standard functions incorporating additional functions available on other common COBOL dialects and some unique to this COBOL. Many of the additional functions are compiled by P3/COBOL for syntax checking purposes in the editor, but are not currently implemented.
The implementation markers in this table follow the compiler's intrinsic-function registry. A function marked with footnote 1 is recognized for syntax checking but is not implemented by the runtime. Functions without that marker are implemented.
For background on national argument and result types, conversion between DISPLAY and national data, and national
collating sequences, see National Data in P3/COBOL.
The Arguments column defines argument type and the Type column defines the type of the function, as follows:
| Argument | Type |
|---|---|
| Alph | means alphabetic |
| Anum | means alphanumeric Bool means boolean |
| Ind | means index |
| Int | means integer |
| Key | means a keyword |
| Nat | means national |
| Num | means numeric |
| Ord | means an ordering table |
| Ptr | means pointer |
| Type | means a type declaration |
| Arg or Args | means the type of the argument or arguments, respectively |
Num in the arguments column includes Int. Both Int and Num are listed in the arguments column when the type of the argument determines the type of the function.
Anum in the arguments column includes strongly-typed group items. When the type of the argument determines the type of the function, the function is an alphanumeric function when any of the arguments is strongly-typed, even when all the arguments of the function are of the same type.
In the Arguments column, the following conventions apply:
- A digit immediately following the argument type indicates the argument's position in the list of arguments.
- If more than one argument type may appear in a given position, they are separated by the word 'or'.
- If an argument in a given position in the list may consist of more than one component, the components are separated by the word 'and'.
- Commas are used only to separate an argument from the next argument in the argument list.
For example, the sequence 'Alph1 or Anum1 or Nat1, Alph2 or Anum2 or Nat2 or Key2 or Key2 and Loc2, Key3' in the 'Arguments' column is to be interpreted as follows:
- The first argument is alphabetic, alphanumeric, or national.
- The second argument is alphabetic, alphanumeric, national, a keyword alone, or a keyword with a locale specification.
- The third argument is a keyword.
The 'Value returned' column gives a synopsis of the value returned; additional details are specified in the definition of the function.
| Name | Argument(s) | Type | Value returned |
|---|---|---|---|
| ABBREVIATE | Anum1 or Nat1 | Arg | The abbreviated value of argument-1 |
| ABS | Int1 or Num1 | Arg | The absolute value of argument-1 |
| ACOS | Num1 | Num | Arccosine of argument-1 |
| ADDR | Alph1 ... or Anum1 ... or Ind1 ... or Int1 ... or Nat1 ... or Num1 ... | Ptr | Address of the argument-1 (as a P3/COBOL pointer) |
| ANNUITY | Num1, Int2 | Num | Ratio of annuity paid for argument-2 periods at interest of argument-1 to initial investment of one |
| ATAN | Num1 | Num | Arctangent of argument-1 |
| ASIN | Num1 | Num | Arcsine of argument-1 |
| BOOLEAN-OF-INTEGER1 | Int1, Int2 | Bool | A boolean item representing the binary value equivalent of the numeric value in argument-1 |
| BYTE-LENGTH | Any | Int | Length of argument-1 in number of bytes |
| CHAR | Int1 | Anum | Character in position argument-1 of the alphanumeric program collating sequence |
| CHAR-NATIONAL | Int1 | Nat | Character in position argument-1 of the national program collating sequence |
| COMBINED-DATETIME | Int1, Num2 | Num | Numeric representation of combined integer date and standard numeric time |
| COS | Num1 | Num | Cosine of argument-1 |
| CURRENT-DATE | Anum | Current date and time and local time differential | |
| DATE-OF-INTEGER | Int1 | Int | Standard date equivalent (YYYYMMDD) of integer date in argument-1 |
| DATE-TO-YYYYMMDD | Int1, Int2, Int3 | Int | Argument-1 converted from YYMMDD to YYYYMMDD based on the values of argument-2 and argument-3 |
| DATEVAL12 | Int1 or Anum1 | Arg | The date value of argument-1 |
| DAY-OF-INTEGER | Int1 | Int | Julian date equivalent (YYYYDDD) of integer date in argument-1 |
| DAY-TO-YYYYDDD | Int1, Int2, Int3 | Int | Argument-1 converted from YYDDD to YYYYDDD based on the values of argument-2 and argument-3 |
| DISPLAY-OF | Nat1, Alph2 or Anum2 | Anum | Usage display representation of argument argument-1. Argument-2, if specified, is an alphanumeric character to be used when no alphanumeric character corresponds to a national character in argument-1 |
| E | Num | The value of e, the natural base | |
| ESCAPE-PATTERN | Anum1 or Nat1 | Nat | Escapes argument-1 string for use as regular expression matching the argument-1 string |
| EXCEPTION-FILE | Anum | Information about the file exception that raised an exception | |
| EXCEPTION-FILE-N | Nat | Information about the file exception that raised an exception | |
| EXCEPTION-LOCATION1 | Anum | Implementor-defined location of exception | |
| EXCEPTION-LOCATION-N1 | Nat | Implementor-defined location of exception | |
| EXCEPTION-STATEMENT1 | Anum | Name of statement causing an exception | |
| EXCEPTION-STATUS1 | Anum | Exception-name identifying last exception | |
| EXP | Num1 | Num | e raised to the power argument-1 |
| EXP10 | Num1 | Num | 10 raised to the power argument-1 |
| FACTORIAL | Int1 | Int | Factorial of argument-1 |
| FORMATTED-CURRENT-DATE | Anum1 or Nat1 | Arg | Formatted date equivalent of current date and time in the format specified in argument-1 |
| FORMATTED-DATE | Anum1 or Nat1, Int2 | Arg | Formatted date equivalent of integer date contained in argument-2 in the format specified in argument-1 |
| FORMATTED-DATETIME | Anum1 or Nat1, Int2, Num3, Int4 | Arg | Formatted date (from integer date in argument-2) and time (from standard numeric time in argument-3) in the format specified by argument-1. Offset from UTC, if the format Int4 requires it, is supplied by argument-4 |
| FORMATTED-TIME | Anum1 or Nat1, Num2, Int3 | Arg | Formatted time equivalent of standard numeric time contained in argument-2 in the format specified in argument-1. Offset from UTC, if the format requires it, is supplied by argument-3 |
| FRACTION-PART | Num1 | Num | Fraction part of argument-1 |
| HEX-OF | Anum1 or Nat1 | Nat | String represention of argument-1 as hexadecimal digits |
| HIGHEST-ALGEBRAIC1 | Anum1 or Int1 or Nat1 or Num1 | Int Num | Greatest algebraic value that may be represented in argument-1 |
| INTEGER | Num1 | Int | The greatest integer not greater than argument-1 |
| INTEGER-OF-BOOLEAN1 | Bool1 | Int | The numeric value of a BINARY-DOUBLE item whose bit configuration is the same as argument-1, right-justified |
| INTEGER-OF-DATE | Int1 | Int | Integer date equivalent of standard date (YYYYMMDD) in argument-1 |
| INTEGER-OF-DAY | Int1 | Int | Integer date equivalent of Julian date (YYYYDDD) in argument-1 |
| INTEGER-OF-FORMATTED-DATE | Anum1 or Nat1, Anum2 or Nat2 | Int | Integer date equivalent of date contained in argument-2 whose format is described by argument-1 |
| INTEGER-PART | Num1 | Int | Integer part of argument-1 |
| LENGTH | Alph1 or Anum1 or Bool1 or Ind1 or Nat1 or Num1 or Type1 | Int | Length of argument-1 in number of character positions or number of boolean positions |
| LOCALE-COMPARE1 | Alph1, Anum1 or Nat1, Alph2, Anum2 or Nat2, Loc3 | Anum | A character indicating the result of comparing argument-1 to argument-2 using an ordering defined by a locale specified by argument-3 |
| LOCALE-DATE1 | Anum1 or Nat1, Loc2 | Anum | A character string containing a date specified by argument-1 in a format specified by argument-2 and a locale |
| LOCALE-TIME1 | Anum1 or Nat1, Loc2 | Anum | A character string containing a time specified by argument-1 in a format specified by a locale |
| LOCALE-TIME-FROM-SECONDS1 | Num1, Loc2 | Anum | A character-string containing a time specified by argument-1, in a format specified by a locale specified by argument-2 |
| LOG | Num1 | Num | Natural logarithm of argument-1 |
| LOG10 | Num1 | Num | Logarithm to base 10 of argument-1 |
| LOWER-CASE | Alph1 or Anum1 or Nat1 | Arg | A character string with any uppercase letters in argument-1 set to lowercase |
| LOWEST-ALGEBRAIC1 | Anum1 or Int1 or Nat1 or Num1 | Int Num | Lowest algebraic value that may be represented in argument-1 |
| MAX | Alph1 ... or Anum1 ... or Ind1 ... or Int1 .... or Nat1 ... or Num1 ... | Args | Value of maximum argument |
| MEAN | Num1 ... | Num | Arithmetic mean of arguments |
| MEDIAN | Num1 ... | Num | MediaMean of minimum and maximum arguments |
| MIN | Alph1 ... or Anum1 ... or Ind1 ... or Int1 ... or Nat1 ... or Num1 ... | Args | Value of minimum argument |
| MOD | Int1, Int2 | Int | argument-1 modulo argument-2 |
| NATIONAL-OF | Alph1 or Anum1, Nat2 | Nat | Usage national representation of argument-1. Argument-2, if specified, is a national character to be used when no national character corresponds to an alphanumeric character in argument-1 |
| NUMVAL | Anum1 or Nat1 | Num | Numeric value of simple numeric string contained in argument-1 |
| NUMVAL-C | Anum1 or Nat1, Anum2 or Nat2 or Key2 and Loc2, Key3 | Num | Numeric value of numeric string with optional currency sign and commas contained in argument-1. If specified, argument-2 is either a specified currency sign or a locale specification, and argument-3 specifies case insensitivity |
| NUMVAL-F | Anum1 or Nat1 | Num | Numeric value of numeric string representing a floating-point number contained in argument-1 |
| ORD | Alph1 or Anum1 or Nat1 | Int | Ordinal position of argument-1 in collating sequence |
| ORD-MAX | Alph1 ... or Anum1 ... or Ind1 .... or Nat1 ... or Num1 ... | Int | Ordinal position of maximum argument |
| ORD-MIN | Alph1 ... or Anum1 ... or Ind1 ... or Nat1 ... or Num1 ... | Int | Ordinal position of minimum argument |
| PI | Num | The value of π | |
| PRESENT-VALUE | Num1, Num2 ... | Num | Present value of a series of future period-end amounts, argument-2, at a discount rate of argument-1 |
| RANDOM | Int1 | Num | Random number; optional argument-1 specifies seed value |
| RANGE | Int1 ... or Num1 ... | Arg | Value of maximum argument minus value of minimum argument |
| REM | Num1, Num2 | Num | Remainder of division of argument-1 by argument-2 |
| REVERSE | Alph1 or Anum1 or Nat1 | Arg | Reverse order of the characters of argument-1 |
| SECONDS-FROM-FORMATTED-TIME | Anum1 or Nat1, | Num | Standard numeric time equivalent of the data contained in argument-2 as described by the format specified in argument-1 |
| SECONDS-PAST- MIDNIGHT | Num | Seconds past midnight as provided by the system | |
| SIGN | Num1 | Int | The sign of argument-1 |
| SIN | Num1 | Num | Sine of argument-1 |
| SQRT | Num1 | Num | Square root of argument-1 |
| STANDARD-COMPARE1 | Alph1 or Anum1 or Nat1, Alph2 or Anum2 or Nat2, Ord3, Int4 | Anum | A character indicating the result of comparing argument-1 to argument-2 using the ordering specified by argument-3 at the comparison level specified by argument-4 |
| STANDARD-DEVIATION | Num1 ... | Num | Standard deviation of arguments |
| SUM | Int1 ... or | Args | Sum of arguments |
| TAN | Num1 | Num | Tangent of argument-1 |
| TEST-DATE-YYYYMMDD1 | Int1 | Int | 0 if argument-1 is a valid standard date; otherwise identifies the sub-field in error |
| TEST-DAY-YYYYDDD1 | Int1 | Int | 0 if argument-1 is a valid Julian date; otherwise identifies the sub-field in error |
| TEST-FORMATTED-DATETIME1 | Anum1 or Nat1, Anum2 or Nat2 | Int | 0 if argument-2 conforms in form to the format specified error in argument-1 and represents a valid date, time or combined representation according to that description; otherwise, identifies the character in |
| TEST-NUMVAL | Anum1 or Nat1 | Int | 0 if argument-1 conforms to the requirements of the NUMVAL function; otherwise identifies the character in error |
| TEST-NUMVAL-C | Anum1 or Nat1, Alph2 or Anum2 or Nat2 or Key2 or Key2 and Loc2, Key3 | Int | 0 if argument-1 conforms to the requirements of the NUMVAL-C function; otherwise, identifies the character position in error. Argument-2 specifies either a currencysign or a locale specification, and argument-3 specifies case insensitivity |
| TEST-NUMVAL-F1 | Anum1 or Nat1 | Int | 0 if argument-1 conforms to the requirements of the NUMVAL-F function; otherwise identifies the character in |
| TIME-MILLI | Int | The time in milliseconds since the beginning of epoch | |
| TIME-NANO | Int | The time in nanoseconds since the beginning of epoch | |
| TRIM | Alph1 or Anum1 or Nat1, Key2 | Args | The value of argument-1 with leading spaces, trailing spaces, or both, deleted. |
| UNDATE12 | Int1 or Anum1 | Arg | The non-date value of a date-type argument-1 |
| UPPER-CASE | Alph1 or Anum1 or Nat1 | Arg | A character string with any lowercase letters in argument-1 set to uppercase |
| VARIANCE | Num1 ... | Num | Variance of argument-1 |
| WHEN-COMPILED | Anum | Date and time compilation unit was compiled | |
| YEAR-TO-YYYY | Int1, Int2, Int3 | Int | Argument-1 converted from YY to YYYY based on the values of argument-2 and argument-3 a A function that has only alphabetic arguments is type alphanumeric. |
| YEARWINDOW12 | Int | Starting year number of the current century window |
1 This function is recognized for syntax checking, but is not implemented by the runtime at this time.
2 The function definition follows IBM COBOL for z/OS with the NODATEPROC option in effect.