Name resolution in an expression

A name in an EGL expression can refer to any of the following:

The name resolution process is the same no matter where the expression is located (the expression might be in an assignment statement, a function call, or other position). The rules for resolving a part name are different; see EGL part resolution rules.

To resolve a name in an expression, EGL looks at the following declarations, in order:
  1. Local variables and parameters. These are the variables declared within the function. This includes the parameter list for the function, and any record variable names (but not field names within those records). No duplicate names are allowed in this category.
  2. Local I/O objects. These are I/O objects and other fields specific to the function. I/O objects might include an array of SQL records referenced in a get statement. At the same level are fields in record variables that are declared or passed as parameters to the function. Record variables declared at the function level are found in step 1; record variables declared at the program level are found in this step. It is possible to have duplicate names in this category.

    For example, two record variables might be based on the same CustomerRecord definition, each with a customerNumber field. In this case, you must qualify the name customerNumber with the name of the record variable to prevent ambiguity.

    Another example might be a program-level record variable and a function-level field with the same name. In this case, take one or more of the following actions:
    • Qualify the name of the program-level record variable with the this keyword.
    • Set the allowUnqualifiedItemReferences property to YES.
    • Qualify the field with the name of the DataTable, form, or structured record that contains it. Field names in non-structured records must always be qualified with the record name.
  3. Program variables. These are the variables declared at the program level. They include the parameter list (in the case of a called program), and any record variable names (but not field names in those records). No duplicate names are allowed in this category.
  4. Form names. These form names can be declared in any of the following ways:
    • In use declarations.
    • Specified by the inputForm property.
    • In the parameter list of the program.
    • In any I/O statements in any function in the program.
    If the use declaration refers to a FormGroup, EGL looks at all form names within the group. No duplicate names are allowed in this category.
  5. Data table names. It looks at data table names in a use declaration. No duplicate names are allowed in this category.
  6. Fields. EGL now looks at all fields within the records, forms, and data tables in steps 3-5. Duplicate names in this category must be qualified to prevent ambiguity.
  7. Library variables. These are the variables in a user library specified in a use declaration. Duplicate names in this category must be qualified with the name of the library.
  8. System variables. Finally EGL looks at the variables in the EGL system libraries. There are no duplicate names in this category.

Feedback