Document revision date: 30 March 2001

## OpenVMS RTL Library (LIB$) Manual

Previous | Contents | Index

## LIB$CVT_DX_DX

> The General Data Type Conversion routine converts OpenVMS standard atomic or string data described by a source descriptor to OpenVMS standard atomic or string data described by a destination descriptor. This conversion is supported over a subset of the OpenVMS standard data types.

### Format

> LIB$CVT_DX_DX source-item ,destination-item [,word-integer-dest-length]

### RETURNS

> OpenVMS usage: | cond_value
> type: | longword (unsigned)
> access: | write only
> mechanism: | by value

### Arguments

> #### source-item

> OpenVMS usage: | unspecified
> type: | unspecified
> access: | read only
> mechanism: | by descriptor

> Source item to be converted by LIB$CVT_DX_DX. The source-item argument is the address of a descriptor pointing to the source item to be converted. The type of the item to be converted is contained in the descriptor.

> The combination of source descriptor class and data type is restricted as described in Table lib_1 and Table lib-2.

> #### destination-item

> OpenVMS usage: | unspecified
> type: | unspecified
> access: | write only
> mechanism: | by descriptor

> Destination of the conversion. The destination-item argument is the address of a descriptor pointing to the destination item. The destination descriptor specifies the data type to which the source item is converted.

> The combination of destination descriptor class and data type is restricted as described in Table lib_1 and Table lib-2.

> #### word-integer-dest-length

> OpenVMS usage: | word_unsigned
> type: | word (unsigned)
> access: | write only
> mechanism: | by reference

> Length in bytes of the destination item (when that item is a string) that has been converted by LIB$CVT_DX_DX, not including any space filling. The word-integer-dest-length argument contains the address of an unsigned word containing this length.

> If the destination string is truncated, the returned length reflects the truncation. This word can be used by the calling program to determine if truncation has occurred or to extract the exact length of the string when the string contains space filling.

### Description

> LIB$CVT_DX_DX is a universal conversion utility routine. Table lib-1 shows the complete matrix of data type and descriptor class combinations (as specified in the fields of the descriptor) supported by LIB$CVT_DX_DX.

> Conversion is defined over three sets of data types: atomic, string, and numeric byte data strings. Although some of the functions of this routine may be found in other Run-Time Library routines, LIB$CVT_DX_DX packages the conversion functions with a general interface. Because of this general interface, the calling program does not have to specify what conversion should be done for which data type.

> Refer to LIB$CVT_xTB if you want to convert the ASCII text string representation of a decimal, hexadecimal, or octal number into a binary representation.

> The description of this routine has been divided into the following parts:

> - Guidelines for Using LIB$CVT_DX_DX
> - Use of Numeric Byte Data Strings (NBDS)

> For more information about numeric byte data strings, see the section called Use of Numeric Byte Data Strings (NBDS). Although the set of data types in NBDS is actually a subset of the atomic and string data types, the three sets are mutually exclusive in this routine. For more information on the OpenVMS atomic and string data types and the argument descriptor classes supported by this routine, see the OpenVMS Calling Standard manual.

