Problem with Multi-Dim Array
I use very similar code for other functions and it works quite well. But...
The above code does not return any values for any of the called DSP block row/columns. I can't spot any mistakes that should cause this. Help!
DEFINE_CONSTANT
integer ao_ab_z1[3] = {1,25,1} //1=UNIT, 2=DSP, 3=LINE
integer ao_ab_z2[3] = {1,25,2} //1=UNIT, 2=DSP, 3=LINE
integer ao_gr_z1[3] = {2,32,1} //1=UNIT, 2=DSP, 3=LINE
integer ao_gr_z2[3] = {2,32,2} //1=UNIT, 2=DSP, 3=LINE
integer ao_gr_z3[3] = {2,32,3} //1=UNIT, 2=DSP, 3=LINE
integer ao_gr_z4[3] = {2,32,4} //1=UNIT, 2=DSP, 3=LINE
integer ao_c_z1[3] = {3,53,1} //1=UNIT, 2=DSP, 3=LINE
integer ao_c_z2[3] = {3,53,2} //1=UNIT, 2=DSP, 3=LINE
integer ao_de_z1[3] = {3,53,4} //1=UNIT, 2=DSP, 3=LINE
integer ao_de_z2[3] = {3,53,5} //1=UNIT, 2=DSP, 3=LINE
//zone output map
integer aout_blocks[10][3] = {
ao_ab_z1,
ao_ab_z2,
ao_c_z1,
ao_c_z2,
ao_de_z1,
ao_de_z2,
ao_gr_z1,
ao_gr_z2,
ao_gr_z3,
ao_gr_z4
}
DEFINE_EVENT
button_event[tp_all,btnset_zonedn] //Zone DN
{
push: {
send_string debug,"'Zone DSP [1][1,2,3]: ',itoa(aout_blocks[1][1]),',',itoa(aout_blocks[1][2]),',',itoa(aout_blocks[1][3])"
send_string debug,"'Zone DSP [3][1,2,3]: ',itoa(aout_blocks[3][1]),',',itoa(aout_blocks[3][2]),',',itoa(aout_blocks[3][3])"
send_string debug,"'Zone DSP [6][1,2,3]: ',itoa(aout_blocks[6][1]),',',itoa(aout_blocks[6][2]),',',itoa(aout_blocks[6][3])"
}
}
The above code does not return any values for any of the called DSP block row/columns. I can't spot any mistakes that should cause this. Help!
0
Comments
My first instinct was to reply "you can't assign an integer array" so I tried and you can do so at runtime.
You can also assign an integer array to a member of a multi-dimensional integer array at runtime. News to me!
You can't both declare and assign an integer array in define_variable because the RHS in the assignment has to be a constant.
This compiles but does not work:
define_constant integer a[3] = {65,66,67} integer b[3] = {68,69,70} define_variable integer c[2][3] = {a,b}This does not compile:
define_constant integer a[3] = {65,66,67} define_variable integer d[3] = aThis compiles but does not work:
define_constant integer a[3] = {65,66,67} integer b[3] = {68,69,70} integer c[2][3] = {a,b}Some might say "that's not meant to work" and that's fine by me, but the compiler doesn't say that, which is the bug.
One workaround is to do this:
integer aout_blocks[10][3] = { {1,25,1}, {1,25,2}, {2,32,1}, {2,32,2}, {2,32,3}, {2,32,4}, {3,53,1}, {3,53,2}, {3,53,4}, {3,53,5}}...or to assign the elements to the multidimensional array in define_start.
D'oh - I think I've even run into this once before! The rest of the multi-dims I use are assigned with the numbers like:
INTEGER this_array[][] {{1,2,3},{4,5,6},{7,8,9}}
...which as you say really does work.
Thanks!