The part is a crucial concept in EGL. A part refers
to an independent part of an application. No part can exist inside
of another part. Parts can be as large as a Service or as small as
a single DataItem.
A variable is a named entity in either an EGL logic
part or Record. Variables are based on data parts, which means that
a variable reserves storage for a particular kind of data. For more
information, see Variables.
If you declare a variable or constant in a part, that identifier
is in scope throughout the part:
- If the declaration is in a function, the identifier is in the
local scope of the function. For example, if the function getCustomer() declares
the variable runningBalance, any code in getCustomer() that
follows the declaration can reference runningBalance.
You
can pass the variable as an argument to another function, but the
original identifier is not available in the called function. Instead,
the name of the corresponding parameter in the receiving function
declaration is available in the called function.
- If the declaration is in a generatable part (such as a Program)
but is outside of any function (including the main() function),
the name is global to that part. Refer to the name without
qualifying it in any function called by the part. For example, if
a program declares runningBalance outside of a function
and invokes getCustomer(), which in turn invokes getCustomerBalance(), runningBalance is
available throughout both functions.
- If the declaration is in a Library part, but outside of a function,
the identifier is in scope within the run unit (a set
of programs that operate together; see Run unit).