Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop variables
#2
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:

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.
Reply


Messages In This Thread
Loop variables - by Kernelpanic - 05-18-2024, 08:13 PM
RE: Loop variables - by DSMan195276 - 05-18-2024, 08:20 PM
RE: Loop variables - by SMcNeill - 05-19-2024, 07:45 PM
RE: Loop variables - by Kernelpanic - 05-18-2024, 08:43 PM
RE: Loop variables - by Kernelpanic - 05-18-2024, 09:55 PM
RE: Loop variables - by DSMan195276 - 05-19-2024, 12:43 AM
RE: Loop variables - by Kernelpanic - 05-19-2024, 07:22 PM
RE: Loop variables - by SMcNeill - 05-19-2024, 07:33 PM



Users browsing this thread: 7 Guest(s)