Page 1 of 1

Local string variables cannot have the name of multidimensional string arrays

Posted: Sat Apr 24, 2021 12:06 pm
by programandala.net
I've found that a local string variable cannot have the name of a multidimensional string array.
In the following example code, the first execution of `local` works, but the second fails with "Subscript wrong":

Code: Select all

  10 DIM n$(10)
  20 PRINT "DIM n$(10)"
  30 LET n$(1)="G"
  40 PROC zx()
  50 PRINT "global n$(1)=";n$(1)
  60 :
  70 DIM n$(10,1)
  80 PRINT "DIM n$(10,1)"
  90 LET n$(1)="G"
 100 REM "Subscript wrong" at "LOCAL":
 110 PROC zx()
 120 PRINT "global n$(1)=";n$(1)
 130 :
 140 STOP 
 150 :
 160 DEFPROC zx()
 170 LOCAL n$
 180 LET n$="L"
 190 PRINT "local n$=";n$
 200 ENDPROC 
Is it a side effect of the way string variables and string arrays are handled by Sinclair BASIC? (I mean, unidimensional string arrays can be used as ordinary strings, just with a fixed length.) Or is it a bug?

Re: Local string variables cannot have the name of multidimensional string arrays

Posted: Sun May 09, 2021 8:21 am
by garrylancaster
Yes, it's a bug. Due to be fixed in the next major version (v2.07) which will completely overhaul procedure and locals handling.