GLBasic forum

Main forum => GLBasic - en => Topic started by: AlienMenace on 2011-Mar-21

Title: Having a problem with single dimensioned array
Post by: AlienMenace on 2011-Mar-21
Hello,

I try this code:

GLOBAL enemy_ID
DIM enemy_ID[7]
enemy_ID[1]=1

and receive this result:


*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.7.861 SN:741e258f - 3D, NET
Wordcount:2 commands
compiling:
C:\Users\test\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\test\AppData\Local\Temp\glbasic\gpc_temp0.cpp:49: error: no matching function for call to `DIM(DGInt&, int)'
C:/Coding/GLBasic/Compiler/platform/Include/glb.h:861: note: candidates are: void __GLBASIC__::DIM(__GLBASIC__::DGIntArray&, DGNat, DGNat, DGNat, DGNat)
C:/Coding/GLBasic/Compiler/platform/Include/glb.h:862: note:                 void __GLBASIC__::DIM(__GLBASIC__::DGNatArray&, DGNat, DGNat, DGNat, DGNat)
C:\Users\test\AppData\Local\Temp\glbasic\gpc_temp0.cpp:53: error: `__GLBASIC__::enemy_ID' cannot be used as a function
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 1.1 sec. Time: 00:51
Build: 0 succeeded.
*** 1 FAILED ***

What am I doing wrong?
Thanks.
Title: Re: Having a problem with single dimensioned array
Post by: Moru on 2011-Mar-21
You declare a variable, not an array I believe
Title: Re: Having a problem with single dimensioned array
Post by: ampos on 2011-Mar-21
GLOBAL enemy_ID[]
Title: Re: Having a problem with single dimensioned array
Post by: Ian Price on 2011-Mar-21
You missed out the brackets [] after the GLOBAL definition

Code (glbasic) Select

GLOBAL enemy_ID[]

DIM enemy_ID[7]

enemy_ID[1]=1


WHILE TRUE

PRINT enemy_ID[1],10,10

SHOWSCREEN

WEND


This now works fine.
Title: Re: Having a problem with single dimensioned array
Post by: AlienMenace on 2011-Mar-21
That did the trick, thanks guys!