Implementing Toggle Buttons

Tutorials for working with our software
Locked
User avatar
DemoPad
Site Admin
Posts: 769
Joined: Thu Jun 14, 2012 10:46 am
Contact:

Implementing Toggle Buttons

Post by DemoPad » Thu Jul 05, 2012 4:33 pm

Whilst there is no specific module built in the software to implement a toggle button, the nature of the software design means that you can create the same effect (and more) using flags & dependent actions. Here is an example of a toggle button action sequence – you will need 2 flags set up in the software to accomplish this, we’ll call them TOGGLETEMP and TOGGLEMEMORY for this example. Here are the actions which are performed.

1. Set TOGGLETEMP=”OFF”
2. Set TOGGLETEMP=”ON”, dependent on TOGGLEMEMORY being = “ON”

3. Execute all actions for the first toggle state, dependent on TOGGLETEMP being =”OFF”
4. Execute all actions for the second toggle state, dependent on TOGGLETEMP being = “ON”

5. Set TOGGLEMEMORY=”ON”, dependent on TOGGLETEMP being = “OFF”
6. Set TOGGLEMEMORY=”OFF”, dependent on TOGGLETEMP being = “ON”

If we look at what we are doing here, we are using a Flag called TOGGLETEMP, and we are setting that Flag equal to whatever TOGGLEMEMORY is in lines 1 & 2. If TOGGLEMEMORY is “OFF”, line 2 is not executed, so TOGGLETEMP will = “OFF”.

From then on, we are using TOGGLETEMP to determine whether we should execute certain actions. We split the actions into two sets – the red actions are executed if TOGGLETEMP=”OFF”, and the green actions are executed when TOGGLETEMP=”ON”. Only one set of these actions will execute for a given press of the button.
Finally, lines 5 & 6 set the Flag TOGGLEMEMORY so that it is the opposite of the value it started with, so that the next time the button is pressed, the other actions will be performed.

Tags
toggle button set

Locked