Mutually exclusive buttons & open window

Like this?

Var
   group1_sound1 : PluginBlock
   group1_btn1 : Widget

On WidgetValueChanged (btval : double) from group1_btn1
    if ModifierKeys() == 2 and btval > 0.5
        then OpenPlugin(group1_sound1)
        Else ClosePlugin(group1_sound1)
    end
    If btval >0.5
        then SetPluginBypassed(group1_sound1, false)
        else SetPluginBypassed(group1_sound1, true)
    end
End

You have to put in the other declarations and statements before you End the sequence from On WidgetValueChanged.

1 Like

@edm

That likely does work and I can test it in a different gigā€¦ but in my gig, that crashed GP completely and I suspect this is why:

I have another part of my script with the following variables:

Var
TimerStarted : Boolean
StartTime : double
Delay : double

Now this is just a guessā€¦ because this is quickly getting over my head, but I think the true, false syntax is creating a feedback loop of somekind and hanging GP.

I myself tried almost what you sent using ā€˜falseā€™ last night and it crashed GP.

Hereā€™s the rest of that script I am referring to:

> 
> //leslie break script//
> 
> initialization
>  TimerStarted = false
>  Delay = 410
>  SetTimersRunning(true)
> end 
>    
> on Activate
>  TimerStarted = false
>  SetTimersRunning(true)
> end 
> 
> On WidgetValueChanged(newValue : double) from speed1
> 
>  if ParamToMidi(newValue) >= 20
>     and ParamToMidi(newValue) <= 110 then
>   if TimerStarted == false then
>     SetTimersRunning(true)
>     TimerStarted = true
>     StartTime = TimeSinceStartup()
>   end  
>  
>  else
>   brake1.SetWidgetValue(0.0)
>   brake2.SetWidgetValue(0.0)
>   brake3.SetWidgetValue(0.0)
>   SetTimersRunning(false)
>   TimerStarted = false
>  end 
>     
> End
> 
> on TimerTick(ms : double)
>  if TimeSinceStartup() >= StartTime + Delay then
>   brake1.SetWidgetValue(1.0)
>   brake2.SetWidgetValue(1.0)
>   brake3.SetWidgetValue(1.0)
>  end 
> end

I am putting ALL of my Var for all my script sections at the very top of my script to keep that in one place, I donā€™t know if where those are expressed matters or not.

While Iā€™d ultimately like to know if I am correct in my assumption that true/false is the culprit of the crashingā€¦ I also wonder if itā€™s possible to get around this by using an integer or double instead but when I try that I get an error of incompatible value.

I can confirm that if I remove my //leslie break script// from my overall script, then adding the SetPluginBypassed action doesnā€™t crash GP so while I donā€™t understand why this is, my hunch is correctā€¦ itā€™s a conflict with the boolean true/false that creates a ā€˜death spiralā€™.

@dhj I know were in un-supported territory here but just a FYIā€¦ when this crash occurs it doesnā€™t dump out to the GP crash notification screenā€¦ I just get the GP has stopped working and will be reported to Windows screen.

Is it a crash or is it a hang? These are different!

in the parlance of Windows 10ā€¦ paraphrasing hereā€¦

ā€œThe application GP has encountered a problem and stopped working and this will be reported to Bill Gatesā€

the application will eventually disappear on itā€™s own, I donā€™t have to force quitā€¦ so Iā€™d call that a crash.

1 Like

I get this often tooā€¦out of the blue.

ā€œStopped workingā€ generally just means that Windows didnā€™t detect any GUI activity after a certain amount of time passed. Thatā€™s generally due to a hang and eventually Windows will kill it. So if you are in GPScript and have setup an infinite loop such that nothing else can happen then that is essentially a hang, not a crash

So I think I have solved the issue that caused the hang just by reordering my scripts.

If I put the SetPluginBypassed script before my //leslie break script// both scripts function normally and clicking the bypass button doesnā€™t hang GP.

But if I reverse the order of these scripts, clicking the bypass button does hang GP.

I donā€™t understand ā€“ there is only one script (per rackspace, say) ā€” how are you reordering it?

Hereā€™s the order that works without the hang:

//bypass button open plugin script//

thenā€¦

//leslie break script//

