GLBasic forum

Main forum => Bug Reports => Topic started by: FutureCow on 2009-Oct-04

Title: GENSPRITE() crash
Post by: FutureCow on 2009-Oct-04
Here's a one line program that crashes on WinXP

Code: (glbasic) [Select]
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
Code: (glbasic) [Select]
MouseSpriteId=GENSPRITE()

or

GLOBAL MouseSpriteId
MouseSpriteId=GENSPRITE()
it no longer crashes.
Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-04
RGB is the only command that you can use to initialise a variable.

However, the compiler (gpc) certainly shouldn't crash :)
Title: Re: GENSPRITE() crash
Post by: FutureCow on 2009-Oct-05
The compiler doesn't crash, it passes through the compiler and crashes as an .exe
Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-05
Mine crashed the compiler...
Title: Re: GENSPRITE() crash
Post by: FutureCow on 2009-Oct-05
Woo!  =D
Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-05
Its probably the better choice :)
Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-10
It doesn't crash the compiler now - just the executable.
Title: Re: GENSPRITE() crash
Post by: FutureCow on 2009-Oct-11
Quote
RGB 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.
Title: Re: GENSPRITE() crash
Post by: Hemlos on 2009-Oct-11
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.
Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-11
Quote
As 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.
Title: Re: GENSPRITE() crash
Post by: Hemlos on 2009-Oct-11
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()
Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-11
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)
Title: Re: GENSPRITE() crash
Post by: Hemlos on 2009-Oct-11
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()

Title: Re: GENSPRITE() crash
Post by: MrTAToad on 2009-Oct-11
If its not a constant value or RGB, then it wont be allowed :)
Title: Re: GENSPRITE() crash
Post by: Kitty Hello on 2009-Oct-12
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.
Title: Re: GENSPRITE() crash
Post by: FutureCow on 2009-Oct-12
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.