This question sounds really dumb...
is there syntax for array literals to initialize two-dimensional array constant?
I tried visual basic syntax and got a bunch of strange errors
Array initialization
Well, it is extremely simple. I need a constant look-up table of integer values, about 30x5. As a workaround I wrote InitRow subroutine with 6 parameters which is called 30 times from InitArray subroutine.
In standard Basic syntax it'll be something like this:
Dim numbers = {{1, 2}, {3, 4}, {5, 6}}
If you are asking how it is being used... the numbers in table are 5-dimensional coordinates of a set of 30 waypoints. There is a function that accepts coordinates and locates closest waypoint. Function returns an index of that row in a table.
In standard Basic syntax it'll be something like this:
Dim numbers = {{1, 2}, {3, 4}, {5, 6}}
If you are asking how it is being used... the numbers in table are 5-dimensional coordinates of a set of 30 waypoints. There is a function that accepts coordinates and locates closest waypoint. Function returns an index of that row in a table.
Below is some example code using an Integer table. One unusual aspect of accessing tables in Program Memory is that the column index appears first followed by the row index. This is backward with respect to the way that variable arrays are indexed - it was done that way for backward compatibility with BasicX.wwwoholic wrote:I need a constant look-up table of integer values, about 30x5.
Code: Select all
Dim myTable as IntegerTableData ({
1, 7, 235, 8, 21
63, 77, 59, 82, 77
106, 23, 11, 21, 9
})
Public Sub Main()
Dim i As Integer, j as Integer
For i = 1 to 3
For j = 1 to 5
Dim s as String
s = " " & CStr(myTable(j, i))
Debug.Print Right(s, 5);
Next j
Debug.Print
Next i
End Sub
- Don Kinzer