1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Solved “If” statements controlling button state

Discussion in 'Scripting Workshop' started by BenjMarx, May 10, 2018.

  1. BenjMarx

    BenjMarx New Member

    Messages:
    8
    Is there a way to control a button’s state within an “if” statement in which the condition is based on the current value of a slider?

    Essentially, I want the button’s state to turn “off” when its fader reaches 0000000, and to toggle back on whenever the fader rises above 0000000

    $room is a slider
    $roombutton is a mute button for the group.

    Something like:

    If ($room := 0000000)
    $roombutton = 0
    end if

    I know I’m missing something basic, but have yet to figure it out. Any help would be much appreciated! Thanks!

    Ben
     
  2. soundtrax

    soundtrax NI Product Owner

    Messages:
    301
    that's simple:
    Code:
    on init
    declare ui_slider $room (0,1000000)
    declare ui_switch $roombutton
    end on
    on ui_control ($room)
    $roombutton := $room
    end on
     
  3. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    With one million values, you will probably want to have a bit of leeway for when the slider is almost close to 0 but not quite. Say the bottommost 1000 or 10000 units. So:

    Code:
    if ($room < 10000)
        $roombutton := 0
    else
        $roombutton := 1
    end if
     
    • Like Like x 1
  4. BenjMarx

    BenjMarx New Member

    Messages:
    8
    Thank you both! Still not totally sure how I missed that...

    Thanks again!
    Ben