Structure
A structure is composed of a series of structure items, each of which describes an elemental memory location or a collection of memory locations. A structure establishes the format of a form, table, or record part and can establish the format of at least some of the data used in a pageHandler part.
An example of a structure is as follows:
10 workAddress; 20 streetAddress1 CHAR(20); 30 Line1 CHAR(10); 30 Line2 CHAR(10); 20 streetAddress2 CHAR(20); 30 Line1 CHAR(10); 30 Line2 CHAR(10); 20 city CHAR(20);You can declare all the structure items directly in the structure declaration, as in the preceding example. Alternatively, you can indicate that all or a subset of the structure is equivalent to the structure that is in another record part; for details, see Typedef.
Access to a structure item is based on a variable name, then a series of structure item names with a dot syntax. If you declare that the record myRecord includes the structure shown in the previous example, each of the following identifiers refers to an area of memory:
myRecord.workAddress myRecord.workAddress.streetAddress1 myRecord.workAddress.streetAddress1.Line1An elementary structure item has no subordinate structure items and describes an area of memory in either of these ways:
- By a specification of length and primitive type, as in the previous example; or
- By pointing to the declaration of a dataItem part, as described in Typedef.
As shown earlier, a structure item can have subordinate structure items. Consider the next example:
10 topMost; 20 next01 HEX(4); 20 next02 HEX(4);When you define a superior structure item (like topMost), you have several options:
- If you do not assign a length or primitive type, the superior structure item is of type CHAR, and EGL calculates the length. The primitive type of topMost is CHAR, for example, and the length is 4.
- If you assign a primitive type but do not assign a length, EGL calculates the length based on characteristics of the subordinate structure items
- If you assign both a length and primitive type, the length must reflect the space provided for the subordinate structure items; otherwise, an error occurs
Note: The primitive type of a structure item determines the number of bytes in each unit of length; for details, see Primitive types.
Each elementary structure item has a series of properties, whether by default or as specified in the structure item. (The structure item may refer to a dataItem part that itself has properties.) For details, see Overview of EGL properties and overrides.
Related concepts
DataItem part
Parts
Overview of EGL properties and overrides
Record parts
References to variables and constants
Typedef
Related reference
Data initialization
EGL source format
Items
Primitive types
SQL item properties