> Table lib-1 OpenVMS Descriptor Class and Data Type Combinations Accepted by LIB$CVT_DX_DX
> | Descriptor Class
> --- | ---
> DSC$K_DTYPE_yyy | A | D | NCA | S | SD | VS
> B |  |  |  | Non-NBDS | Non-NBDS |
> BU | NBDS |  | NBDS | Non-NBDS |  |
> D |  |  |  | Non-NBDS | Non-NBDS |
> F |  |  |  | Non-NBDS | Non-NBDS |
> FS |  |  |  | Non-NBDS | Non-NBDS |
> FT |  |  |  | Non-NBDS | Non-NBDS |
> G |  |  |  | Non-NBDS | Non-NBDS |
> H |  |  |  | Non-NBDS | Non-NBDS |
> L |  |  |  | Non-NBDS | Non-NBDS |
> LU |  |  |  | Non-NBDS |  |
> NL |  |  |  | Non-NBDS | Non-NBDS |
> NLO |  |  |  | Non-NBDS | Non-NBDS |
> NR |  |  |  | Non-NBDS | Non-NBDS |
> NRO |  |  |  | Non-NBDS | Non-NBDS |
> NU |  |  |  | Non-NBDS | Non-NBDS |
> NZ |  |  |  | Non-NBDS | Non-NBDS |
> P |  |  |  | Non-NBDS | Non-NBDS |
> Q |  |  |  | Non-NBDS | Non-NBDS |
> T | NBDS | NBDS | NBDS | NBDS | NBDS |
> VT |  |  |  |  |  | NBDS
> W |  |  |  | Non-NBDS | Non-NBDS |
> WU |  |  |  | Non-NBDS |  |

Invalid combinations are blank. Any source data can be converted into any other destination data as long as they are both represented by one of the valid combinations.

Note: LIB $CVT _DX _DX treats an array, described by a CLASS _A or CLASS _NCA descriptor, as a character string. NBDS must have the format defined in Table lib-2 .

Guidelines for Using LIB$CVT_DX_DX

The data type and descriptor class of the source and destination arguments determine how LIB$CVT_DX_DX performs the conversion, according to the following rules:

- Scale is applied when indicated in the descriptor (descriptor CLASS_SD only), and scaling is defined for the data type.
- No language-specific semantics are applied, such as BASIC scale for DSC$K_DTYPE_D.
- Some conversions must use intermediate values to arrive at the destination requested. Although some loss of speed is inevitable, intermediate values will not cause a loss of precision.
- Results are always rounded instead of truncated, except for the case described below. Note that loss of precision or range may be inherent in the destination data type or in the NBDS destination size. No errors are reported if there is a loss of precision or range as a result of destination data type.
- When the destination is an NBDS and has fixed-string semantics, then if the source does not fill the destination, the destination is padded with blanks.
- When the source and destination are both NBDS and no scaling is requested, then a straight copy is done without translation or conversion, and truncation is possible. If scaling is requested, then a conversion takes place as defined in Table lib-2.
- When the source is an NBDS and the destination is non-NBDS, if there is an invalid character in the source or the value is outside the range that can be represented by the destination, then LIB$_INVNBDS is returned.
- Attempts to convert a negative value to an unsigned data type cause the LIB$_INVCVT error to be returned.
- If the destination is an NBDS of descriptor CLASS_D, then a new string of appropriate size is allocated for it, if necessary.
- Invalid conversions resulting in an error produce an unpredictable result.

Use of Numeric Byte Data Strings (NBDS)

For simplicity, and to define a generic numeric string that LIB$CVT_DX_DX understands to be a numeric string, the set Numeric Byte Data String (NBDS) is defined to be the set of NBDS descriptors shown in Table lib-1.

The combination of data type and descriptor class determines whether an argument is an NBDS. For example, LIB$CVT_DX_DX treats the combination DSC$K_DTYPE_B/DSC$K_CLASS_S (unsigned byte scalar) as an atomic data type. However, the routine considers DSC$K_DTYPE_BU/DSC$K_CLASS_NCA (noncontiguous array of unsigned bytes) to be an NBDS.

A destination NBDS is always left-justified.

If a destination NBDS requires more than 50 digits for its format (including the sign, if any), then it is expressed in exponential format.

For a conversion of NBDS to NBDS, this format is used if scaling is requested. Otherwise, a straight copy is done. The format of a source NBDS is the same as the format defined for the input argument inp in OTS$_CVT_T_z, with bits 0, 2, and 4 set in the flags argument. That is, blanks are ignored, underflow causes an error, and tabs are ignored.

Table lib-2 defines the format of a destination NBDS.

