03-14-2011, 12:57 PM
Okay, I figured out what it is... and it's a weird one, to say the least! :-)
This is a revised version of the code above but with the value being stored in an element of a String array instead of in a standalone String. It compiles and works perfectly with the new version of ZXBasic:
However.... if I take out all of the literal '1' values and make the array index a variable instead, the code no longer works - you get a blank value at the final 'print'.
Hopefully that makes some sense to you, boriel! :-D
This is a revised version of the code above but with the value being stored in an element of a String array instead of in a standalone String. It compiles and works perfectly with the new version of ZXBasic:
Code:
dim testglobal(5) as string
cls
testglobal(1) = "global"
print testglobal(1)
setlocal()
print testglobal(1)
print "done"
sub setlocal
dim testlocal as string
testlocal = "local"
testglobal(1) = testlocal
print testlocal
print testglobal(1)
end sub
However.... if I take out all of the literal '1' values and make the array index a variable instead, the code no longer works - you get a blank value at the final 'print'.
Code:
dim testglobal(5) as string
dim pos as UBYTE
cls
pos = 1
testglobal(pos) = "global"
print testglobal(pos)
setlocal()
print testglobal(pos)
print "done"
sub setlocal
dim testlocal as string
testlocal = "local"
testglobal(pos) = testlocal
print testlocal
print testglobal(pos)
end sub
Hopefully that makes some sense to you, boriel! :-D