Databases Reference
In-Depth Information
I will discuss the scope and lifetime of a variable next (but I will not generally include
scope prefixes in variable names).
10.4.11 Variable Scope
Variables and constants have a scope , which indicates where in the program the variable
or constant is recognized (or visible to the code). The scope of a variable or constant can
be either procedure-level (also called local), module-level private, or module-level
public. The rules may seem a bit involved at first, but they do make sense.
10.4.11.1 Procedure-level (local) variables
A local or procedure-level variable or constant is a variable or constant that is declared
within a procedure, as is the case with the variable LocalVar and the constant
LocalConstant in Figure 10-2. A local variable or constant is not visible outside of the
procedure. Thus, for instance, if we try to run ProcedureB in Figure 10-2, we will get the
error message, “Variable not defined,” and the name LocalVar will be highlighted.
Figure 10-2. Examples of variable scope
Search WWH ::




Custom Search