[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

7.43 TAN

Description

The TAN function returns a numeric value that approximates the tangent of an angle or arc, expressed in radians, that is specified by the argument.


arg

is a numeric or integer argument.

Rules

  1. The type of this function is numeric.
  2. The returned value is the approximate tangent of the angle specified.

Example


COMPUTE TAN-RSLT = FUNCTION TAN (X).
X and TAN-RSULT are numeric data items. If the value of X is 3, the approximate tangent of an angle of 3 radians is moved to TAN-RSLT.

7.44 TEST-DATE-YYYYMMDD

Description

The TEST-DATE-YYYYMMDD function tests whether a standard date in the form YYYYMMDD is a valid date in the Gregorian calendar.

General Format


FUNCTION TEST-DATE-YYYYMMDD ( arg )

arg

is an integer.

Rules

  1. The type of this function is integer.
  2. If the year is not within the range 1601 through 9999, the function returns a 1.
    Otherwise, if the month is not within the range 1 through 12, the function returns a 2.
    Otherwise, if the number of days is invalid for the given month, the function returns a 3.
    Otherwise, the function returns a 0 to indicate the date is a valid date in the form YYYYMMDD.

Example


IF FUNCTION TEST-DATE-YYYYMMDD (123456789) = 1
   DISPLAY "correct - invalid year (12345)".
IF FUNCTION TEST-DATE-YYYYMMDD (19952020)  = 2
   DISPLAY "correct - invalid mm  (20)".
IF FUNCTION TEST-DATE-YYYYMMDD (19950229)  = 3
   DISPLAY "correct - invalid dd  (29)".
IF FUNCTION TEST-DATE-YYYYMMDD (20040229)  = 0
   DISPLAY "correct - valid YYYYMMDD".

7.45 TEST-DAY-YYYYDDD

Description

The TEST-DAY-YYYYDDD function tests whether a Julian date in the form YYYYDDD is a valid date in the Gregorian calendar.

General Format


FUNCTION TEST-DAY-YYYYDDD ( arg )

arg

is an integer.

Rules

  1. The type of this function is integer.
  2. If the year is not within the range 1601 through 9999, the function returns a 1.
    Otherwise, if the number of days is invalid for the given year, the function returns a 2.
    Otherwise, the function returns a 0 to indicate the date is a valid date in the form YYYYDDD.

Example


IF FUNCTION TEST-DAY-YYYYDDD (12345678) = 1
   DISPLAY "correct - invalid year (12345)".
IF FUNCTION TEST-DAY-YYYYDDD (1995366)  = 2
   DISPLAY "correct - invalid ddd (366)".
IF FUNCTION TEST-DAY-YYYYDDD (2004366)  = 0
   DISPLAY "correct - valid YYYYDDD".

7.46 UPPER-CASE

Description

The UPPER-CASE function returns a character string that is the same length as the argument with each lowercase letter in the argument replaced by the corresponding uppercase letter.


string

is an alphabetic or alphanumeric argument at least one character in length.

Rules

  1. The type of this function is alphanumeric.
  2. The returned value is the same character string as the argument, except that each lowercase letter in the argument is replaced by the corresponding uppercase letter.

Examples


  1. MOVE FUNCTION UPPER-CASE (STR) TO UC-STR.
    
    If STR (an alphanumeric data item six characters in length) contains the value "Autumn" the value returned and stored in UC-STR (also an alphanumeric data item six characters in length) is "AUTUMN"; if STR contains "FALL98" the value returned is unchanged ("FALL98").

  2. ACCEPT NAME-FIELD.
    WRITE RECORD-OUT
          FROM FUNCTION UPPER-CASE(NAME-FIELD).
    
    The value in NAME-FIELD is made all-uppercase, unless it was already all-uppercase, in which case it is unchanged. Any nonalphabetic characters remain unchanged.

7.47 VARIANCE

Description

The VARIANCE function returns a numeric value that approximates the variance of its arguments.


arg

is an integer or numeric argument.

Rules

  1. The type of this function is numeric.
  2. The returned value is the approximation of the variance of the argument series, and is defined as the square of the standard deviation of the argument series. (For a definition of standard deviation, see the description of the
    Section 7.41 function.)
  3. If the argument series consists of only one value, the returned value is 0.

Examples


  1. COMPUTE RSULT = FUNCTION VARIANCE (A).
    
    The value returned and stored in RSULT is 0, because there is only one argument.

  2. COMPUTE RSULT = FUNCTION VARIANCE (A, B, C).
    
    If A has the value 1, B has 2, and C has 12, the value returned and stored in RSULT is approximately 24.667. This represents the variance, which is the square of the standard deviation of these arguments; the calculation is described in the description of the Section 7.41 function. In the above examples, A, B, C, and RSULT are numeric data items.

7.48 WHEN-COMPILED

Description

The WHEN-COMPILED function returns the date and time the program was compiled.


Rules

  1. The type of this function is alphanumeric.
  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 provided in the listing of the source program and in the generated object code for the source program. The representation differs, and the precision can differ, as shown in the second example.
  4. The contents of the character positions returned, numbered from left to right, are as follows:
    Character Positions Contents
    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.
    17-21 The value 00000. (Reserved for future use.)

Examples


MOVE FUNCTION WHEN-COMPILED TO VERSION-STAMP.
The value returned and stored in VERSION-STAMP (an alphanumeric data item) is the date and time of the program's compilation.


199701101652313200000
This is a sample value returned by the WHEN-COMPILED function. Reading from left to right, it shows
  • The year, 1997
  • The month, January
  • The day of the month, the 10th
  • The time of day, 16:52 (4:52 P.M.)
  • The seconds, 31, and the hundredths
    of seconds, 32, after 16:52:31

This compilation date and time as shown on the compiler listing (which does not show hundredths of seconds) is as follows:


Previous Next Contents Index