Home AMX User Forum AMXForums Archive Threads Tips and Tricks

Be CAREFUL using button_event with Arrays!

Spire_JeffSpire_Jeff Formerly Caffeinated ProgrammerPosts: 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:

//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:

//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.



  • bcirrisibcirrisi Junior Member Posts: 148
    Good catch, I ran into a similar problem, and ended up breaking it out into individual button presses (that was a long night) for everything. I never really got an answer why. Now I know, "And Knowing is Half the Battle!"
  • ericmedleyericmedley Senior Member - 4000+ posts Posts: 4,177
    It's for this reason that I got out of the habit of doing button arrays along the lines of
    {1,2,3,4,...   45,46}
    And went to more generic mult-purpose button arrays like
    {01,02,03,04.... ,99,100} 
    and then do
      SEND_COMMAND dv_World_Domination_Minions,'commence plans'
  • viningvining X Member Posts: 4,368
    Here's a link from early last year that goes over this issue that my be helpful.

Sign In or Register to comment.