The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible String issue? (*solved*)
#13
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:
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
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)