GLOBAL in FUNCTION

Previous topic - Next topic

MrTAToad

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.

Kitty Hello

Strange. It worked for me. It debugged "0".

Add some code after the DEBUG, maybe?

MrTAToad

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