regional
regional { statements; }
regional () statement;
regional () { statements; }
In the statement or code block following the regional function, all local (and regional) variables accessible here will also be visible in the
code of user-defined functions called further from here. This feature is useful for making a large number of variables accessible in the code of the
user-defined function called, without using numerous function parameters or global variables.
Variables which are neither system variables, global variables, nor local variables, are defined as regional variables as they are defined
by the calling code and made visible.
Indirect parameter passing is disabled
0
define procedure( zoo )
{
echo('Zoo in ', city[], ' ', country[]);
city[] = Cambridge; // city and country are regional variables
country[] = United Kingdom;
echo( " Scope of country[] in 'zoo': ", scope(country[]), " and city[]: ", scope( city[]) );
}
define procedure( bar )
{
country[] = USA; // country is a local variable, but city is not
echo('Bar in ', city[], ' ', country[]);
regional // Alternative formulation
{
zoo;
}
echo('Bar in ', city[], ' ', country[]); // Cambridge, UK
echo( " Scope of country[] in 'bar': ", scope(country[]), " and city[]: ", scope( city[]) );
}
define procedure( foo )
{
city[] = Boston;
regional() bar;
echo('Foo(d) in ', city[]); // Cambridge
}
// Main program
foo;
Bar in Boston USA
Zoo in Boston USA
Scope of country[] in 'zoo': regional and city[]: regional
Bar in Cambridge United Kingdom
Scope of country[] in 'bar': local and city[]: regional
Foo(d) in Cambridge