When using gensprite() function in a project that has "Explicit declarations" turned on, exe crashes immediately.
Everything works fine until I turn on expl.d. After that it crashes no matter whether it's turned on or off subsequently.
It's like turning it on jinxes the compiler... >:D
GLB v7.206
This is fine for me :
LOCAL a%
a%=GENSPRITE()
WHILE TRUE
PRINT a%,100,100
SHOWSCREEN
WEND
With explicit declarations with and without debug mode.
Do explicit declarations prohibit declaring GLOBAL values?
because if I declare gensprite() variable as global it crashes, if it is declared as local it does not.
LOCAL a% = GENSPRITE()
LOCAL b% = GENSPRITE()
PRINT a%, 0,0
PRINT b%, 0,10
SHOWSCREEN
KEYWAIT
This code works the first time it compiles.
Declare any variable as global = BOOM!
Even if I later turn explicit declarations off, I still can't declare global values without crashing!
Also, I'm not entirely sure how gensprite works: in the above code, both a and b are returned as zero. Wasn't it supposed to increment and return b% = 1?
Damn, I think I got it!
Apparently, I cant declare and assign gensprite() value to the variable in the same line.
ie.
global a = gensprite()
is a disaster, but ...
global a
a = gensprite()
is fine.
Yes, RGB is the only command that can be used to initialise variables when defined.
Yes, that one catches us all sooner or later :-)
Wonder why? Maybe because it says so in the GENSPRITE() help entry! :(
C/P from the help file:
GLOBAL gImgFoo = GENSPRITE(); LOADSPRITE "foo.png", gImgFoo
GLOBAL gImgBar = GENSPRITE(); LOADSPRITE "bar.png", gImgBar
DRAWSPRITE gImgFoo,0,0
DRAWSPRITE gImgBar,0,100
SHOWSCREEN
MOUSEWAIT