Local string variables cannot have the name of multidimensional string arrays

This is where most of us started. Classic Spectrum basic.

Moderator: Programming Moderators

User avatar
programandala.net
Posts: 45
Joined: Thu Nov 02, 2017 11:55 am
Location: Spain
Contact:

Local string variables cannot have the name of multidimensional string arrays

Postby programandala.net » Sat Apr 24, 2021 12:06 pm

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?
Marcos Cruz (programandala.net)

garrylancaster
Posts: 36
Joined: Mon Feb 19, 2018 2:44 pm

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

Postby garrylancaster » Sun May 09, 2021 8:21 am

Yes, it's a bug. Due to be fixed in the next major version (v2.07) which will completely overhaul procedure and locals handling.


Who is online

Users browsing this forum: No registered users and 1 guest