> Var
>    TimerStarted : Boolean
>    StartTime : double
>    Delay : double
> 
>    brake1, brake2, brake3 : Widget
>    speed1, speed2, speed3 : Widget
>     
> 	group1_btn1 : widget
> 	group1_sound1 : PluginBlock
> 
> //bypass button open plugin script//
>     
> On WidgetValueChanged (btval : double) from group1_btn1
> if ModifierKeys() == 2 and btval > 0.5
>         then OpenPlugin(group1_sound1)
>         Else ClosePlugin(group1_sound1)
>     end
>     If btval >0.5
>         then SetPluginBypassed(group1_sound1, false)
>         else SetPluginBypassed(group1_sound1, true)
>     end
> End
> 
> 
> //leslie break script//
> 
> initialization
>  TimerStarted = false
>  Delay = 410
>  SetTimersRunning(true)
> end 
>    
> on Activate
>  TimerStarted = false
>  SetTimersRunning(true)
> end 
> 
> On WidgetValueChanged(newValue : double) from speed1
> 
>  if ParamToMidi(newValue) >= 20
>     and ParamToMidi(newValue) <= 110 then
>   if TimerStarted == false then
>     SetTimersRunning(true)
>     TimerStarted = true
>     StartTime = TimeSinceStartup()
>   end  
>  
>  else
>   brake1.SetWidgetValue(0.0)
>   brake2.SetWidgetValue(0.0)
>   brake3.SetWidgetValue(0.0)
>   SetTimersRunning(false)
>   TimerStarted = false
>  end 
>     
> End
> 
> on TimerTick(ms : double)
>  if TimeSinceStartup() >= StartTime + Delay then
>   brake1.SetWidgetValue(1.0)
>   brake2.SetWidgetValue(1.0)
>   brake3.SetWidgetValue(1.0)
>  end 
> end	

If I reverse the order like follows, when I click on group1_btn1, then I get the hang.

> Var
>    TimerStarted : Boolean
>    StartTime : double
>    Delay : double
> 
>    brake1, brake2, brake3 : Widget
>    speed1, speed2, speed3 : Widget
>     
> 	group1_btn1 : widget
> 	group1_sound1 : PluginBlock
> 
> //leslie break script//
> 
> initialization
>  TimerStarted = false
>  Delay = 410
>  SetTimersRunning(true)
> end 
>    
> on Activate
>  TimerStarted = false
>  SetTimersRunning(true)
> end 
> 
> On WidgetValueChanged(newValue : double) from speed1
> 
>  if ParamToMidi(newValue) >= 20
>     and ParamToMidi(newValue) <= 110 then
>   if TimerStarted == false then
>     SetTimersRunning(true)
>     TimerStarted = true
>     StartTime = TimeSinceStartup()
>   end  
>  
>  else
>   brake1.SetWidgetValue(0.0)
>   brake2.SetWidgetValue(0.0)
>   brake3.SetWidgetValue(0.0)
>   SetTimersRunning(false)
>   TimerStarted = false
>  end 
>     
> End
> 
> on TimerTick(ms : double)
>  if TimeSinceStartup() >= StartTime + Delay then
>   brake1.SetWidgetValue(1.0)
>   brake2.SetWidgetValue(1.0)
>   brake3.SetWidgetValue(1.0)
>  end 
> end	
> 
> //bypass button open plugin script//
>     
> On WidgetValueChanged (btval : double) from group1_btn1
> if ModifierKeys() == 2 and btval > 0.5
>         then OpenPlugin(group1_sound1)
>         Else ClosePlugin(group1_sound1)
>     end
>     If btval >0.5
>         then SetPluginBypassed(group1_sound1, false)
>         else SetPluginBypassed(group1_sound1, true)
>     end
> End

Both script //sections// work independently no issueā€¦ but adding another instance of using the Boolean true, false in the same script, depending on the order it is used, creates the hang.

Iā€™d love to understand why.

(this is a paired down version of my full script)

I donā€™t have time to do user script debugging (and frankly it doesnā€™t hepp that your script is not properly indented to at least make it readable) but would note that your OnTimerTick should actually stop the timer once it reaches the correct time otherwise itā€™s going to just keep setting those widget values on every tick.

This is a single script ā€“ not two separate scripts. The order of callbacks should not matter one bit.

sorry about the indentationā€¦ it happens when I paste in for some reason, itā€™s not like that in the script.

yes, i get that itā€™s one scriptā€¦ but the order of the callbacks is definitely what determines if the crash is triggered or not. Iā€™ve tested that numerous times and itā€™s the variable.

Iā€™ll try to figure out the Timer, thanks for the suggestion.

Iā€™m attaching the exported script in case anyone wants to take a look. The way this is exported is the way in which it does not crash.

DEFAULT Script.zip (1.3 KB)

2 Likes

If thatā€™s true, thereā€™s something very deeply wrong with GPScript ā€” really needs a short script to demonstrate this.

1 Like

Iā€™m sure this is not the caseā€¦ must be another variable. Iā€™ll try to pressure test some more on this issue.

Bump for radio button widgets.
Iā€™ve got a group of seven mutually exclusive buttons I want to automate. I will dig in with GPScript but also register my interest here.

I tried to follow the file you provided, and when switching between variations, the button just blinks and recovers, not visually switching or mutual exclusion, i.e.: the led indicator is lit but does not stay on, and doesnā€™t work as a constant reminder of the current state (e.g. out of a certain page).

Is it possible to modify the script code to help me realize a toggle variation like the one in your file?

Thank you!

No need for scripting anymore, there is an in-built function for radio buttons since V4.7 (I guess).
Just put the buttons into the same radio group (must not be 0) and you are good to go!
Search the manual for ā€œradio groupā€ā€¦ it should be well documented.

2 Likes

Iā€™ll keep trying!

Thank you!