EGL Reference Guide for iSeries

Typedef

A type definition (typedef) is a part that is used as a model of format. You use the typedef mechanism for these reasons:

Often, typedefs identify an abstract grouping. You can declare a record part named address, for example, and divide the information into streetAddress1, streetAddress2, and city. If a personnel record includes the structure items workAddress and homeAddress, each of those structure items can point to the format of the record part named address. This use of typedef ensures that the address formats are the same.

Within the set of rules described in this page, you may point to the format of a part either when you declare another part or when you declare a variable.

When you declare a part, you are not required to use a part as a typedef, but you may want to do so, as in the examples that are shown later. Also, you are not required to use a typedef when you declare a variable that has the characteristics of a data item; instead, you can specify all characteristics of the variable, without reference to a part.

A typedef is always in effect when you declare a variable that is more complex than a data item. For instance, if you declare a variable named myRecord and point to the format of a part named myRecordPart, EGL models the declared variable on that part. If you point instead to the format of a part named myRecordPart02, the variable is called myRecord but has all characteristics of the part named myRecordPart02.

The table and sections that follow give details on typedefs in different contexts.

Entry that points to a typedef Type of part to which the typedef can refer
function parameter or other function variable a record part or dataItem part
program parameter data item part, form part, record part
program variable (non-parameter) data item part, record part
structure item data item part, record part

Data item part as a typedef

You can use a data item part as a typedef in the following situations:

These rules apply:

Record part as a typedef

You can use a record part as a typedef in the following situations:

When you declare a structure item that points to the format of another part, you specify whether the typedef adds a level of hierarchy, as illustrated later.

These rules apply:

Form as a typedef

You can use a form part as a typedef only when declaring a program parameter.


Related concepts
DataItem part
Form part
Introduction to EGL
Record parts
Structure


Related tasks
Creating an EGL program part


Related reference
EGL statements
SQL record internals


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]