05-18-2024, 08:20 PM
It's not possible - all variables in QB64 are scoped to the main code or to the sub/function they're in, there is no local scope for loops or IF's like in other languages. Ex: This is not valid in C but is valid in QB64:
That's perfectly valid code that prints 40, but the `b` is declared inside of the `If`. Despite that, the `b` still exists everywhere after the `Dim` regardless of control structures, it's not scoped to only inside of the `If` that it was declared inside of.
That said it is potentially something that could be introduced, maybe a `Dim _Local` or something, but that's never been discussed.
Code: (Select All)
a = 20
If a = 20 Then
Dim b As Long
b = 40
End If
Print b
That's perfectly valid code that prints 40, but the `b` is declared inside of the `If`. Despite that, the `b` still exists everywhere after the `Dim` regardless of control structures, it's not scoped to only inside of the `If` that it was declared inside of.
That said it is potentially something that could be introduced, maybe a `Dim _Local` or something, but that's never been discussed.