Sending channel arrays to a touch panel
travis
Posts: 180
In the docs, it lists
CHAN[ ] – a channel array.
as an allowablet parameter to
ON[DEVICE,CHANNEL]
this works... sometimes
Anyone else ever pulled their hair out over this?
I have to set_length_array before it will update my touchpanel.
Here's a complete demo file. Just make a tp file with buttons 1 through 8.
CHAN[ ] – a channel array.
as an allowablet parameter to
ON[DEVICE,CHANNEL]
this works... sometimes
Anyone else ever pulled their hair out over this?
I have to set_length_array before it will update my touchpanel.
Here's a complete demo file. Just make a tp file with buttons 1 through 8.
PROGRAM_NAME='arraytest' DEFINE_DEVICE vdv = 33001:1:0 tp = 10001:1:0 DEFINE_CONSTANT INTEGER BUTTONS[] = {1,2,3,4,5,6,7,8} DEFINE_VARIABLE VOLATILE INTEGER hack DEFINE_EVENT CHANNEL_EVENT[vdv,1] { ON:{ ON[tp,buttons] //works } } CHANNEL_EVENT[vdv,2] { ON:{ LOCAL_VAR INTEGER i_BtnsToTurnOn[4] STACK_VAR INTEGER idx //turn them all off OFF[tp,BUTTONS] //works //turn 1st 4 on FOR(idx=1;idx<=4;idx++){ i_BtnsToTurnOn[idx] = idx } IF(hack){ SET_LENGTH_ARRAY(i_BtnsToTurnOn,4) } ON[tp,i_BtnsToTurnOn] //only work after at least 1 set_length_array } } CHANNEL_EVENT[vdv,3] { ON:{ STACK_VAR INTEGER i_BtnsToTurnOn[4] STACK_VAR INTEGER idx //turn them all off OFF[tp,BUTTONS] //turn 1st 4 on FOR(idx=1;idx<=4;idx++){ i_BtnsToTurnOn[idx] = idx } IF(hack){ SET_LENGTH_ARRAY(i_BtnsToTurnOn,4) } ON[tp,i_BtnsToTurnOn] //need set_length_array (stack_var) } }
0
Comments
Paul
As a rule-of-thumb, if there is a built-in function to manipulate the array (like any of the string functions), the length is set properly. If you manually change any of the elements, you have to set the length yourself. I can't think of any exceptions to this, but it wouldn't surprise me if there were a few odd cases.
I think the only exception is when using double quotes to concatenate a string. Netlinx must sum the characters in each string and set the length of the new string to that length. I've never actually tested it but I never use set_length_array when using double quotes and I still get the correct result.
Paul
The length will not change if you set/poke individual cells in the array.
The length will change with any other type of assignment.
Am I missing your point?