Set Toggle state

Hello,

I need to set the Toggle state (on/off), is it possible ?

The reason for my request is the following : the toggle on state starts a treatment. When the treatment ends, if the toggle is always on, the treatment will be restarted one more time if the user does somethings on the Human UI window.
The solution I imagine is to set the toggle to Off when the treatment is finished.

Thanks in advance,
JLH

1 Like

As an easy solution you can use the logical operator AND to restart if the toogle is True and also another value (the state you want to consider, maybe another toogle to set if restart) is True. This way if the toogle is True but the state is false, the AND will give false.

1 Like

You mean to set the state of the Toggle with the CreateToggle component plugged into input with the Value Listener current value ? It doesn’t work because it creates a cyclic execution in the definition. So, we need a “Set Toggle” component, as there are “Set Label Contents”, “Set Check Box”, …)

I also need this because I want a toggle to be systematically “Off” when the window that contains it is opened.
As it stands, the toggle “remembers” it’s previous state, and if it was “On” when the windows was last closed, it will also be “on” when the window is re-opened.

The Metahopper “Expire” component works, but somehow, the timing isn’t right : When the window opens, the toggle is still “On”, and switches “Off” afterwards, which defeats my purpose because the toggle still sends a “True” value downstream which is what I need to avoid…

Maybe the False Start Toggle helps in this scenario? On first file load it always resets to false. andheum / FalseStartToggle / Downloads — Bitbucket

I’ll try that, thanks !