Implicitly created GLOBAL?

Previous topic - Next topic

bigsofty

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
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

right. It implicitly creates a local now. The message is wrong. Try it?

bigsofty

#2
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
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)