{{fbdoc item="title" value="SCOPE...END SCOPE"}}----
Statement to begin a new scope block

{{fbdoc item="syntax"}}##
	**Scope**
		[//statements//]
	**End Scope**
##
{{fbdoc item="desc"}}
	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.
	
	The local variables are reserved on stack at granularity level of each procedure (including the main part of the program), not at granularity level of each individual scope block. So a same memory space can be used by local variables belonging to different scope blocks.
	
	To access duplicated symbols defined as global outside the scope block, add one or preferably two dot(s) as prefix: ##.""SomeSymbol""## or preferably ##..""SomeSymbol""## (or only ##..""SomeSymbol""## if inside a [[KeyPgWith|With..End With]] block).
	
	##**Scope..End Scope**## is not permitted when compiling with in the //[[CompilerOptlang|-lang qb]]// dialect.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/variable/scope.bas"}}%%(freebasic)
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
%%

{{fbdoc item="lang"}}
	- 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.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgDim|Dim]]##
	- ##[[KeyPgRedim|Redim]]##
	- ##[[KeyPgStatic|Static]]##
	- ##[[KeyPgVar|Var]]##
	- ##[[KeyPgByrefVariables|Byref (variables)]]##

{{fbdoc item="back" value="CatPgVariables|Variable Declarations"}}