Correct use of GLOBAL?

Previous topic - Next topic

Gary

I like to try to keep any production code free from any warnings just in case something goes wrong its one less thing to look at but am struggling with the use of the GLOBAL command.

I assume all the globals should be set right at the top of the program and is as simple as

Code (glbasic) Select
GLOBAL variable_name

for everything used that is a global variable

The example gives

Code (glbasic) Select
GLOBAL array_name[]

for defining arrays but if I try

Code (glbasic) Select
GLOBAL array_name[][]

I get syntax error.

How do you define a 2 and 3 dimensional array as a global?

Thanks
Gary

backslider

Hi!

Your solution is:

Code (glbasic) Select

//define the array
Global array[]

//set the array dimensions
DIM array[4][3]

Gary

ah thanks for that, I did try that and it seemed to work but wondered if because it was defined in the global as a single dimension and then set as a 2 dimension if it would cause problems

ampos

Beware you can access multidimensional Variabkes as single-dimensions and GLB will not say anything.

A[12]=A[12][0]