Global variables

BlitzPlus Forums/BlitzPlus Programming/Global variables

Joerg B.(Posted 2004) [#1]
is there a way to you have global variables by default, or do i have to declare one by one..?
Thank you!!!


soja(Posted 2004) [#2]
If you have a variable inside a function that you want to be global, yes, you must declare it as global outside the function.

You can do this, though:
Global i%, j%, k%, str$, str2$, str3$, percent1%, percent2%

Function myfunc()
    i% = 1            ; These would be local
    str$ = "Hello"    ; if they weren't declared
    percent1% = .75   ; as Global outside of this scope
End Function