HP 3000 Manuals

>GENERATE ELEMENTS [ DICTIONARY 3000 ] MPE/iX 5.0 Documentation


DICTIONARY 3000

>GENERATE ELEMENTS 

Generates PASCAL data declarations for element definitions in the
Dictionary.

Prompts 

The following prompt is issued when the command-subcommand GENERATE
ELEMENT is entered:
_____________________________________
|                                   |
|     ELEMENT(S)>                   |
_____________________________________

ELEMENT(S)>               Enter the name(s) of the elements to be
                          extracted from the Dictionary and for which the
                          data declaration(s) will be generated.  More
                          than one element name can be entered in one
                          command line as long as each element is
                          separated by a comma ( , ) or a space.  Also,
                          the element names can not exceed the first 72
                          characters of the command line.  DICTPDE will
                          continue to prompt for element names until
                          [[RETURN]] is pressed in response to this
                          prompt.

                          If a parent element is entered in response to
                          this prompt, DICTPDE will generate data
                          declarations for the parent element as well as
                          for the related child elements.  The parent
                          element will be generated as a record.  The
                          primary name of the parent element will be the
                          record name.  The child elements will be
                          generated as fields within the record.  The
                          aliases of the child elements will be the field
                          names (unless a child element does not have an
                          alias; then its primary name will be the field
                          name).

                          A data declaration can be generated for a
                          specified element only once to an output file.
                          However, many data declarations can be
                          generated for a specified element if each
                          declaration generated for that element is
                          written to a different output file.

                          Pressing [[RETURN]] in response to this prompt
                          indicates that no more element names are to be
                          entered.  DICTPDE will then stop prompting for
                          element(s) and begin the code generation
                          process.  The generated code is echoed to the
                          terminal as it is written to the output file.

Discussion 

GENERATE ELEMENT allows you to identify the element(s) to be used for
code generation.

Example 

The following examples show how the GENERATE ELEMENT command-subcommand
is used and the code that it generates.

The first example shows the data declaration generated for a simple
element.  The element "account" does not have any child elements related
to it.

The element "account" is defined in the Dictionary as follows:

     ELEMENT         = account
     ELEMENT-TYPE    = I
     ELEMENT-LENGTH  = 4

The code is generated as follows:

> generate element                    Or G E could have been entered.
ELEMENT NAME(S)> account
                                      The generated code is echoed to
TYPE                                  the terminal.
ACCOUNT = INTEGER;

The next example shows the code generated for elements that have
ELEMENT-COUNTS in the Dictionary that are greater than 1.  The two
elements have no child entities related to them.  The elements are
defined in the Dictionary as follows:

     ELEMENT         = PART1     PART2
     ELEMENT-TYPE    = I         P
     ELEMENT-LENGTH  = 2         10
     ELEMENT-COUNT   = 10        4

The code is generated as follows:

     > generate element
     ELEMENT NAME(S)> part1 part2
     TYPE
        PART1 = ARRAY[1..10] OF -32768..32767;
        PART2 = ARRAY[1..4] OF ARRAY[1..10] OF 0..255;

Note that ELEMENT-COUNT is used to determine the index of the array.
ELEMENT-TYPE and ELEMENT-LENGTH are used in determining the base type of
the array.

The third example shows the code generated for an element whose type is
defined as an asterisk "*" in the Dictionary.  (This element
back-references another element.)  The element is defined in the
Dictionary as follows:

     ELEMENT         = CUSTNUM
     ELEMENT-TYPE    = *
     ELEMENT-REFERENCE = CUSTNAME

CUSTNAME is defined in the Dictionary as:

     ELEMENT         = CUSTNAME
     ELEMENT-TYPE    = X
     ELEMENT-LENGTH  = 14

The TYPE declaration for the element CUSTNUM is generated as follows:

     >generate element
     ELEMENT(S)> custnum

        TYPE
           CUSTNAME = PACKED ARRAY[1..14] OF CHAR;

           CUSTNUM : CUSTNAME;

The VAR declaration for the element CUSTNUM is generated as follows:

     TYPE
        CUSTNAME = PACKED ARRAY[1..14] OF CHAR;

     VAR
        CUSTNUM = CUSTNAME

Note that the code for the ELEMENT-REFERENCE is generated first as a TYPE
declaration.

The next example shows the code generated for a parent element.  (This
element has child elements related to it.)  In this example, the element
SALES has the elements PRODUCT, PRICE and PACKAGE related to it.  These
elements are defined in the Dictionary as:

     PARENT-ELEMENT  = SALES
     ELEMENT-TYPE    = X
     ELEMENT-LENGTH  = 50

     CHILD-ELEMENTS  = PRODUCT     PRICE     PACKAGE
     ELEMENT-TYPE    = X           X         X
     ELEMENT-LENGTH  = 12          28        10

The code for the parent element SALES is generated as follows:

     >generate element
     ELEMENT(S)> sales

     TYPE
        SALES =
         RECORD
           PRODUCT  : PACKED ARRAY[1..12] OF CHAR;
           PRICE    : PACKED ARRAY[1..28] OF CHAR;
           PACKAGE  : PACKED ARRAY[1..10] OF CHAR
         END;

Note that in this case the sum of the storage lengths for the child
elements equals the storage length for the parent element as defined in
the Dictionary.

In the next example, code is again generated for a parent element.
However, in this example, the sum of the storage lengths for the child
elements does not equal the storage length for the parent element.

     PARENT-ELEMENT  = ADDRESS
     ELEMENT-TYPE    = X
     ELEMENT-LENGTH  = 48

     CHILD-ELEMENTS  = STREET      NUMB
     ELEMENT-TYPE    = X           I
     ELEMENT-LENGTH  = 12          4

The code for the parent element ADDRESS is generated as follows:

     >generate element
     ELEMENT(S)> address

     TYPE
        ADDRESS =
         RECORD
            CASE INTEGER OF
               0 :
                (
                  BUFFER : PACKED ARRAY[1..48] OF CHAR;
                );
               1 :
                (
                  DUMMY0 : PACKED ARRAY[1..3] OF CHAR;
                  STREET : PACKED ARRAY[1..12] OF CHAR;
                  DUMMY1 : PACKED ARRAY[1..15] OF CHAR;
                  NUMB   : INTEGER
                );
         END;

When the sum of the storage lengths for the child elements does not equal
the storage length for the parent element, DICTPDE will generate "BUFFER"
or "DUMMY" fields in order to insure the correct storage length for the
parent element.  The BUFFER and DUMMY fields begin at the correct byte
offsets within the parent element.


MPE/iX 5.0 Documentation