Graphic bug I can't understand!

Previous topic - Next topic

Moru

It has been working now for a while again so I started using it.

MrTAToad

#16
Quotedon't do that in GLB (assigning a value when initialising/defining variables) as this is only guaranteed to work when used in conjunction with the RGB() function...
Constants should be used for things like that...

Kitty Hello

You can assign GLOBAL a = foo(), but you are not able to use strings or any of the GLBasic commands inside. The problem is, that this foo() is called in the constructor _before_ the GLBasic engine is set up, whereas
GLOBAL g
g=foo() // this assignement is done during runtime.

MrTAToad

Quote from: Kitty Hello on 2010-Jul-29
You can assign GLOBAL a = foo(), but you are not able to use strings or any of the GLBasic commands inside. The problem is, that this foo() is called in the constructor _before_ the GLBasic engine is set up, whereas
GLOBAL g
g=foo() // this assignement is done during runtime.
I tried that, but the program didn't actually run :)

Code (glbasic) Select
GLOBAL a%=foo()

DEBUG a%
END

FUNCTION foo%:
RETURN 12
ENDFUNCTION

okee

Regarding the scope of Global Local
From tests this is what i gathered:

2 files in a project
main.gbas //the main code file
include.gbas //included file

Global  declared in main.gbas is available to main.gbas and include.gbas
Global declared in include.gbas must have an assignment otherwise the compiler throws variable is not explicitly defined error
once declared with an assignment it's available to main.gbas and include.gbas

Local declared outside a function/sub in main.gbas is only available to functions/subs in main.gbas
Local outside a function/sub in include.gbas  is not allowed

Also using GENSPRITE() as described in the manual
Code (glbasic) Select
GLOBAL gImgFoo = GENSPRITE(); LOADSPRITE "foo.png", gImgFoo
used to cause problems when declaring and assigning has this changed ?
or do we still have to do
Code (glbasic) Select
GLOBAL gImgFoo
gImgFoo = GENSPRITE()



okee
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

MrTAToad

RGB is the only command that be used with variable initialisation.

matchy

Oh yeah! Even this works...
Code (glbasic) Select

CONSTANT rnd_color=RGB(RND(255),RND(255),RND(255))
CONSTANT rnd_red=RND(255)