Page 1 of 1
initializing 4-dimensional array
Posted: 08 Dec 2011, 17:55
by sharpsee
I'm having trouble initializing a 4-dimensional array in nxc bricxcc. A little while ago, I hooked on to
this topic. I've tried the steps presented here by muntoo, but they didn't work. Without any hope for it to work, I also tried with the NXT connected via USB. I don't
need the 4-dimensoinal array, but having it would make my life a lot easier.
To be sure that nothing is wrong woth my array, I've tested with
Code: Select all
task main()
{
int MyArray[][][][] = {
{
{{0, -1},{1, -1}},
{{2, -1},{3, -1}}
},
{
{{10, 11},{12, 13}},
{{20, 21},{23, 31}}
}
};
}
The error I'm getting is "Line12: Error: Error parsing expression: } Line12: Error: Error parsing expression: } }"
Re: initializing 4-dimensional array
Posted: 08 Dec 2011, 18:32
by HaWe
I would do it this way:
define the correct size from the start, e.g.
int MyArray[2][2][2][2];
then I initialize it step by step:
MyArray[0][0][0][0]=0;
MyArray[1][0][0][0]=1;
MyArray[0][1][0][0]=2;
MyArray[1][1][0][0]=3;
MyArray[0][0][1][0]=4;
MyArray[1][0][1][0]=5;
...
Re: initializing 4-dimensional array
Posted: 08 Dec 2011, 21:59
by afanofosc
When I get around to posting my latest version of the compiler/IDE then you will be able to use your C-style initialization code. Or you could send me a regular email to the address in the About box and I could hook you up with a newer build than is currently available on line.
John Hansen
Re: initializing 4-dimensional array
Posted: 08 Dec 2011, 22:00
by afanofosc
P.S., how exactly would having a 4-d array make your life a lot easier?
John Hansen
Re: initializing 4-dimensional array
Posted: 08 Dec 2011, 22:09
by HaWe
You are talking from my soul (don't know if you understand this idiom) -
i personally actually was afraid to ask this question.
4 dimensions are sort of beyond my imagination although I must admit that my imagination is limited.
Re: initializing 4-dimensional array
Posted: 09 Dec 2011, 07:30
by mightor
P.S., how exactly would having a 4-d array make your life a lot easier?
Perhaps he's not from Earth and needs this kind of 4D math to allow him to travel back to his own dimension.
Anything's possible, right?
- Xander
Re: initializing 4-dimensional array
Posted: 13 Dec 2011, 05:57
by afanofosc
I've uploaded a new test release (20111212) to
http://bricxcc.sourceforge.net/test_releases/
See if this version successfully compiles the 4-d array initialization code above. In theory, it should.
John Hansen