[v1.4] ReDim 2D array fails with no syntax error.

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
User avatar
skywalk
Posts: 47
Joined: Tue Feb 25, 2014 2:13 am
Location: Boston, MA

[v1.4] ReDim 2D array fails with no syntax error.

Post by skywalk »

Code: Select all

;#WHAT = 1;ok
#WHAT = 2;fail
;#WHAT = 3;ok
;#WHAT = 4;ok
;#WHAT = 5;fail
CompilerIf     #WHAT = 1
  Debug "-- Dim 2-Dimensional Array --"
  Global Dim aX.d(10,10)
  aX(0, 0) = 0.11
  aX(10, 10) = 20.11
  Debug StrD(aX(0,0))
  Debug StrD(aX(10,10))
CompilerElseIf #WHAT = 2
  Debug "-- ReDim 2-Dimensional Array --"
  Global Dim aX.d(0,0)
  ReDim aX(10,10)           ;<-- FAIL
  aX(0, 0) = 0.11
  aX(10, 10) = 20.11
  Debug StrD(aX(0,0))
  Debug StrD(aX(10,10))
CompilerElseIf #WHAT = 3
  Debug "-- Structure with ReDim 1-Dimensional Array --"
  Structure my1DStruct
    Array aX.d(0)
    x.i
  EndStructure
  Global mys1.my1DStruct
  ReDim mys1\aX(10)
  mys1\aX(0) = 0.11
  mys1\aX(10) = 10.11
  mys1\x = 10
  Debug StrD(mys1\aX(0))
  Debug StrD(mys1\aX(10))
  Debug Str(mys1\X)
CompilerElseIf #WHAT = 4
  Debug "-- Structure with 2-Dimensional Array --"
  Structure my2DStruct
    Array aX.d(10,10)
    x.i
  EndStructure
  Global mys2.my2DStruct
  mys2\aX(0, 0) = 0.22
  mys2\aX(10, 10) = 20.22
  mys2\x = 20
  Debug StrD(mys2\aX(0,0))
  Debug StrD(mys2\aX(10,10))
  Debug Str(mys2\X)
CompilerElseIf #WHAT = 5
  Debug "-- Structure with ReDim 2-Dimensional Array --"
  Structure my2DStruct
    Array aX.d(0,0)
    x.i
  EndStructure
  Global mys2.my2DStruct
  ReDim mys2\aX(10, 10)
  mys2\aX(0, 0) = 0.22
  mys2\aX(10, 10) = 20.22
  mys2\x = 20
  Debug StrD(mys2\aX(0,0))
  Debug StrD(mys2\aX(10,10))
  Debug Str(mys2\X)
CompilerEndIf
Debug "-- DONE --"
Last edited by skywalk on Mon Sep 05, 2016 4:34 am, edited 1 time in total.
When working toward the solution of a problem, it always helps if you know the answer. ~ ?
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber
Comtois
Posts: 40
Joined: Mon Feb 24, 2014 11:07 pm

Re: [v1.4] ReDim 2D array fails.

Post by Comtois »

You can redim only one dimension.
If ReDim is used with a multi-dimension array, only its last dimension can be changed.
http://www.spiderbasic.com/documentatio ... e/dim.html
User avatar
skywalk
Posts: 47
Joined: Tue Feb 25, 2014 2:13 am
Location: Boston, MA

Re: [v1.4] ReDim 2D array fails.

Post by skywalk »

Yes, I meant to say no syntax error? The browser output just stops and no notice.
When working toward the solution of a problem, it always helps if you know the answer. ~ ?
An expert is one who knows more and more about less and less until he knows absolutely everything about nothing. ~ Weber
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: [v1.4] ReDim 2D array fails with no syntax error.

Post by Fred »

It miss a debugger error, so I will move it to feature and request
Post Reply