EGL resolves a variable reference by static or dynamic access:
- When dynamic access is in effect, the field name and type are known
only at run time. Your code determines the name from a value in the code or
from runtime input.
Dynamic access is in effect when your code is referencing
any of these:
- When static access is in effect, the field name and type are known
at generation time, and the name is always consistent with the naming conventions
for EGL identifiers. The name is not used at run time.
Static access is
in effect when your code is referencing any of these:
- A variable that is outside of any container and whose type is other than
ANY
- A field in a fixed record
- A field in a non-fixed record, when the chain of relationships that led
to that field (from variable to field to subfield) is such that every reference
used static access
Consider an example in which the values in a dictionary include a fixed
record and a non-fixed record:
// a fixed record part
Record myFixedRecordPart type=serialRecord
{
fileName = "myFile"
}
10 ID INT;
10 Job CHAR(10);
end
// a record part (not fixed)
Record myDynamicRecordPart type=basicRecord
ID INT;
Job CHAR(10);
end
Program myProgram
dynamicPerson myDynamicRecordPart;
myFlexID INT;
fixedPerson myFixedRecordPart;
myFixedID INT;
Function main()
dynamicPerson.ID = 123;
dynamicPerson.Job = "Student";
fixedPerson.ID = 456;
fixedPerson.Job = "Teacher";
relationship Dictionary
{
dynamicRecord=dynamicPerson,
staticRecord=fixedPerson
};
end
end
end
The following rules apply:
- A reference to a dictionary value is dynamic and every subordinate reference
is dynamic. Consider the effect if the code included the following statements:
myDynamicID INT;
myDynamicID = relationship.dynamicRecord.ID;
The reference to dynamicRecord would be dynamic, and the reference
to ID would be dynamic, with the identifier ID visible at run time.
- A reference that begins with a fixed structure can reference only the
memory internal to that structure. In the current example, a reference that
begins with fixedPerson can access the fields ID and JOB in the fixed record
but can access no other fields.
- Your code can access a fixed structure dynamically but the same reference
statement cannot access the fields of that field. In the current example,
the following reference would not be valid because the identifier ID is
not available at run time:
myFixedID INT;
// NOT valid
myFixedID = relationship.fixedRecord.ID;
You could handle the problem by declaring another fixed record
and assigning it values from the fixed record that is in the dictionary:
myFixedID INT;
myOtherRecord myFixedRecordPart;
myOtherRecord = relationship.staticRecord;
myFixedID = myOtherRecord.ID;
Dynamic access is valid in assignments (on the left- or right-hand sides);
in logical expressions; and in the statements set, for,
and openUI.