GLBasic forum

Feature request => IDE/Syntax => Topic started by: bigsofty on 2010-Nov-08

Title: Implicitly created GLOBAL?
Post by: bigsofty on 2010-Nov-08
When outside a sub/func this, IMHO, should be GLOBAL by default but when inside a SUB/func, I think creating a GLOBAL is simply not right unless the GLOBAL keyword is used. LOCAL should be the default in a sub/func.

Cheers,


Ian
Title: Re: Implicitly created GLOBAL?
Post by: Kitty Hello on 2010-Nov-08
right. It implicitly creates a local now. The message is wrong. Try it?
Title: Re: Implicitly created GLOBAL?
Post by: bigsofty on 2010-Nov-08
Nope, its creating a GLOBAL I am afraid, even when the var is defined within a function.

Code (glbasic) Select
myfunc()
myfunc2()

SHOWSCREEN
MOUSEWAIT

FUNCTION myfunc:
blah = 10
ENDFUNCTION

FUNCTION myfunc2:
PRINT blah, 100, 10
ENDFUNCTION


Displays "10", if it was defined within the function as a LOCAL the value would have been lost.

Cheers,


Ian