Table lib-2 LIB$CVT_DX_DX Destination NBDS Formats
Source Data Type | Destination NBDS Format
--- | ---
Byte integer (signed) | sdigits
Byte (unsigned) | digits
Word integer (signed) | sdigits
Word (unsigned) | digits
Longword integer (signed) | sdigits
Longword (unsigned) | digits
Quadword integer (signed) | sdigits
D_floating | s0.min(16,w-7)E+ or - nn
F_floating | s0.min( 7,w-7)E+ or - nn
G_floating | s0.min(15,w-8)E+ or - nnn
H_floating | s0.min(33,w-9)E+ or - nnnn
FS_floating (IEEE) | s0.min(7,w-7)E+ or - nn
FT_floating (IEEE) | s0.min(15,w-8)E+ or - nnn
NBDS | s0.min(33,w-9)E+ or - nnnn
Decimal string | sdigits (as defined by VAX architecture)

Key to Destination NBDS Formats

- digits: Digits 0 through 9, and a decimal point only if source descriptor specifies the value of the SCALE field as less than 0.
- w: Width of destination in bytes.
- s: Sign. For positive numbers, the sign is implied.
- min: Minimum of two values.

The A and NCA array descriptor classes are supported with the following restrictions:

An array is written with the semantics of a fixed string.
DIMCT = 1 | Only one-dimensional arrays are recognized.
LENGTH = 1 | The length of each array element must be a byte.
ARSIZE <= 65,535 | The total size of the array must be less than 65,535 bytes. If ARSIZE = 0, the array has a length of zero.
S1 = 1 | The stride of an array passed by a noncontiguous array descriptor must be 1. That is, even if the class of the array's descriptor is noncontiguous array (NCA), the array itself must be contiguous.

For more information about the semantics of writing output strings, see the OpenVMS RTL String Manipulation (STR$) Manual.

If the calling program passes a descriptor to LIB$CVT_DX_DX that does not comply with Table lib-1, one of the following error messages is returned:

> LIB$_INVDTYDSC
> LIB$_INVCLADSC
> LIB$_INVCLADTY
> LIB$_INVNBDS

### Condition Values Returned

> SS$_NORMAL | Routine successfully completed.
> LIB$_DECOVF | Packed decimal overflow error. Severe error.
> LIB$_FLTOVF | Floating overflow error. Severe error.
> LIB$_FLTUND | Floating underflow error. Severe error.
> LIB$_INTOVF | Integer overflow error. Severe error.
> LIB$_INVCLADSC | Invalid class in descriptor. This class of descriptor is not supported. Severe error.
> LIB$_INVCLADTY | Invalid class and data type in descriptor. This class and data type combination is not supported. Severe error.
> LIB$_INVCVT | If the source value is negative and the destination data type is unsigned, this error is returned.
> LIB$_INVDTYDSC | Invalid data type in descriptor. This data type is not supported. Severe error.
> LIB$_INVNBDS | Invalid NBDS. There is an invalid character in the input, or the value is outside the range that can be represented by the destination, or the NMDS descriptor is invalid. This error is also signaled when the array size of an NBDS is larger than 65,535 bytes or the array is multi-dimensional.
> LIB$_OUTSTRTRU | Output string truncated. This is returned only when NBDS is both source and destination and no scaling is requested. The result is truncated.
> LIB$_ROPRAND | Reserved operand error. Severe error.

## LIB$CVT_FROM_INTERNAL_TIME

> The Convert Internal Time to External Time routine converts an internal OpenVMS system time (either absolute or delta) into an external time.

### Format

> LIB$CVT_FROM_INTERNAL_TIME operation ,resultant-time [,input-time]

### RETURNS

> OpenVMS usage: | cond_value
> type: | longword (unsigned)
> access: | write only
> mechanism: | by value

### Arguments

> #### operation

> OpenVMS usage: | function_code
> type: | longword (unsigned)
> access: | read only
> mechanism: | by reference

> The conversion to be performed. The operation argument is the address of an unsigned longword containing the operation. The following table shows valid values for operation:

