General Formats (Cont.) [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation
Micro Focus COBOL Language Reference
General Formats (Cont.)
For ANS85: Intrinsic Functions (Cont.)
For ANS85 only: The ORD Function.
Description.
The ORD function returns an integer value that is the ordinal position of
argument-1 in the collating sequence for the program. The lowest ordinal
position is 1. The type of this function is integer.
General Format.
Argument.
Argument-1 must be one character in length and must be class alphabetic
or alphanumeric.
Returned Value.
The returned value is the ordinal position of argument-1 in the collating
sequence for the program.
For ANS85 only: The ORD-MAX Function.
Description.
The ORD-MAX function returns a value that is the ordinal number of the
argument-1 that contains the maximum value. The type of this function is
integer.
General Format.
Argument.
If more than one argument-1 is specified, all arguments must be of the
same class, except alphabetic and alphanumeric arguments which can be
mixed.
Returned Values.
1. The returned value is the ordinal number that corresponds to the
position of the argument-1 having the greatest value in the
argument-1 series.
2. The comparisons used to determine the greatest valued argument are
made according to the rules for simple conditions. See the
section Simple Conditions earlier in this chapter.
3. If more than one argument-1 has the same greatest value, the
number returned corresponds to the position of the leftmost
argument-1 having that value.
For ANS85 only: The ORD-MIN Function.
Description.
The ORD-MIN function returns a value that is the ordinal number of the
argument-1 that contains the minimum value. The type of this function is
integer.
General Format.
Argument.
If more than one argument-1 is specified, all arguments must be of the
same class, except alphabetic and alphanumeric arguments which may be
mixed.
Returned Values.
1. The returned value is the ordinal number that corresponds to the
position of the argument-1 having the lowest value in the
argument-1 series.
2. The comparisons used to determine the lowest valued argument are
made according to the rules for simple conditions. See the
section Simple Conditions earlier in this chapter.
3. If more than one argument-1 has the same lowest value, the number
returned corresponds to the position of the leftmost argument-1
having that value.
For ANS85 only: The PRESENT-VALUE Function.
Description.
The PRESENT-VALUE function returns a value that approximates the present
value of a series of future period-end amounts specified by argument-2 at
a discount rate specified by argument-1. The type of this function is
numeric.
General Format.
Arguments.
1. Argument-1 and argument-2 must be of the class numeric.
2. The value of argument-1 must be greater than -1.
Returned Values.
1. The returned value is an approximation of the summation of a
series of calculations with each term in the following form:
argument-2 / (1+argument-1) ** n
There is one term for each occurrence of argument-2. The
exponent, n, is incremented from one by one for each term in the
series.
2. Floating-point format is used for numeric non-integer results.
For ANS85 only: The RANDOM Function.
Description.
The RANDOM function returns a numeric value that is a pseudo-random
number from a rectangular distribution. The type of this function is
numeric.
General Format.
Arguments.
1. If argument-1 is specified, it must be zero or a positive integer.
It is used as the seed value to generate a sequence of
pseudo-random numbers.
2. If a subsequent reference specifies argument-1, a new sequence of
pseudo-random numbers is started.
3. For MF only: If the first reference to this function in the run
unit does not specify argument-1, the seed value of zero is used .
4. In each case, subsequent references without specifying argument-1
return the next number in the current sequence.
Returned Values.
1. The returned value is greater than or equal to zero and less than
one.
2. For a given seed value on a given implementation, the sequence of
pseudo-random numbers will always be the same.
3. The domain of argument-1 values will yield distinct sequences of
pseudo-random numbers. This subset includes the values from 0
through at least 32767.
4. Floating-point format is used for numeric non-integer results.
For ANS85 only: The RANGE Function.
Description.
The RANGE function returns a value that is equal to the value of the
maximum argument minus the value of the minimum argument. The type of
this function depends upon the argument types as follows:
Argument Type Function Type
---------------------------------------------------------------------------------------
All arguments integer Integer
Numeric Numeric
(some arguments can be integer)
General Format.
Argument.
Argument-1 must be class numeric.
Returned Values.
1. The returned value is equal to the greatest value of argument-1
minus the least value of argument-1.
2. The comparisons used to determine the greatest and least values
are made according to the rules for simple conditions. See the
section Simple Conditions earlier in this chapter.
3. If the value of argument-1 is numeric non-integer, results are
returned in floating-point format.
For ANS85 only: The REM Function.
Description.
The REM function returns a numeric value that is the remainder of
argument-1 divided by argument-2. The type of this function is numeric.
General Format.
Arguments.
1. Argument-1 and argument-2 must be class numeric.
2. The value of argument-2 must not be zero.
Returned Values.
1. The returned value is the remainder of argument-1 / argument-2.
It is defined as the expression:
argument-1 -(argument-2 * FUNCTION INTEGER-PART (argument-1
/ argument-2))
2. Floating-point format is used for numeric non-integer results.
For ANS85 only: The REVERSE Function.
Description.
The REVERSE function returns a character string whose length and
characters are exactly the same as argument-1, except that the characters
are in reverse order. The type of this function is alphanumeric.
General Format.
Argument.
Argument-1 must be class alphabetic or alphanumeric and must be at least
one character in length.
Returned Value.
If argument-1 is a character string of length n, the returned value is a
character string of length n such that for 1 j n, the character in
position j of the returned value is the character from position n-j+1 of
argument-1.
For ANS85 only: The SIN Function.
Description.
The SIN function returns a numeric value that approximates the sine of an
angle or arc, expressed in radians, that is specified by argument-1. The
type of this function is numeric.
General Format.
Argument.
Argument-1 must be class numeric.
Returned Values.
1. The returned value is the approximation of the sine of argument-1
and is greater than or equal to -1 and less than or equal to +1.
2. Floating-point format is used for numeric non-integer results.
For ANS85 only: The SQRT Function.
Description.
The SQRT function returns a numeric value that approximates the square
root of argument-1. The type of this function is numeric.
General Format.
Arguments.
1. Argument-1 must be class numeric.
2. The value of argument-1 must be zero or positive.
Returned Values.
1. The returned value is the absolute value of the approximation of
the square root of argument-1.
2. Floating-point format is used for numeric non-integer results.
For ANS85 only: The STANDARD-DEVIATION Function.
Description.
The STANDARD-DEVIATION function returns a numeric value that approximates
the standard deviation of its arguments. The type of this function is
numeric.
General Format.
Argument.
Argument-1 must be class numeric.
Returned Values.
1. The returned value is the approximation of the standard deviation
of the argument-1 series.
2. The returned value is calculated as follows:
a. The difference between each argument-1 value and the
arithmetic mean of the argument-1 series is calculated and
squared.
b. The values obtained are added. This quantity is divided by
the number of values in the argument-1 series.
c. The square root of the quotient obtained is calculated.
The returned value is the absolute value of this square
root.
3. If the argument-1 series consists of only one value, or if the
argument-1 series consists of all variable occurrence data items
and the total number of occurrences for all of them is one, the
returned value is zero.
4. Floating-point format is used for numeric non-integer results.
For ANS85 only: The SUM Function.
Description.
The SUM function returns a value that is the sum of the arguments. The
type of this function depends upon the argument types as follows:
Argument Type Function Type
---------------------------------------------------------------------------------------
All arguments integer Integer
Numeric Numeric
(some arguments may be integer)
General Format.
Argument.
Argument-1 must be class numeric.
Returned Values.
1. The returned value is the sum of the arguments.
2. If the argument-1 series are all integers, the value returned is
an integer.
3. If the argument-1 series are not all integers, a numeric value is
returned in floating-point format.
For ANS85 only: The TAN Function.
Description.
The TAN function returns a value that approximates the tangent of an
angle or arc, expressed in radians, that is specified by argument-1. The
type of this function is numeric.
General Format.
Argument.
Argument-1 must be class numeric.
Returned Values.
1. The returned value is the approximation of the tangent of
argument-1.
2. Floating-point format is used for numeric non-integer results.
For ANS85 only: The UPPER-CASE Function.
Description.
The UPPER-CASE function returns a character string that is the same
length as argument-1 with each lowercase letter replaced by the
corresponding uppercase letter. The type of this function is
alphanumeric.
General Format.
Argument.
Argument-1 must be class alphabetic or alphanumeric and must be at least
one character in length.
Returned Values.
1. The same character string as argument-1 is returned, except that
each lowercase letter is replaced by the corresponding uppercase
letter.
2. The character string returned has the same length as argument-1.
For ANS85 only: The VARIANCE Function.
Description.
The VARIANCE function returns a numeric value that approximates the
variance of its arguments. The type of this function is numeric.
General Format.
Argument.
Argument-1 must be class numeric.
Returned Values.
1. The returned value is the approximation of the variance of the
argument-1 series.
2. The returned value is defined as the square of the standard
deviation of the argument-1 series. (See the section The
STANDARD-DEVIATION Function, earlier in this chapter.)
3. If the argument-1 series consists of only one value, or if the
argument-1 series consists of all variable occurrence data items
and the total number of occurrences for all of them is one, the
returned value is zero.
4. Floating-point format is used for numeric non-integer results.
For ANS85 only: The WHEN-COMPILED Function.
Description.
The WHEN-COMPILED function returns the date and time the program was
compiled. The type of this function is alphanumeric.
General Format.
Returned Values.
1. The character positions returned, numbered from left to right,
are:
Character Contents
Positions
-------------------------------------------------------
1-4 Four numeric digits of the year in the
Gregorian calendar.
5-6 Two numeric digits of the month of the year,
in the range 01 through 12.
7-8 Two numeric digits of the day of the month,
in the range 01 through 31.
9-10 Two numeric digits of the hours past
midnight, in the range 00 through 23.
11-12 Two numeric digits of the minutes past the
hour, in the range 00 through 59.
13-14 Two numeric digits of the seconds past the
minute, in the range 00 through 59.
15-16 Two numeric digits of the hundredths of a
second past the second, in the range 00
through 99.
If the system does not have the facility to
provide fractional parts of a second, the
value 00 is returned.
Character Contents
Positions
-------------------------------------------------------
17 Either the character "-", the character "+",
or the character "0". The character "-" is
returned if the local time indicated in the
previous character positions is behind
Greenwich Mean Time. The character "+" is
returned if the local time indicated is the
same or ahead of Greenwich Mean Time. The
character "0" is returned if the system on
which this function is evaluated does not
have the facility to provide the local time
differential factor. If the system does not
have the facility to provide the local time
differential factor, the value 00000 is
returned in character positions 17 through
21.
18-19 If character position 17 is "-", two numeric
digits are returned in the range 00 through
12, indicating the number of hours that the
reported time is behind Greenwich Mean Time.
If character position 17 is "+", two numeric
digits are returned in the range 00 through
13 indicating the number of hours that the
reported time is ahead of Greenwich Mean
Time. If character position 17 is "0", the
value 00 is returned.
20-21 Two numeric digits are returned in the range
00 through 59 indicating the number of
additional minutes that the reported time is
ahead of or behind Greenwich Mean Time,
depending on whether character position 17 is
"+" or "-" , respectively. If character
position 17 is "0", the value 00 is returned.
2. The returned value is the date and time of compilation of the
source program that contains this function. If the program is a
contained program, the returned value is the compilation date and
time associated with the separately compiled program in which it
is contained.
3. The returned value denotes the same time as the compilation date
and time if provided in the listing of the source program and in
the generated object code for the source program, although their
representations and precisions may differ.
The ACCEPT Statement
Function.
The ACCEPT statement causes data keyed at the console or supplied by the
operating system to be made available to the program in a specified data
item.
General Formats.
Format 1.
Format 2.
For MF only: Format.
Format 4 (MF) (XOPEN).
Format 5 (MF).
Syntax Rules.
Format 1.
1. The mnemonic-name in Format 1 must be associated with a
function-name in the SPECIAL-NAMES paragraph in the Environment
Division. See General Rule 12 in the section The SPECIAL-NAMES
Paragraph in this chapter for a list of valid function-names.
2. Alternatively, function-name can itself be used instead of an
associated mnemonic-name (OSVS)(VSC2)(MF).
3. When mnemonic-name is associated with ARGUMENT-NUMBER in the
SPECIAL-NAMES paragraph, then identifier must be an unsigned
integer (MF)(XOPEN).
4. When mnemonic-name is associated with ARGUMENT-VALUE or
ENVIRONMENT-VALUE in the SPECIAL-NAMES paragraph, then identifier
must be an alphanumeric data item (MF)(XOPEN).
5. Identifier can be a USAGE DISPLAY-1 (DBCS) item or an external
floating-point data item (MF)(VSC2).
Identifier can be an internal floating-point data item (MF).
6. For MF and XOPEN only: The EXCEPTION phrase may be specified
only if FROM is specified with either ENVIRONMENT-NAME or
ARGUMENT-VALUE, or with the mnemonic-names associated with them.
For OSVS, VSC2 and MF only: Format 2.
7. Identifier can be an internal floating-point or external
floating-point item.
For MF only: Format 3.
8. No restrictions apply to the class, category or usage of the
identifier. However, the actual value placed into the identifier
and the validity of moving such values to the identifier are
dependent on the FROM clause. See the Format 3 General Rules for
more information.
For MF only: Format 4.
9. Screen-name cannot be an item with an OCCURS clause.
For MF only: Formats 4 and 5.
10. The LINE and COLUMN phrases can appear in any order.
11. EXCEPTION and ESCAPE are equivalent.
12. Identifier-4 must be a PIC 9(4) or a PIC 9(6) data item.
For MF only: Format 5.
13. Identifier-8 must be an integer. It can be signed.
14. Integer-7 can be signed.
15. An ACCEPT statement whose operand is not a screen-name is treated
as a Format 5 ACCEPT statement if it has an AT phrase, a FROM
phrase with the CRT option, a WITH phrase, a MODE IS BLOCK
phrase, or an EXCEPTION phrase; or if it has no FROM phrase but
the CONSOLE option clause is specified in the SPECIAL-NAMES
paragraph. If it has the FROM phrase with the CONSOLE option, or
if it has no FROM phrase and the CONSOLE IS CRT clause is not
specified in the SPECIAL-NAMES paragraph, it is treated as a
Format 1 ACCEPT statement.
16. The phrases following the identifier can be in any order.
17. The SPACE-FILL, ZERO-FILL, LEFT-JUSTIFY, RIGHT-JUSTIFY, PROMPT
and TRAILING-SIGN options are allowed only if the operand is an
elementary item.
18. Elementary data items in identifier-1 must be of USAGE DISPLAY.
19. No elementary item in identifier-1 may be longer than 8191 bytes.
If the MODE IS BLOCK phrase is used, the whole of identifier-1
must be no longer than 8191 bytes.
MPE/iX 5.0 Documentation