Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Bill_O on April 28, 2009, 09:00:07 AM

Title: button code
Post by: Bill_O on April 28, 2009, 09:00:07 AM
I have the following code in a button.
There are 4 buttons and I only want the one clicked on to have the led turned on.
Each button has 2 leds.
One is around the button and changes color and the other is a fake button that sits over a transparent button.
The led that is around the button always works.
The led that is a fake button usually does not change.
What am I doing wrong?

If (GetUserLED (1141) = 1) Then
SetUserLED (1141, 0)
Else
If (GetUserLED (1142) = 1) Then
SetUserLED (1142, 0)
Else
If (GetUserLED (1143) = 1) Then
SetUserLED (1143, 0)
End If 
End If
End If 
SetUserLED (1140 , 1)

Bill
Title: Re: button code
Post by: jimpinder on April 29, 2009, 11:25:42 AM
The leds are either true or false, not 0 and 1. The "0" is 0, but the "1" is "non-zero" not necessarily 1.

Just try If GetUserLED(****) Then  - or - If NOT GetUserLED(****) Then for the "on" or "off"
Title: Re: button code
Post by: Hood on April 29, 2009, 01:25:54 PM
I thought I replied to this yesterday but must be going senile :(
 It could be your buttons/led setup. I know Brett had a lot of trouble trying to put invisible buttons on top of LEDs etc

Hood
Title: Re: button code
Post by: Greolt on April 30, 2009, 04:59:21 AM
What Hood is referring to is this,

If you have a LED with a transparent button taking up the same screen space then you must assign a transparent png to the button.

Otherwise the LED will not show change of state reliably.

Greg
Title: Re: button code
Post by: Bill_O on April 30, 2009, 12:20:17 PM
I think I did make and use a transparent png for the button but I will check.
Thanks everyone,
Bill