> Operation | Type | Return Range
> --- | --- | ---
> LIB$K_MONTH_OF_YEAR | Absolute | 1 to 12
> LIB$K_DAY_OF_YEAR | Absolute | 1 to 366
> LIB$K_HOUR_OF_YEAR | Absolute | 1 to 8784
> LIB$K_MINUTE_OF_YEAR | Absolute | 1 to 527,040
> LIB$K_SECOND_OF_YEAR | Absolute | 1 to 31,622,400
> LIB$K_DAY_OF_MONTH | Absolute | 1 to 31
> LIB$K_HOUR_OF_MONTH | Absolute | 1 to 744
> LIB$K_MINUTE_OF_MONTH | Absolute | 1 to 44,640
> LIB$K_SECOND_OF_MONTH | Absolute | 1 to 2,678,400
> LIB$K_DAY_OF_WEEK | Absolute 1 | 1 to 7
> LIB$K_HOUR_OF_WEEK | Absolute 2 | 1 to 168
> LIB$K_MINUTE_OF_WEEK | Absolute 3 | 1 to 10,080
> LIB$K_SECOND_OF_WEEK | Absolute 4 | 1 to 604,800
> LIB$K_HOUR_OF_DAY | Absolute | 0 to 23
> LIB$K_MINUTE_OF_DAY | Absolute | 0 to 1439
> LIB$K_SECOND_OF_DAY | Absolute | 0 to 86,399
> LIB$K_MINUTE_OF_HOUR | Absolute | 0 to 59
> LIB$K_SECOND_OF_HOUR | Absolute | 0 to 3599
> LIB$K_SECOND_OF_MINUTE | Absolute | 0 to 59
> LIB$K_JULIAN_DATE | Absolute 5 | Julian date
> LIB$K_DELTA_WEEKS | Delta 6 |
> LIB$K_DELTA_DAYS | Delta 7 |
> LIB$K_DELTA_HOURS | Delta 8 |
> LIB$K_DELTA_MINUTES | Delta 9 |
> LIB$K_DELTA_SECONDS | Delta 10 |

1Day 1 is Monday.
2Hours since midnight on previous Monday.
3Minutes since midnight on previous Monday.
4Seconds since midnight on previous Monday.
5Number of days since system zero time (17--Nov--1858).
6Whole weeks.
7Whole days.
8Whole hours.
9Whole minutes.
10Whole seconds.

#### resultant-time

OpenVMS usage: | longword_unsigned
type: | longword (unsigned)
access: | write only
mechanism: | by reference

The external time that results from the conversion. The resultant-time argument is the address of an unsigned longword containing the result.

#### input-time

OpenVMS usage: | date_time
type: | quadword (unsigned)
access: | read only
mechanism: | by reference

Optional absolute or delta time to be converted. The input-time argument is the address of an unsigned quadword containing the time. If you do not supply a value for input-time, the current system time is used.

### Description

> LIB$CVT_FROM_INTERNAL_TIME converts an internal OpenVMS system time (either absolute or delta) into an external time. The operation argument specifies the conversion. LIB$CVT_FROM_INTERNAL_TIME converts the value of input-time (or the current system time if input-time is not supplied) into one of the external formats listed in the operation argument description. LIB$CVT_FROM_INTERNAL_TIME then places the result into resultant-time.

> See the OpenVMS Programming Concepts Manual for a description of system date and time operations as well as a detailed description of the format mnemonics used in these routines.

### Condition Values Returned

> LIB$_NORMAL | Routine successfully completed.
> LIB$_ABSTIMREQ | Absolute time required but delta time supplied.
> LIB$_DELTIMREQ | Delta time required but absolute time supplied.
> LIB$_INVOPER | Invalid operation.
> LIB$_IVTIME | Invalid time.
> LIB$_WRONUMARG | Incorrect number of arguments.

Previous | Next | Contents | Index

| privacy and legal statement |
5932PRO_008.HTML