Be CAREFUL using button_event with Arrays!
Spire_Jeff
Posts: 1,917
If you are like me and you use an array of touchpanels, and you also use arrays for channel numbers, be careful. There is a limit to the number of events that can be inserted into the event table this way. I am waiting for confirmation from tech support as to the actual number, but the thinking is that it is around 1000 (probably 1024) even though there is an old tech note (number 383) that indicates the limit to be 4000.
So, if you are having issues where most of the buttons are responding correctly, but some are not, or most of the touch panels work, but not all of them, this may be the cause.
Here is an example:
If you have an array of 40 touch panels(dvTp), and you are using an array of 200 buttons(nButtons), the following will cause problems:
button_event[dvTp,nButtons]{
//do stuff
}
This will cause problems because this statement is adding 40*200 events which is 8000 events. Only the first 1000ish will be added, and no ERROR will be generated during compile. I don't think it will even throw an error during start up.
Don't despair, it is very easy to fix once you are aware of the problem. You only have to break up the button_event line and stack it. You could create ten arrays of buttons (nButtons1_20, nButtons21_40,...) and then declare like this:
button_event[dvTp,nButtons1_20]
button_event[dvTp,nButtons21_40]
.
.
button_event[dvTp,nButtons161_180]
button_event[dvTp,nButtons181_200]{
//do something.
}
This can be a tricky problem to figure out because some touch panels might work completely while others are only partially functional and you will see all of the button pushes come through to the processor, but the code will never be triggered for those events that were never added to the event table.
Jeff
So, if you are having issues where most of the buttons are responding correctly, but some are not, or most of the touch panels work, but not all of them, this may be the cause.
Here is an example:
If you have an array of 40 touch panels(dvTp), and you are using an array of 200 buttons(nButtons), the following will cause problems:
button_event[dvTp,nButtons]{
//do stuff
}
This will cause problems because this statement is adding 40*200 events which is 8000 events. Only the first 1000ish will be added, and no ERROR will be generated during compile. I don't think it will even throw an error during start up.
Don't despair, it is very easy to fix once you are aware of the problem. You only have to break up the button_event line and stack it. You could create ten arrays of buttons (nButtons1_20, nButtons21_40,...) and then declare like this:
button_event[dvTp,nButtons1_20]
button_event[dvTp,nButtons21_40]
.
.
button_event[dvTp,nButtons161_180]
button_event[dvTp,nButtons181_200]{
//do something.
}
This can be a tricky problem to figure out because some touch panels might work completely while others are only partially functional and you will see all of the button pushes come through to the processor, but the code will never be triggered for those events that were never added to the event table.
Jeff
0
Comments
and then do
http://www.amxforums.com/showthread.php?t=3746&highlight=event+table