Scope...End Scope
Statement to begin a new scope block
Syntax
`
Scope
[statements]
End Scope
`
Description
The Scope block allows variables to be temporarily (re)defined and used in a program. When a variable is defined with `Dim` within a scope structure, that variable can be used 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 dimensioned will use the variable as defined outside the Scope.
`Scope..End Scope` is not permitted when compiling with in the -lang qb dialect.
Example
`
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
`
Dialect Differences

- Explicit SCOPE..END SCOPE blocks are available only in the -lang fb and -lang deprecated dialects.
- Explicit SCOPE..END SCOPE blocks are not available in the -lang fblite and -lang qb dialects.

Differences from QB

- New to FreeBASIC

See also

- `Dim`