Multi Dimension Arrays?

margret

Well-Known Member
Licensed User
Longtime User
Does B4A not support multi dimension arrays? It may be Android but, seems every time I go to use a function or feature it's not there. Am I just dumb and blind and I missed it? Please help, getting stuck at every turn because the functions I need are not there or as I said, I am to stupid to find them.

Thanks,

Margret
 

Kamac

Active Member
Licensed User
Longtime User
Type in searchbox: multi dimension arrays.

But to make this post OK and since i cannot give links yet, i'll explain;

B4X:
Dim ArrayOf6Dimensions(3,3,3,3,3,3) As Int
ArrayOf6Dimenstions(0,0,0,0,0,1) = 12

As far as i know, this: ArrayOf6Dimenstions(0,0,0,0,0,1) = 12
will make ArrayOf6Dimensions numbers: 0 0 0 0 0 and 1 be equal to 12....
Which means you gotta set everyone separately.

That should help :).

@Edit

I found this code:

B4X:
Dim Table As String
   Table = File.ReadString(File.DirInternal,"ScoreTable.txt")
   Dim Scores(25) As String
   c = Table.IndexOf(Level)
   Table = Table.SubString(c)
   For i = 0 To 24
         d=Table.IndexOf(",")
         c = 0
         Scores(i) = Table.SubString2(c,d)
         Table = Table.SubString(d + 1)
   Next

(Originally posted by: Cableguy)


It might help you!

It writes with numbers from file, eg. you can create ScoreTable.txt with these:
B4X:
1,0,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0  '25 numbers as there is done in the sample

This will make it way easier. You might modify the code for multi dimensional arrays. Here's an example code using 3 on 3 multi-dimensional array.


B4X:
Dim Table As String
   Table = File.ReadString(File.DirInternal,"ScoreTable.txt")
        Dim ArrayOf6Dimensions(3,3,3) As Int
        Dim Line as Int
        Line = 0
   c = Table.IndexOf(Level)
   Table = Table.SubString(c)
   For y = 0 To 2
                For x = 0 to 2
         d=Table.IndexOf(",")
         ArrayOf6Dimensions(y,y,y) = Table.SubString2(Line,d)
         Table = Table.SubString(d + 1)
                Next
        Line = Line + 4
   Next

This should work. That is a sample how your ScoreTable should look like:

1,0,0
0,1,1
1,0,0

Yell at me if it won't work.
 
Last edited:
Upvote 0
Top