|
Post by tsh73 on Dec 14, 2018 18:08:50 GMT
Then GLOBAL declared above subs - it works
'global failure demo global x x=123 call test
end
sub test if x=0 then print "x is local" else print "x is global" end sub
x is global
Then GLOBAL declared under subs - it doesn't work
'global failure demo
x=123 call test
'end
sub test if x=0 then print "x is local" else print "x is global" end sub
global x
x is local
NOW Then GLOBAL declared under subs, but that line gets executed by GOTO or GOSUB - it STILL doesn't work. And that's IMHO, constitutes a bug. It [doesn't] work this way on JB 1.01, JB 2.0 and LB 4.5.1.
'global failure demo
gosub [makeGlobal] x=123 call test
'end
sub test if x=0 then print "x is local" else print "x is global" end sub
[makeGlobal] global x x=123 return
x is local
|
|
|
Post by B+ on Dec 15, 2018 16:08:49 GMT
Aha! try this:
'global success demo
gosub [makeGlobal] call test end
[makeGlobal] global x x=123 return
'moved the subroutine BELOW the GOSUB code! sub test if x=0 then print "x is local" else print "x is global" end sub
|
|
|
Post by tsh73 on Dec 15, 2018 18:51:07 GMT
Even better - UGH
'global success demo
gosub [makeGlobal] call test1 call test2 end
sub test1 if x=0 then print "x is local" else print "x is global" end sub
[makeGlobal] global x x=123 return
'moved the subroutine BELOW the GOSUB code! sub test2 if x=0 then print "x is local" else print "x is global" end sub
x is local x is global How's that?
|
|
|
Post by B+ on Dec 15, 2018 19:50:55 GMT
Interesting! here is Ugh X's 2:
'global testing continued call test1 call test2 end
sub test1 gosub [makeGlobal] if x=0 then print "x is local" else print "x is global" exit sub [makeGlobal] global x x=123 return end sub
'[makeGlobal] ' global x ' x=123 'return
'moved the subroutine BELOW the GOSUB code! sub test2 if x=0 then print "x is local" else print "x is global" end sub
|
|
|
Post by B+ on Dec 15, 2018 20:00:02 GMT
Ugh X's 3:
'global testing continmued
call makeGlobal call test1 call test2 end
sub test1 if x=0 then print "x is local" else print "x is global" end sub
sub makeGlobal global x x=123 end sub
sub test2 if x=0 then print "x is local" else print "x is global" end sub
Nope! (and that is really strange!) to above code but:
'global testing continmued
call makeGlobal call test1 call test2 end
sub makeGlobal global x x=123 end sub
sub test2 if x=0 then print "x is local" else print "x is global" end sub
sub test1 if x=0 then print "x is local" else print "x is global" end sub
Just fine!
|
|