Hi, just a slight issue. Whenever I try to do anything useful with for loops, I get something like this:
C:\DOCUME~1\(Username removed)\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\DOCUME~1\(Username removed)\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:89: error: `n' was not declared in this scope
*** FATAL ERROR - Please post this output in the forum
the related code will be simply a FOR loop with something inside it. This exact errormessage was generated from this:
LET n=1
FOR n=0 TO 1 STEP 0.1
ALPHAMODE n
LOADSPRITE "(Filename Removed)",0
DRAWSPRITE 0, 300, 150
SHOWSCREEN
KEYWAIT
NEXT
Any ideas?
That error message means that you have enabled explicit variable declaration and haven't defined the variable "n"
There is nothing in the help about option explicit and I haven't touched anything.
Edit: I found the Option Explicit box. It's not ticked. Any other ideas?
This is why I hate anything that has anything to do with C - things always go wrong when the C bit compiles. C is the worst language ever made (yes, that includes COBOL and Malbolge) as it will often randomly decide it hates you and won't work.
Remove the "LET n=1" and it works.
I tried that before and it didn't work. However, I've just tried again and it has. Any idea why it randomly changed it's mind (other than the fact that C does that in my experience)?
LOCAL n#
;) btw: LET is out!
LET probably checks to see if the variable is defined when you assign a value - and thus you get the message...
Quote(other than the fact that C does that in my experience)
The
only time it will seem to do this is overwriting random parts of memory - which is due to programmer error...
Have you recently updated your copy of GLBasic ?
Did it earlier today, when I first started it up...
As for LET, I like to stick it in if something isn't working, just to see if that's the problem...
LOADSPRITE "sprite.png",1;
n=0.0015;
WHILE TRUE
IF n<1; n=n+0.0015;ENDIF;
ALPHAMODE -n; DRAWSPRITE 1, 300, 150; ALPHAMODE 0;
SHOWSCREEN; WEND