Multi Dimension String Arrays.

edited August 2010 in Sinclair Basic
Ok so I've been playing with Sinclair Basic though BASIN and I'm wanting to use multi dimension string arrays, if it is possible.

I know what when a 2D array is dimension for strings that each element holds a char.

For example if I was to create a 2D character array as follows.

DIM n$(10,10)

It would allow me to store 10 strings of 10 chars each like so.
1  2  3  4  5  6  7  8  9  10

2  W  o  s  1  R  u  l  e  s 

3  F  l  a  c  k  e  r  y  .

4  F  a  r  t  h  e  r  l y 

5  T  e  d  C  r  i  l  l  Y

6  A  d  u  l  t  e  r  y  . 

7  T  H  E  M  o  N  K  E  Y

8  J  a  c  k  a  n  o  r  y

9  P  l  a  y  d  e  a  d  .

10 G  L  O  S  S  O  P  S  .

Is it then possible to say

DIM m$ (10,10,10)

To create ten arrays of ten strings, or do I have to in some way create an array of arrays?

Also are arrays in Sinclair basic 0 based i.e. do they have an element 0?
Post edited by Scottie_uk on
Calling all ASCII Art Architects Visit the WOS Wall of Text and contribute: https://www.yourworldoftext.com/wos

Comments

  • edited August 2010
    Argh 3d arrays make my head bleed. I dunno if Sinclair basic would create a 3rd dimention as you are looking for or add an extra column to the rows of the array. I'm sure someone will be along to assist.
  • edited August 2010
    The last parameter always specifies string length, so

    DIM a$(10,10,10)

    will set up a a 10x10 array of strings, each of which is ten characters in length.

    LET a$(2,4)="hello" will set a$(2,4) to "hello " and pad with extra spaces. You can reference individual characters with the third dimension index. String arrays don't work like every other implementation in sinclair basic, they take some getting used to.

    Edit: And that's a no to zero-based indexing.

    D.
  • edited August 2010
    Dunny wrote: »
    The last parameter always specifies string length, so

    DIM a$(10,10,10)

    will set up a a 10x10 array of strings, each of which is ten characters in length.

    LET a$(2,4)="hello" will set a$(2,4) to "hello " and pad with extra spaces. You can reference individual characters with the third dimension index. String arrays don't work like every other implementation in sinclair basic, they take some getting used to.

    Edit: And that's a no to zero-based indexing.

    D.

    Thanks Dunny just what I wanted to know. Does this also mean a 4D string array is possible?
    Calling all ASCII Art Architects Visit the WOS Wall of Text and contribute: https://www.yourworldoftext.com/wos
  • edited August 2010
    Scottie_uk wrote: »
    Thanks Dunny just what I wanted to know. Does this also mean a 4D string array is possible?

    Absolutely. The hardest part about creating multi-dimensional arrays in my opinion is trying not to think of them in terms of physical dimensions - an array of x by y by z dimensions is just that - not a cube :)

    Once you get past that, it's much easier to get them straight in your head :)

    D.
  • edited August 2010
    Dunny wrote: »
    Absolutely. The hardest part about creating multi-dimensional arrays in my opinion is trying not to think of them in terms of physical dimensions - an array of x by y by z dimensions is just that - not a cube :)

    Once you get past that, it's much easier to get them straight in your head :)

    D.

    I tend to think of muti-dimensional arrays as tables of tables. For me that makes much more sense unless they are actually being employed for modeling a 3D space.
    Calling all ASCII Art Architects Visit the WOS Wall of Text and contribute: https://www.yourworldoftext.com/wos
Sign In or Register to comment.