Previous | Contents | Index |
There are two CDD/Repository character string data types, TEXT and VARYING STRING. The TEXT data type translates directly into the BASIC STRING data type. VARYING STRING is not a supported BASIC data type; therefore, BASIC creates a group to contain the field.
The following example is a CDD/Repository definition that contains both the TEXT and VARYING STRING data types and the translated BASIC RECORD statement:
Example 22-1 CDDL |
---|
define record CDD$top.basic.strings description is /* test */. basicstrings structure. abc datatype is text size is 10. xyz datatype is varying string size is 16. end basicstrings structure. end strings. |
Example 22-2 Translated RECORD Statement |
---|
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.STRINGS" C1 ! test C1 RECORD BASICSTRINGS ! UNSPECIFIED C1 STRING ABC = 10 ! TEXT C1 GROUP XYZ ! VARYING STRING C1 WORD WORD_VALUE C1 STRING STRING_VALUE = 16 C1 END GROUP C1 END RECORD ................1 %BASIC-I-CDD/SUBGRO, 1: data type in CDD/Repository not supported, substituted group for: BASICSTRINGS::XYZ. |
In the VARYING STRING data type, the actual character string is preceded by a 16-bit count field. Therefore, BASIC creates a WORD variable to hold the specified string length.
The count field preceding the VARYING STRING is actually an UNSIGNED WORD. Therefore, the count field of a VARYING STRING whose length is greater than 32,767 is interpreted by BASIC as a negative number. |
In the previous example, the group name (XYZ) is the same name as a CDD/Repository field. Therefore, BASIC supplies an additional name for the RECORD components. The supplied names are WORD_VALUE and STRING_VALUE. For example, the following program statement creates an instance of the record BASICSTRINGS, called MY_REC:
100 MAP (TEST) BASICSTRINGS MY_REC |
The names you use to reference these components in BASIC are
MY_REC::XYZ::WORD_VALUE and MY_REC::XYZ::STRING_VALUE.
22.9.2 Integer Data Types
CDD/Repository refers to integer data types as fixed-point data types. CDD/Repository supports BYTE, WORD, LONGWORD, QUADWORD, and OCTAWORD integer data types. Each of these data types can have the following additional attributes:
SIGNED
UNSIGNED
SIZE
DIGITS
FRACTION
BASE
SCALE
In CDDL, if integer data types are not specified as being signed or unsigned, the default is unsigned. BASIC supports only signed BYTE, signed WORD, signed LONGWORD, and signed QUADWORD integers. If a CDD/Repository data definition containing an unsigned BYTE, WORD, LONGWORD, or QUADWORD integer is extracted, BASIC signals the informational message "Datatype in CDD/Repository not supported, substituted group for: <field-name>," and creates a group to contain the field. Because the group name is the same as the CDD/Repository field name, BASIC assigns a new name to the field. This is shown in the following CDDL data definition and corresponding BASIC RECORD statement:
define record CDD$top.basic.integers description is /*Test of selected integer data types*/. basicint structure. my_byte datatype is signed byte. my_ubyte datatype is byte. my_word datatype is signed word. my_uword datatype is unsigned word. my_long datatype is signed longword. my_ulong datatype is unsigned longword. end basicint structure. end integers. |
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.INTEGERS" C1 ! Test of selected integer data types C1 RECORD BASICINT ! UNSPECIFIED C1 BYTE MY_BYTE ! SIGNED BYTE C1 GROUP MY_UBYTE ! UNSIGNED BYTE C1 BYTE BYTE_VALUE C1 END GROUP C1 WORD MY_WORD ! SIGNED WORD C1 GROUP MY_UWORD ! UNSIGNED WORD C1 WORD WORD_VALUE C1 END GROUP C1 LONG MY_LONG ! SIGNED LONGWORD C1 GROUP MY_ULONG ! UNSIGNED LONGWORD C1 LONG LONG_VALUE C1 END GROUP C1 END RECORD ................1 %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: BASICINT::MY_UBYTE. %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: BASICINT::MY_UWORD. %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: BASICINT::MY_ULONG. |
When the previous data definition is extracted from CDD/Repository, BASIC signals an informational message for each of the unsigned data types, and names the CDD/Repository unsigned byte field BYTE_VALUE, the CDD/Repository unsigned word field WORD_VALUE, and the CDD/Repository unsigned longword field LONG_VALUE.
BASIC does not support OCTAWORD integers. If a CDD/Repository definition contains an OCTAWORD integer, BASIC signals the informational message "Datatype in CDD/Repository not supported, substituted group for: <field-name>" and creates a group to contain the field and a string component within the group. The string component is 16 bytes for OCTAWORD integers. For example:
define record CDD$top.basic.bigintegers description is /*Test of quadword and octaword integer data types*/. basicint structure. my_quad datatype is signed quadword. my_octa datatype is signed octaword. end basicint structure. end bigintegers. |
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.BIGINTEGERS" C1 ! Test of quadword and octaword integer data types C1 RECORD BASICINT ! UNSPECIFIED C1 QUAD MY_QUAD ! SIGNED QUADWORD C1 GROUP MY_OCTA ! SIGNED OCTAWORD C1 STRING STRING_VALUE = 16 C1 END GROUP C1 END RECORD %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: BASICINT::MY_OCTA. |
CDD/Repository supports the SCALE keyword to specify an implied exponent in integer data types, and the BASE keyword (supported in CDDL only) to specify that the scale for a fixed-point field is to be interpreted in a numeric base other than 10. BASIC does not support these integer attributes. Therefore, BASIC signals the informational message "CDD/Repository specifies SCALE for <name>. Not supported" for fixed-point fields containing a SCALE specification, and the error message "CDD/Repository attributes for <name> are other than base 10" for fixed-point fields specifying a base other than 10. For example:
define record CDD$top.basic.funnyintegers description is /* Test of quadword and octaword integer data types */. basicint structure. my_byte datatype is signed byte scale 2. my_long datatype is signed longword base 8. end basicint structure. end funnyintegers. |
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.FUNNYINTEGERS" C1 ! Test of quadword and octaword integer data types C1 RECORD BASICINT ! UNSPECIFIED C1 GROUP MY_BYTE ! SIGNED BYTE C1 BYTE BYTE_VALUE C1 END GROUP C1 LONG MY_LONG ! SIGNED LONGWORD C1 END RECORD %BASIC-I-CDDATTSCA, CDD specifies SCALE for BASICINT::MY_BYTE. Not supported %BASIC-E-CDDATTBAS, CDD attributes for BASICINT::MY_LONG are other than base 10 |
At compilation time, BASIC also signals these warning errors
for each reference to fields that are not base 10 or that have a SCALE.
22.9.3 Floating-Point Data Types
CDD/Repository supports F_floating, D_floating, G_floating, and H_floating data types. These correspond to the BASIC SINGLE, DOUBLE, GFLOAT, and HFLOAT1 data types, respectively. As with fixed-point data types, CDD/Repository also allows the specification of scale and base for floating-point data types. If a CDD/Repository data definition contains a floating-point field that specifies a SCALE or BASE, BASIC signals the informational message "CDD/Repository specifies SCALE for <name>. Not supported" or the error message "CDD/Repository attributes for <name> are other than base 10." For example:
define record floats description is /*Test of floating-point data types*/. basicfloat structure. my_single datatype is f_floating scale 3. my_double datatype is d_floating base 16. my_gfloat datatype is g_floating. my_hfloat datatype is h_floating. end basicfloat structure. end floats. |
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.FLOATS" C1 ! Test of floating-point data types C1 RECORD BASICFLOAT ! UNSPECIFIED C1 GROUP MY_SINGLE ! F_FLOATING C1 SINGLE SINGLE_VALUE C1 END GROUP C1 DOUBLE MY_DOUBLE ! D_FLOATING C1 GFLOAT MY_GFLOAT ! G_FLOATING C1 HFLOAT MY_HFLOAT ! H_FLOATING C1 END RECORD ................1 %BASIC-I-CDDATTSCA, 1: CDD specifies SCALE for BASICFLOAT::MY_SINGLE. Not supported %BASIC-E-CDDATTBAS, 1: CDD attributes for BASICFLOAT::MY_DOUBLE are other than base 10 |
In addition, CDD/Repository supports complex floating-point numbers, but BASIC does not support them. Complex floating-point numbers consist of a real and an imaginary part. Each part requires the same amount of storage as a simple floating-point number. Therefore, each complex floating-point number requires twice as much storage as a simple floating-point number.
If a CDD/Repository data definition containing complex numbers is extracted, BASIC signals the informational message "Datatype in CDD/Repository not supported, substituted group for <field-name>", and creates a group to contain the field. As before, BASIC uses the data type and _VALUE to create the group name, but because each complex number contains both a real and an imaginary part, BASIC adds an "_R" to the name of the real part and an "_I" to the name of the imaginary part. This is shown in the following CDD/Repository data definition and corresponding BASIC RECORD statement:
define record CDD$top.basic.complex description is /* test complex data types */. complex structure. my_s_complex_1 datatype f_floating_complex. my_d_complex_1 datatype d_floating_complex. my_g_complex_1 datatype g_floating_complex. my_h_complex_1 datatype h_floating_complex. end complex structure. end complex. |
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.COMPLEX" C1 ! test complex data types C1 RECORD COMPLEX ! UNSPECIFIED C1 GROUP MY_S_COMPLEX_1 ! F_FLOATING_COMPLEX C1 SINGLE SINGLE_R_VALUE C1 SINGLE SINGLE_I_VALUE C1 END GROUP C1 GROUP MY_D_COMPLEX_1 ! D_FLOATING_COMPLEX C1 DOUBLE DOUBLE_R_VALUE C1 DOUBLE DOUBLE_I_VALUE C1 END GROUP C1 GROUP MY_G_COMPLEX_1 ! G_FLOATING_COMPLEX C1 GFLOAT GFLOAT_R_VALUE C1 GFLOAT GFLOAT_I_VALUE C1 END GROUP C1 GROUP MY_H_COMPLEX_1 ! H_FLOATING_COMPLEX C1 HFLOAT HFLOAT_R_VALUE C1 HFLOAT HFLOAT_I_VALUE C1 END GROUP C1 END RECORD ................1 %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: COMPLEX::MY_S_COMPLEX_1. %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: COMPLEX::MY_D_COMPLEX_1. %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: COMPLEX::MY_G_COMPLEX_1. %BASIC-I-CDDSUBGRO, 1: data type in CDD/Repository not supported, substituted group for: COMPLEX::MY_H_COMPLEX_1. |
CDD/Repository supports the following forms of decimal string data types:
BASIC supports only the PACKED DECIMAL decimal string data type, which corresponds to the BASIC DECIMAL data type. For all other decimal string data types, BASIC creates a group with the same name as the CDD/Repository subordinate field, and creates a string record component to contain the field. For example:
define record CDD$top.basic.decimalstring description is /* test decimal string data types */. decimalstring structure. my_packed_decimal datatype is packed decimal size is 5 digits 2 fractions. my_zoned_numeric datatype is zoned numeric size is 6 digits 2 fractions. my_unsigned_numeric datatype is unsigned numeric size is 8 digits 4 fractions. my_lef_sep_numeric datatype is left separate numeric size is 10 digits 3 fractions. my_left_ovpnch_numeric datatype is left overpunched numeric size is 5 digits 2 fractions. my_right_sep_numeric datatype is right separate numeric size is 3 digits 1 fractions. my_right_ovpnch_numeric datatype is right overpunched numeric size is 4 digits 2 fractions. end decimalstring structure. end decimalstring. |
1 %INCLUDE %FROM %CDD "CDD$TOP.BASIC.DECIMALSTRING" C1 ! test decimal string data types C1 RECORD DECIMALSTRING ! UNSPECIFIED C1 DECIMAL(5 ,2 ) MY_PACKED_DECIMAL ! PACKED DECIMAL C1 GROUP MY_ZONED_NUMERIC ! ZONED NUMERIC ! C1 STRING STRING_VALUE = 6 C1 END GROUP C1 GROUP MY_UNSIGNED_NUMERIC ! UNSIGNED NUMERIC C1 STRING STRING_VALUE = 8 C1 END GROUP C1 GROUP MY_LEF_SEP_NUMERIC ! NUMERIC LEFT ! SEPARATE C1 STRING STRING_VALUE = 11 C1 END GROUP C1 GROUP MY_LEFT_OVPNCH_NUMERIC ! NUMERIC LEFT ! OVERPUNCHED C1 STRING STRING_VALUE = 5 C1 END GROUP C1 GROUP MY_RIGHT_SEP_NUMERIC ! NUMERIC RIGHT ! SEPARATE C1 STRING STRING_VALUE = 4 C1 END GROUP C1 GROUP MY_RIGHT_OVPNCH_NUMERIC ! NUMERIC RIGHT ! OVERPUNCHED C1 STRING STRING_VALUE = 4 C1 END GROUP C1 END RECORD %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: DECIMALSTRING::MY_ZONED_NUMERIC. %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: DECIMALSTRING::MY_UNSIGNED_NUMERIC. %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: DECIMALSTRING::MY_LEF_SEP_NUMERIC. %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: DECIMALSTRING::MY_LEFT_OVPNCH_NUMERIC. %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: DECIMALSTRING::MY_RIGHT_SEP_NUMERIC. %BASIC-I-CDDSUBGRO, data type in CDD/Repository not supported, substituted group for: DECIMALSTRING::MY_RIGHT_OVPNCH_NUMERIC. |
22.9.5 Other Data Types
CDD/Repository supports the following additional data types:
BIT
DATE
POINTER
UNSPECIFIED
VIRTUAL
ALPHABETIC
BASIC does not support these data types. BASIC translates these data types by signaling the informational message "Datatype in CDD/Repository not supported, substituted group for: <field name>", and creates a group to contain the field. See Table 22-2 for a description of how BASIC translates these data types.
If you extract a CDD/Repository definition that contains a BIT field, the field must be a multiple of 8 bits (1 byte). This means that the following field must be aligned on a byte boundary. If the following field is not aligned on a byte boundary, BASIC signals the error "Field <name> from CDD/Repository has bit offset or length."
1 Compaq BASIC for OpenVMS Alpha (Alpha BASIC) does not support the HFLOAT data type. |
Previous | Next | Contents | Index |