GLBasic forum

Main forum => Bug Reports => Topic started by: Schranz0r on 2008-Jul-27

Title: Bug in Globals!
Post by: Schranz0r on 2008-Jul-27
Code (glbasic) Select
GLOBAL a = LoadSprite2("r1.png")



WHILE TRUE

DRAWSPRITE a, 10, 10


SHOWSCREEN
WEND
END




FUNCTION LoadSprite2: name$
STATIC ID

IF DOESFILEEXIST(name$)
LOADSPRITE name$,ID
INC ID,1
RETURN ID-1
ENDIF

ENDFUNCTION


Geht net.... wieso ?
Title: Re: Bug in Globals!
Post by: Moru on 2008-Jul-27
Not bug, you can't set dynamicly in globals, you have to do that on a separate line.

Code (glbasic) Select
GLOBAL a
a = LoadSprite2("r1.png")

Title: Re: Bug in Globals!
Post by: Kitty Hello on 2008-Jul-28
That bug again!?
Title: Re: Bug in Globals!
Post by: Moru on 2008-Jul-28
When was that gone? :-)
Title: Re: Bug in Globals!
Post by: Schranz0r on 2008-Jul-28
für meine Begriffe ist es ein Fehler...

Weil normal gehts ja auch


Global a = 1
Title: Re: Bug in Globals!
Post by: Moru on 2008-Jul-28
You can't set it to something variable. A predefined number is fine but calling a function in a struct is not a good idea :-) I would like it to work too, creates cleaner looking code but it isn't working. It was working a year ago but only for one update, then all my programs stopped working and since then I'm using the long way of first creating the variable then assigning it. The reason why it doesn't work is in some other post, can't find it right now.