Here's a one line program that crashes on WinXP
GLOBAL MouseSpriteId=GENSPRITE()
That's the format the example in the manual uses for the GENSPRITE command.
If on the other hand I get rid of the GLOBAL statement as follows
MouseSpriteId=GENSPRITE()
or
GLOBAL MouseSpriteId
MouseSpriteId=GENSPRITE()
it no longer crashes.
RGB is the only command that you can use to initialise a variable.
However, the compiler (gpc) certainly shouldn't crash :)
The compiler doesn't crash, it passes through the compiler and crashes as an .exe
Mine crashed the compiler...
Woo! =D
Its probably the better choice :)
It doesn't crash the compiler now - just the executable.
QuoteRGB is the only command that you can use to initialise a variable
As a matter of interest, does it say that in the doco somewhere? I must have overlooked it.
Quote from: FutureCow on 2009-Oct-04
Here's a one line program that crashes on WinXP
Youre right, this happened to me also...one time, the first time i tried the same thing by declaring global.
I tested it again, and the exe next crashed.
And every test after, the compile doesnt crash, just the exe.
QuoteAs a matter of interest, does it say that in the doco somewhere? I must have overlooked it.
It's not in the documents per se (except for my online documentation) but if you look in log_e.gbas, V6.247 does state : RGB works for GLOBAL assignments.
Quote from: MrTAToad link=topic=3598.msg26395#msg26395 V6.247 does state : RGB works for GLOBAL assignments.
/quote]
Thats means, "It is working now, and it wasnt previously".
It doesnt mean its the only one used with global.
You should declare every value, global or local, or local global.
And this is the reason i tried to GLOBAL a=gensprite()
See what Kitty wrote about it : http://www.glbasic.com/forum/index.php?topic=1571.0 (http://www.glbasic.com/forum/index.php?topic=1571.0)
I see what you mean now.
What i meant is this:
GLOBAL a,b,c,d,e,f
a=0
b=142346
c=RGB(blahblahblah)
d=GENSPRITE()
If its not a constant value or RGB, then it wont be allowed :)
Background: The global vaiables with initial values are initialized _before_ the main engine initializes. Thus, many of the functions will not work because the framework is not ready, yet.
Is it possible to have the precompiler pick that up? It would be a lot nicer to have an error message than an unexpected crash.