GLBasic forum

Main forum => Bug Reports => Topic started by: MrTAToad on 2011-Oct-01

Title: GLOBAL in FUNCTION
Post by: MrTAToad on 2011-Oct-01
With this :

Code (glbasic) Select
DEBUG x%

FUNCTION moo%:
GLOBAL x%
ENDFUNCTION


Whilst it doesn't cause compiling to fail, it does produce a "variable already exists" warning message if the variable isn't given a variable, like :

Code (glbasic) Select
FUNCTION moo%:
GLOBAL x%=5
ENDFUNCTION


There is unfortunately a slight problem with the code too - try and run it and the program seems to hang before the DEBUG command...

Therefore I feel that a GLOBAL in a function (and possibly subroutine) should produce a compiler error.
Title: Re: GLOBAL in FUNCTION
Post by: Kitty Hello on 2011-Oct-04
Strange. It worked for me. It debugged "0".

Add some code after the DEBUG, maybe?
Title: Re: GLOBAL in FUNCTION
Post by: MrTAToad on 2011-Oct-04
I also tried with :

Code (glbasic) Select
DEBUG "1\n"
DEBUG x%
DEBUG "2\n"

FUNCTION moo%:
GLOBAL x%
ENDFUNCTION


Just get "starting debug session"

Try to compile again, and I get the "debugger is still running" message