TYPE question for Gernot...

Previous topic - Next topic

bigsofty

Code (glbasic) Select
TYPE at
 a
 b[0][0]
ENDTYPE

GLOBAL c AS at

REDIM c.b[10][10]
Is this an OK way to store a 2 dimensional array variable name in a type? The reason I ask, is that if I use a 1 dimensional array I would use the code...
Code (glbasic) Select
TYPE at
 a
 b[]
ENDTYPE
Notice the lack of '0', but if I try...

Code (glbasic) Select
TYPE at
 a
 b[][]
ENDTYPE
I get a syntax error.

I don't mind using the
  • s if need be?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

If you want it pre-sized, use:
Code (glbasic) Select
TYPE Ttyp
array[5][6]

ENDTYPE
Otherwise just array[].
You can DIM any array with any dimensions (up tp 4).
Like:

Code (glbasic) Select
LOCAL a[]
DIM a[5]
DIM a[13][12]

bigsofty

So for a 2 dimensional array that is not DIMed yet I just put in ...
Code (glbasic) Select
TYPE at
 b[]
ENDTYPE

GLOBAL c AS at

REDIM c.b[10][10]
...Just tried this, it seems to work fine.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)