Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize


Visual Studio .NET 2003

Creates regional variables and arrays.

#REGION nRegionNumber


#REGION nRegionNumber
Creates a region. Regional variables must be declared before they are used in a program. Note that #REGION is a compiler directive, not a command. nRegionNumber specifies a region number 0 through 31.
Declares the variables for the region created with the #REGION directive. VarList is a list of variables and arrays separated by commas.

During program compilation, if another identically named regional variable has already been compiled when a regional declaration is encountered, the second occurrence of the variable name is made unique to ensure there is no conflict with the previously declared regional variable.

A variable's name is made unique by padding the regional variable's name out to 10 characters with underscores and the current region number. This substitution takes place entirely during program compilation and has no effect on execution speed.

When a variable name is modified, use DISPLAY MEMORY to display the modified variable name. To monitor the variable in the Debug window, use its modified variable name. Since the Trace window uses the original program source code, the original variable name (not the modified name created by the compiler) appears in the Trace window.


Variables or arrays with identical names will not interfere with each other if their values are protected within a "region." Regional variables are similar to private variables.


In the following example, two sets of regional variables are created. In region 1, the variables gcA, gcB, gcC, and gcD are created, and the character string "One" is stored to each. In region 2, the variables gcC, gcD, gcE and gcF are created, and the character string "Two" is stored to each. The variables gcC and gcD are common to both regions.

The output from DISPLAY MEMORY is then shown. The names of variables gcC and gcD are modified in the second region. gcC becomes GCC________2, and gcD becomes GCD________2. All the variables are private and can be accessed by lower-level programs.

REGIONAL gcA,gcB,gcC,gcD
STORE 'One' to gcA,gcB,cgC,gcD
REGIONAL gcC,gcD,gcE,gcF     && gcC and gcD are common to both regions
STORE 'Two' to gcC,gcD,gcE,gcF
DO showmemory

PROCEDURE showmemory

See Also


© 2015 Microsoft