Sending channel arrays to a touch panel
travis
Junior Member
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)
}
}
Comments
-
I use this all the time, but its not surprising that you need to use set_length_array. Whenever you decide to manually edit arrays on your own, Netlinx doesn't keep track so its up to you to set the length. You could do this using other methods which wouldn't require it though.
Paul -
I use this all the time, but its not surprising that you need to use set_length_array. Whenever you decide to manually edit arrays on your own, Netlinx doesn't keep track so its up to you to set the length. You could do this using other methods which wouldn't require it though.
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. -
DHawthorne wrote: »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 -
Another way to say it:
The length will not change if you set/poke individual cells in the array.
The length will change with any other type of assignment. -
But this is just poking individual cells...
-
Which is why the length will not change…But this is just poking individual cells...
Am I missing your point?
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums