05-24-2013 10:23 AM
Hi,
Help required in building and accessing a number of 2D arrays.
There are 18 arrays in total,inter related(cross point relays, 4 diffrent PCI cards, 5x32 bit word for each card), accessing them will be the same but the content will be different.
Let’s deal with one and I would assume the other will follow the same procedure.
The values to go into the arrays are already known.
I have them, at present, in an Excel file, is this the best place to start, I like to keep things simple.
The array is 52 by 4
1 2 |
3 4 |
5 6 |
7 8 |
9 10 |
11 12 |
13 14 |
15 16 |
|
1 |
1 |
2 |
4 |
8 |
16 |
32 |
64 |
128 |
2 |
4096 |
8192 |
16384 |
32768 |
65536 |
131072 |
262144 |
524288 |
3 |
16777216 |
33554432 |
67108864 |
134217728 |
268435456 |
536870912 |
1073741824 |
2147483648 |
4 |
16 |
32 |
64 |
128 |
256 |
512 |
1024 |
2048 |
In this example
1,1 and 2,1 has a value of 1
7,4 and 8,4 has a value of 128
15,2 and 16,2 has a value of 524288
How to:
Define, load and access the array?
Any direction or help
Thanks
Simon
05-27-2013 03:41 PM
As the data is in Excel already, I'd use this to generate a series of "array1[001,001] = 1 ;" lines in a new worksheet in Excel.
For example:
array1 |
[ |
1 |
, |
1 |
] |
= |
1 |
; |
array1 |
[ |
2 |
, |
1 |
] |
= |
1 |
; |
array1 |
[ | 7 |
, |
4 |
] |
= |
128 |
; |
array1 |
[ |
15 |
, |
2 |
] |
= |
524288 |
; |
Where columns 3, 5, and 8 are generated by formulas referencing your existing tables.
Configure a new worksheet to generate this automatically from your existing table, cut and paste into your source code and pass control during initialisation to setup your array values.
Not elegant, especially if the values might change, but gets the job done.