11.10 Block-EndBlock statement

 
Block <block-code> EndBlock

The Block statement simply executes the following code in a separate scope. This function is of rare use. Normally you will not need this. Here is an example:

 
For k = 1 To 100
    Block
        Local k
        For k = 1 To 2
            DebugPrint(k)
        Next
    EndBlock   ; local "k" will be deleted now
Next

The code above uses two variables with the name k in two nested loops. This is only possible because we put the inner loop in its own block and created a new local variable k in that block. This local variable is only accessible in this block. After the EndBlock statement the local variable k will be deleted and the global k will be used again.


Show TOC