Author Topic: GENSPRITE() crash  (Read 4211 times)

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
GENSPRITE() crash
« 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.

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #1 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 :)

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: GENSPRITE() crash
« Reply #2 on: 2009-Oct-05 »
The compiler doesn't crash, it passes through the compiler and crashes as an .exe

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #3 on: 2009-Oct-05 »
Mine crashed the compiler...

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: GENSPRITE() crash
« Reply #4 on: 2009-Oct-05 »
Woo!  =D

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #5 on: 2009-Oct-05 »
Its probably the better choice :)

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #6 on: 2009-Oct-10 »
It doesn't crash the compiler now - just the executable.

Offline FutureCow

  • HelpEditor
  • Prof. Inline
  • ******
  • Posts: 680
    • View Profile
Re: GENSPRITE() crash
« Reply #7 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.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1619
  • Particle Hawk
    • View Profile
Re: GENSPRITE() crash
« Reply #8 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.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #9 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.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1619
  • Particle Hawk
    • View Profile
Re: GENSPRITE() crash
« Reply #10 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()
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #11 on: 2009-Oct-11 »

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1619
  • Particle Hawk
    • View Profile
Re: GENSPRITE() crash
« Reply #12 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()

Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

MrTAToad

  • Guest
Re: GENSPRITE() crash
« Reply #13 on: 2009-Oct-11 »
If its not a constant value or RGB, then it wont be allowed :)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10776
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: GENSPRITE() crash
« Reply #14 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.