[next] [previous] [contents]

  22.2.5 Extracting CDD/Repository Data Definitions
  A data definition is one type of a CDD/Repository object. In
  BASIC, you can extract only data definition objects into your
  program.

  To extract a CDD/Repository data definition in BASIC, spec-
  ify the %INCLUDE %FROM %CDD compiler directive and
  a CDD/Repository path name. You can use this to extract a
  data definition from either a DMU-format or CDO-format
  dictionary. For example:
  %INCLUDE %FROM %CDD "CDD$TOP.BASIC.BASICDEF"

  The %INCLUDE %FROM %CDD directive extracts the
  CDD/Repository data definition you specify and translates it
  into BASIC syntax. In BASIC, the syntax for data definitions
  or data structures is defined by the RECORD statement.

  After a CDD/Repository data definition is translated into
  RECORD statement syntax, you can reference the name
  of the RECORD statement in your BASIC programs. After
  compilation, the translated RECORD statement is included as
  a part of your program's listing.

  The following is an example of a CDD/Repository data def-
  inition and the translated BASIC RECORD statement. The
  examples in this chapter are CDD/Repository data definitions
  in DMU-format that were written in the Common Data
  Definition Language (CDDL). In all examples, a CDDL data
  definition is displayed in lowercase letters, and the translated
  RECORD statement is displayed in uppercase letters.

  CDDL Definition
  
EXAMPLE: Click to display example.

  Translated RECORD Statement
  
EXAMPLE: Click to display example.

  When BASIC translates a CDD/Repository data definition, it
  does the following:

  .
        For DMU-format definitions, BASIC takes the field
        name specified in the first CDDL STRUCTURE state-
        ment and assigns that name to BASIC RECORD. For
        CDO-format definitions, BASIC takes the record name
        from the CDO DEFINE RECORD statement and as-
        signs that name to a BASIC RECORD. In the previous
        example, the first CDD/Repository structure statement
        is employee structure . When BASIC translates this line
        of a CDD/Repository data definition, it names the record
        EMPLOYEE
. If this first structure is unnamed, BASIC
        signals the error ``Record from CDD/Repository does not
        have a record name''.
  .
        Translates the field name in any subsequent CDD/Repository
        STRUCTURE statement to be the name of a group. In
        the previous example, the second STRUCTURE state-
        ment, zip_code structure , is translated to GROUP ZIP_
        CODE
.
  .
        Translates subordinate field names in CDD/Repository
        STRUCTURE statements to elementary components in
        the RECORD statement. In the previous example, the
        subordinate field name street is translated to STRING
        STREET
.

  If you specify the /LIST qualifier when BASIC translates a
  CDD/Repository data definition, it does the following:

  .
        Begins each line of the RECORD statement with the
        letter ``C'' followed by a number. The letter ``C'' tells
        you that the RECORD statement is translated from a
        CDD/Repository data definition. The number tells you
        the nesting level of the %INCLUDE %FROM %CDD
        directive within the source program. For example, if
        your source program directly extracts a CDD/Repository
        record definition, then each line is preceded by ``C1''.
        If the CDD/Repository extraction came from a file in-
        cluded in the source program, then each line of the record
        definition is preceded by ``C2'', and so on.
  .
        Includes the explanatory text in the CDDL DESCRIPTION
        clause as comment fields.
  .
        Translates the data type text in the subordinate field
        to a comment field that tells you the data type of each
        elementary RECORD component. For example, the com-
        ment ! TEXT tells you that STRING STREET is a text
        data type.

  BASIC requires that a CDD/Repository data definition include
  a minimum of one structure to be translated into a RECORD
  statement. If a CDD/Repository data definition contains only
  a single subordinate field (without a structure), BASIC sig-
  nals an error because it cannot give a name to the RECORD
  statement. You cannot include a CDO FIELD definition in a
  BASIC program. You can, however, include CDO RECORD
  definitions that contain that field.

  For more information about how BASIC translates CDD/Repository
  data types, see
Section 22.9.