Home AMX User Forum AMX General Discussion

TO statements that occur outside PUSH...

I am turning on a channel (button channel) on a touchpanel for feedback purposes, within a hold button, and get the following warning on compile:
WARNING: RSB, Rev2.axs(1290): C10608: TO statements that occur outside the data flow of PUSH events/statements may not work
HOLD[2,REPEAT]:
	{
			
		
		IF (nLightVal[get_last(dcLightsUpBtns)]<100)
		{
			//feedback on button press
			TO[dcLightsUpBtns[get_last(dcLightsUpBtns)]]
			//start incrementing variable for that zone
			nLightVal[get_last(dcLightsUpBtns)]++
			//Update the Level on the Touchpanel
			SEND_LEVEL dvTPLight,(GET_LAST(dcLightsUpBtns)+9),(nLightVal[get_last(dcLightsUpBtns)]*255/100)
		}
		ELSE
		{
			//Set value to 100%
			nLightVal[get_last(dcLightsUpBtns)] = 255
		}
The idea here is to program a button to show pressed while it is being held. The button itself is not set up in the touchpanel as momentary feedback, which is why I programmed it this way. Is there a better way to do this so as not to get the aforementioned error? BTW, every time I press the button(s) associated with this code, it works fine. Possibly a variable or channel going high (or set to 1) during a push, and then to 0 on the release, with feedback in define_program?

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    vegastech wrote: »
    The idea here is to program a button to show pressed while it is being held.
    All you need is a TO[BUTTON.INPUT] inside the PUSH.
  • DHawthorneDHawthorne Posts: 4,584
    First of all, it's just a warning. I have a project where I stuck it inside a function that was called by a button press, and it worked flawlessly, despite the warning. It's just that you can't guarantee the globals used by the TO statement aren't going to change on you in the meanwhile.

    That said though, in your case, it's easy enough just to take it out of your HOLD and put in in the PUSH handler ... even if you have to add a PUSH just for that purpose. There is no need at all to put it in a HOLD; it kind of creates its own HOLD internally.
  • vegastechvegastech Posts: 369
    I figured that was the case(just a warning...), but just wanted to be sure, or at least, 90% sure. :) Thanks for the button.input - there are so many handlers that I haven't quite figured out yet!
Sign In or Register to comment.