Revision history for ProPgVariableScope


Revision [21469]

Last edited on 2016-05-14 01:24:29 by fxm [Formatting]
Additions:
##**local.bas**##
Deletions:
**local.bas**
**Output:**


Revision [21230]

Edited on 2016-03-13 14:29:08 by fxm [Formatting]
Additions:











Revision [20667]

Edited on 2016-02-10 16:13:39 by DkLwikki [Update link format]
Additions:
- ##[[KeyPgSub|Sub]]##, ##[[KeyPgFunction|Function]]##, the main body, and each compound statement implicitly define a new local scope block.
- Explicitly declared variables using ##[[KeyPgDim|Dim]]## or ##[[KeyPgRedim|Redim]]## take the scope of the local most block in which they are declared.
- Implicit variables take the scope of the the local most ##[[KeyPgScope|Scope...End Scope]]## block in which they are first used, otherwise take the scope of the ##[[KeyPgSub|Sub]]##, ##[[KeyPgFunction|Function]]##, or main body in which they are used.
Variables declared inside ##[[KeyPgScope|Scope]]## blocks may only be declared of local scope, and are not visible outside the block. ##[[KeyPgScope|Scope]]## blocks, however, inherit the surrounding scope, so local variables declared outside the ##[[KeyPgScope|Scope]]## block will be visible inside (//see example program//).
You can declare a variable to be of local scope explicitly by using the ##[[KeyPgDim|Dim]]## statement, or implicitly by simply introducing the variable (//see [[ProPgImplicitdeclarations|Implicit Declarations]]//). The example program ##**local.bas**## demonstrates visibility rules for the local scope.
Variables can only be declared to be of shared scope at the module-level. Ie., only modules can share variables. Neither functions nor ##[[KeyPgScope|Scope]]## blocks can declare variables in the shared scope, thus variables declared there can only be local to that function or block.
You can declare a variable to be of shared scope by using the DIM statement with the ##[[KeyPgShared|Shared]]## keyword. The example program ##**shared_scope.bas**## demonstrates visibility rules for the shared scope.
Variables declared with ##[[KeyPgCommon|Common]]## are visible to other modules with a matching ##[[KeyPgCommon|Common]]## variable declaration. The variable name declared must match from between modules.
' This is executed after all other modules
Variables declared with ##[[KeyPgCommon|Common]]## are visible to other modules with a matching ##[[KeyPgCommon|Common]]## variable declaration. The variable name declared must match from between modules. Within a module the ##[[KeyPgShared|Shared]]## declaration modifier gives the variable module scope and makes the variable visible to all subs and functions.
- ##[[KeyPgScope|Scope]]##
- ##[[KeyPgDim|Dim]]##
- ##[[KeyPgCommon|Common]]##
- ##[[KeyPgShared|Shared]]##
- [[ProPgVariables|Variables]]
- [[ProPgImplicitdeclarations|Implicit Declarations]]
Deletions:
- ##[[KeyPgSub Sub]]##, ##[[KeyPgFunction Function]]##, the main body, and each compound statement implicitly define a new local scope block.
- Explicitly declared variables using ##[[KeyPgDim Dim]]## or ##[[KeyPgRedim Redim]]## take the scope of the local most block in which they are declared.
- Implicit variables take the scope of the the local most ##[[KeyPgScope Scope...End Scope]]## block in which they are first used, otherwise take the scope of the ##[[KeyPgSub Sub]]##, ##[[KeyPgFunction Function]]##, or main body in which they are used.
Variables declared inside ##[[KeyPgScope Scope]]## blocks may only be declared of local scope, and are not visible outside the block. ##[[KeyPgScope Scope]]## blocks, however, inherit the surrounding scope, so local variables declared outside the ##[[KeyPgScope Scope]]## block will be visible inside (//see example program//).
You can declare a variable to be of local scope explicitly by using the ##[[KeyPgDim Dim]]## statement, or implicitly by simply introducing the variable (//see [[ProPgImplicitdeclarations Implicit Declarations]]//). The example program ##**local.bas**## demonstrates visibility rules for the local scope.
Variables can only be declared to be of shared scope at the module-level. Ie., only modules can share variables. Neither functions nor ##[[KeyPgScope Scope]]## blocks can declare variables in the shared scope, thus variables declared there can only be local to that function or block.
You can declare a variable to be of shared scope by using the DIM statement with the ##[[KeyPgShared Shared]]## keyword. The example program ##**shared_scope.bas**## demonstrates visibility rules for the shared scope.
Variables declared with ##[[KeyPgCommon Common]]## are visible to other modules with a matching ##[[KeyPgCommon Common]]## variable declaration. The variable name declared must match from between modules.
' This is executed after all other modules
Variables declared with ##[[KeyPgCommon Common]]## are visible to other modules with a matching ##[[KeyPgCommon Common]]## variable declaration. The variable name declared must match from between modules. Within a module the ##[[KeyPgShared Shared]]## declaration modifier gives the variable module scope and makes the variable visible to all subs and functions.
- ##[[KeyPgScope Scope]]##
- ##[[KeyPgDim Dim]]##
- ##[[KeyPgCommon Common]]##
- ##[[KeyPgShared Shared]]##
- [[ProPgVariables Variables]]
- [[ProPgImplicitdeclarations Implicit Declarations]]


Revision [13577]

Edited on 2008-07-21 15:44:32 by JeffMarshall [added #lang or $lang to example]
Additions:
'$lang: "qb"


Revision [10932]

The oldest known version of this page was created on 2007-08-24 09:16:43 by JeffMarshall [added #lang or $lang to example]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode