Revision [17609]
This is an old revision of KeyPgScope made by FxMwikki on 2015-04-25 00:19:57.
SCOPE...END SCOPE
Statement to begin a new scope block
Syntax:
Scope
[statements]
End ScopeDescription:
The Scope block allows variables to be (re)defined and used locally in a program.
When a variable is (re)defined with KeyPgDim Dim within a scope structure, this local working variable can be used from its (re)definition until the end of the scope. During this time, any variables outside the scope that have the same name will be ignored, and will not be accessible by that name. Any statements in the Scope block before the variable is redefined will use the variable as defined outside the Scope.
When a variable is (re)defined with KeyPgDim Dim within a scope structure, this local working variable can be used from its (re)definition until the end of the scope. During this time, any variables outside the scope that have the same name will be ignored, and will not be accessible by that name. Any statements in the Scope block before the variable is redefined will use the variable as defined outside the Scope.
Scope..End Scope is not permitted when compiling with in the CompilerOptlang -lang qb dialect.
Examples:
Dim As Integer x = 5, y = 2
Print "x ="; x; ", "; "y ="; y
Scope
Dim x As Integer = 3
Print "x ="; x; ", "; "y ="; y
Scope
Dim y As Integer = 4
Print "x ="; x; ", "; "y ="; y
End Scope
End Scope
Print "x ="; x; ", "; "y ="; y
Print "x ="; x; ", "; "y ="; y
Scope
Dim x As Integer = 3
Print "x ="; x; ", "; "y ="; y
Scope
Dim y As Integer = 4
Print "x ="; x; ", "; "y ="; y
End Scope
End Scope
Print "x ="; x; ", "; "y ="; y
Dialect Differences:
- Explicit Scope..End Scope blocks are available only in the CompilerOptlang -lang fb and CompilerOptlang -lang deprecated dialects.
- Explicit Scope..End Scope blocks are not available in the CompilerOptlang -lang fblite and CompilerOptlang -lang qb dialects.
Differences from QB:
- New to FreeBASIC
See also:
Back to Variable Declarations