Hi,
I have a program where, before the game loop, there is the following statement:
DIM classe$[2][2]
When I compile the program the following message appears:
----------------------------------------
Random.gbas"(32) error : variable is not explicitly defined : classe$
----------------------------------------
The strangest thing is that in one of the sample programs (The First Game) the same structure does not give rise to any problem.
What did I miss?
Best regards
You either need to define the variable 1st, by using using LOCAL/GLOBAL/STATIC, or turn of explicit declarations in the project options. Please use the search funtions if you need more informations about this issue, there are many threads about this.
Make sure the variable is not locally defined in a function elsewhere.
Hehe, ok :)
Like kanonet say:
LOCAL classe$
DIM classe[2][2]
@ Gernot( if you read this) :
Is there any way to do something like ( v11 :P ):
GLOBAL DIM classe[2][2]
?? ;)
In the GLBasic menu, go to "Project" -> "Options" and there is a checkbox "Explicit declarations". If this is checked, you must declare all your variables. You can uncheck it and you won't get the error message. However, I would recommend you always have this option enabled (checked).
For example, look at the following code:
mystring$ = "test"
PRINT mysting$, 10, 10
With "Explicit declarations" enabled, you'll get an error and you'll quickly notice the typo "mysting$" instead of "mystring$". When it's disabled it will just compile, automatically create 2 variables "mysting$" and "mystring$" and the code doesn't print anything, and then you have to go find the mistake yourself. ;)
Quote from: BdR on 2013-Feb-04
With "Explicit declarations" enabled, you'll get an error and you'll quickly notice the typo "mysting$" instead of "mystring$". When it's disabled it will just compile, automatically create 2 variables "mysting$" and "mystring$" and the code doesn't print anything, and then you have to go find the mistake yourself. ;)
Oh yeah... makes me think of Python... Beautiful, powerful scripting language. But all hell breaks loose if you have a typo in variable name or wrongly placed whitespace indent. =D
Then there are C style languages where you spend more time writing declarations than actual implementations.
And GLBasic once again sits in the golden middle! :good: