Quote: "I'm pretty sure that "global variables" are slightly different to arrays"
You are correct they are. Numeric and string variables are single entities. Single dimensioned arrays are long 'chains' of these variables in a line - with Dim() used to state in the brackets how many links you want in the 'chain'.
The confusion has arisen because this is the Dark Basic Classic board - notice where you are Games 2 Live?

and akzel's original post asked about Global Variables.
In DB Classic, they do NOT exist - only in DB Pro.
Sven B correctly stated that to get around this limitation, in DBC you can use arrays as global variables if you need them.
Just do a Dim VariableName(0) and then use VariableName(0) instead of just 'VariableName' and as long as the Dim is outside your functions, they can see and alter the contents.
Any arrays dimensioned
inside a function cannot be seen outside that function.
SimSmall
The DBC help files aren't brilliant and do contain errors. However, the section of the help you showed in your screenshot
is wrong - but not the exact section you highlighted. It actually says:
Quote: "Any variables declared in the function are what are known as local variables. Local variables can only be recognized and used from within the function."
Correct. Use Dim MyVar(0) in Function X then it is local to that function and can't be seen outside it.
Quote: "Global variables on the other hand are variables declared outside of any function."
Here it's referring to global as being available to the rest of the
main program - not inside functions. It is confusing because the term 'global' has been used whereas I would have used the term 'normal'.
Quote: "Your function cannot recognize or use global variables."
Again, replace 'global' with 'normal' and it reads a lot better.
Quote: "The same rules apply to arrays and parameters passed into the function. Parameters declared by the function can be used in the same way you would use any local variable, in order to bring information from the outside world."
And this is where the real error is. This paragraph refers to arrays and variables passed to a function in the parameter list as being local. In fact, you can't pass an array to a function in that way - only normal variables.
The fact is that arrays dimensioned outside of a function shouldn't actually be global either and the fact that it works is a convenient bug - but a bug none-the-less.
There's also another little-known bug in DBC's functions which I always found quite convenient - non-destructive local variables.
When a variable is declared in a function, on exit from that function, all local variables are destroyed. When you use the function the next time, you start again from scratch with all local variables set to 0 (zero) or in the case of strings, Null ("").
Well, that's how it's supposed to be. In fact, DB doesn't destroy the local variables, so the next time you call the function, all the variables are still set to the value they were last time.
An example:
TestFunc
Print "Value of A in main program on return from function: ";A
Print
Print "Press A Key To Call The Function Again"
Print
Wait Key
TestFunc
Print "Value of A in main program on return from function: ";A
Wait Key
Function TestFunc
If A=0
A=100
Print "Just made A equal 100"
Else
Print "A is already 100 (should be 0)"
Endif
Print "(A inside the function is now ";A;")"
Print
EndFunction
In this example, when you press a key to call the function a second time, A should be zero, but as it wasn't destroyed the last time the function was exited, it's still 100.
This to me can be very useful, but worth bearing in mind if you trying to track down bug and assume that DB's functions work like other languages.
TDK_Man