Condividi tramite


REGIONAL Command

Creates regional variables and arrays.

#REGION nRegionNumber
REGIONAL VarList

Parameters

  • #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.

  • REGIONAL VarList
    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.

Remarks

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.

Example

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.

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

PROCEDURE showmemory
DISPLAY MEMORY LIKE g*

See Also

PRIVATE | PUBLIC | STORE