B4J Question Error declaring array, says declaration not the same

TorontoJim

Member
Licensed User
Longtime User
I've searched this forum and google for the answer, but can't find anything that applies specifically to this.

This is my first project with B4J.

This is a snippet of the code in the Process_Globals subroutine. I put it there because these values will not change, this is a lookup utility I'm creating:


Private arr8HrPattern (0 To 4, 0 To 34) As String
arr8HrPattern (0, 0) = "E"
arr8HrPattern (0, 1) = "E"
arr8HrPattern (0, 2) = "E"
arr8HrPattern (0, 3) = "X"
arr8HrPattern (0, 4) = "X"
arr8HrPattern (0, 5) = "X"
arr8HrPattern (0, 6) = "X"
... #just indicating more data, I didn't really put that there.
arr8HrPattern (4, 27) = "D"
arr8HrPattern (4, 28) = "D"
arr8HrPattern (4, 29) = "D"
arr8HrPattern (4, 30) = "D"
arr8HrPattern (4, 31) = "D"
arr8HrPattern (4, 32) = "X"
arr8HrPattern (4, 33) = "X"
arr8HrPattern (4, 34) = "X"


The declaration is underlined in red and the error message I get is:

Current declaration does not match previous one,
Previous: {Type=String, Rank=2, RemoteObject=True}
Previous: {Type=String, Rank=1, RemoteObject=True}

I've looked through the file visually AND done a search, there is only one place I am declaring the array.

I've been looking for a solution for over an hour and can't find out why this won't bend to my will :)

Does anyone have an explanation for what the NOOB is doing wrong?
 

udg

Expert
Licensed User
Longtime User
Hi Jim,
I'm sure you have your good reasons to choose a multi-dimensional array, in which case please disregard what follows.

An alternative could be a one dimensional string array with strings 35chars each. Something like:
B4X:
Private myarray(5) as string
'init the array in a compact way
myarray(0)="EEEEEXXXXXX......." 35 chars
myarray(1)="AAAAAAAAXXXXX.." again 35 chars
..
'looking for char Index,Index2 in old scheme becomes
char = myarray(Index).charAt(Index2)  'Index 0..4, Index2 0..34
That way you could easily pass an entire 35chars string to a sub, if needed.

my 2cent
 
Upvote 0

TorontoJim

Member
Licensed User
Longtime User
Erel, thank you. I thought I had read somewhere that arrays started at 1 instead of 0. I'll make the correction.

udg: I'm not sure yet which is more efficient, a multidimensional array, or a map. Were I writing this in Perl I'd use an associative array. This is only one of my first two projects in B4J. My only exposure to VB so far is VBA (but a lot of it).

I originally thought he multidimensional array would provide faster lookup, knowing two parameters, but your solution would also work. I'll play with them both and see if there is any noticeable differrence in speed. Thank you for posting the idea.
 
Upvote 0
Top