- If you are referencing an item that is described by a structure item, you
can avoid ambiguity about the area of memory being referenced. Consider
the following part declaration, for example:
Record myRecordPart type serialRecord
{
fileName = myFile
}
10 myTop;
20 myNext;
30 myAlmost;
40 myItem CHAR(10);
40 myItem02 CHAR(10);
end
Assume that a function or program uses the record part
myRecordPart as a typeDef when declaring a variable named
myRecordVar.
If you want to refer to an item that has the characteristics of a specific
structure item, you can include the following symbols in order:
- The name of the variable that points to the format of the part; in
this case, myRecordVar
- A period (.)
- A list of structure items superior to the item, with a period separating
each structure item from the next; for example,
myTop.myNext.myAlmost
- The item name preceded by a period; for example,
.myItem
A valid reference to myItem in myRecordVar is as follows:
myRecordVar.myTop.myNext.myAlmost.myItem
That reference is considered to be fully qualified.
- If you want to refer to an item that has the characteristics of a
structure item whose name is unique within a structure, you can specify the
variable name, followed by a period, followed by the item name. Valid
references for the earlier example include this symbol:
myRecordVar.myItem02
That references are considered to be partially qualified.
You cannot partially qualify an item name in any other way. You
cannot include only some of the structure item names that are between the
variable name and the item name, for example, nor can you eliminate the
variable name while keeping any of the names of structure items that are
superior to the item. The following references are not valid
for the earlier example:
// NOT valid
myRecordVar.myNext.myItem
myRecordVar.myAlmost.myItem
myNext.myItem
myAlmost.myItem
- You can refer to an item without preceding the name with any
qualifiers. Valid references for the earlier example include these
symbols:
myItem02
myOtherItem
Those references are considered to be unqualified.
- You must qualify any reference to a structure item to the extent necessary
to avoid ambiguity. It is recommended that you use fully qualified
names whenever possible. You must use an unqualified reference,
however, when you are specifying a record property that refers to a
key item, variable length item, or number of occurs item. (In an EGL
statement, you can reference those special structure items as you would
reference any structure item.)
- Unqualified and partially qualified references can be valid only if you
set the property allowUnqualifiedItemReferences to
yes. That property is a characteristic of programs, page
handlers, and libraries, and the default value is no.
- The name of a structure item can be an asterisk (*) if the related memory
area is a filler, which is an area whose name is of no
importance. You cannot include an asterisk in a reference.
Consider this example:
record myRecordPart type serialRecord
{
fileName = myFile
}
10 person;
20 *;
30 streetAddress1 CHAR(30);
30 streetAddress2 CHAR(30);
30 nation CHAR(20);
end
If you use that part as a typeDef when declaring the variable
myRecordVar, you can refer to myRecordVar.nation
or nation, but the following references are not valid:
// NOT valid
myRecordVar.*.streetAddress1
myRecordVar.*.streetAddress2
myRecordVar.*.nation
- When EGL tries to resolve a reference, names of local variables are
searched first, then names of structure items in the records used for I/O in
the same function, then names of other local structure items, then names that
are program-global.
Consider the case in which a function declares both a data item called
nation and a variable that points to the following basic
record:
record myRecordPart
10 myTop;
20 myNext;
30 nation CHAR(20);
end
An unqualified reference to nation refers to the data item, not
to the structure item.
- A name search shows no preference for program-global data items over
program-global structure items. Consider the case in which a program
declares both a data item called nation and a variable that points
to the format of the following basic record:
record myRecordPart
10 myTop;
20 myNext;
30 nation CHAR(20);
end
An unqualified reference to nation fails because
nation could refer either to the data item or to the structure
item. You can reference the structure item, but only by qualifying the
reference.
- The fully qualified name of a program variable must be unique among
program variables; and the name of a function variable must be unique
among function variables.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.