Understanding Logic Functions

Getting started with Touch Portal

This guide will help you understand the logic functions that you can use in Touch Portal.

A Touch Portal button without logic

The best way to start this guide is to explain what a button without logic does. A Touch Button has three execution lists; On Press, On Event and On Hold.

For this guide we do not use the On Event or the On Hold because it is of a different nature and does not support most of the logic functions. The On Press is your list of actions that are triggered when you press the button on your mobile device.

The image above shows a button with just one action. This action will open our webpage on your default browser. We have created our actions in such a way that they read as what they do. So you should be able to read through your list of actions and understand what it does in a normal language.

You can stack actions as many as you want and the list of action will be executed in order. So this means that the next action will be started when the previous ended. So lets add another action to the button.

So now we have two actions. When you press the button first it will execute the opening of our website. When it has opened it, it will continue with the next action, which in this case is an action that navigates to another page within Touch Portal, called "Touch Portal". So now we have a button that does multiple actions in order.

The Wait for action

There can be situations where we need to wait for the website to load before we want to go to the other Touch Portal page. For this we can use the Timer action. The timer action is just an action like the others and it just does nothing for a given time. This means the action will only end when that time is passed and only then it will continue with executing actions again. Let us add a Timer in our list of actions.

If you press this button, it will start by opening our website and goes on to the next action. The next action is our timer so it will wait for 3 seconds until the action is ended and the next action will be triggered which is the action that opens our "Touch Portal" page on our mobile device.

Repeating actions using The Repeat X times action

The Repeat X times logic action is not really an action like the timer. It is more a helper function for your actions. In this case it will repeat the encapsulted actions the given amount of times. Lets look at an example:

So for software X which we use, we want to trigger a popup menu and then we want to execute the 8th action on that list. For this our repeater function is handy. To simulate what we want, we do the key press action ALT + T to trigger the popup menu. Now in software X, the first item of the popup list is selected when it popups up. To go to the 8th item, we need to press 7 times the down button. Our repeater does this for us. Then when the repeater is done, we press the enter key to trigger that 8th item in software X.

Again, every action is run in order. First the key press (ALT + T), then the repeater and after that the key press again (ENTER). The repeater however has a sub flow of actions which will be executing during the repeater action. Sub flows are also repeated in order.

You can add every action you want in a repeater, but be warned that it will run it the amount of times you specify. So if you made a mistake you need to see it through. Be aware that this can mess things up in the software you want to control like this if you make mistakes. Logic functions can enrich your Touch Portal experience but be sure of what you are doing, otherwise unwanted things can happen.

The If Statement

In the previous section you already learned a bit about sub flows. With this logic function, you will create one or two sub flows. An If statement if a logical action that will check if a statement is true. If it is, it will execute the encapsulated sub flow of actions. This is what an IF statement is about. Just a check if some statement is true and if it is it will execute the sub flow.

In this example we have an IF statement with a sub flow. The IF statement checks if OBS is recording. If it is recording, the IF statement is true, then it will execute the sub flow. In this case it will stop recording. If the OBS was not recording then this button would do nothing because the IF statement would be false, so the sub flow will not be executed. And since there are no other actions after the IF statement, nothing is being executed.

The example above is not a very useful example because if you tell OBS to stop recording it will stop it and will ignore the request if it was not recording. So just the stop recording action would have been enough. But lets extend it a bit so it is more useful.

Do remember, this IF statement is only triggered when the button is pressed because we added this in the On Press action list.

Also, because the nature of Touch Portal flows is that each action is only triggered in order and when the previous was being handled, all nested IF statements will be evaluated when they are triggered. They are not evaluated at the beginning of the press (at the beginning of the main flow).

Else - extending the IF statement

The above example added the Else logic action. With the IF statement we learned that if the IF statement is true, the sub flow will be executed, but what if the IF statement is false?

This is what the Else can be used for. If you place this inside an IF statement it will create an alternative flow for the IF statement. In our example we stop the recording if it is recording, but if it is not recording, we turn it on! So we have just made an OBS recording toggle button.

So the Else logic action is there for when you want to handle both results of an IF statement. If it is true it will execute the sub flow beneath the IF statement, if it is false it will execute the sub flow beneath the Else.

Some things to note, you cannot use multiple Else logic actions in one IF statement. This also does not really make sense because the first Else would already cover all other situation besides the IF statement being true.

Execute Flow

In Touch Portal you can execute a premade Flow of actions. This is collection of actions that you can execute from everywhere you want using this Execute Flow action. Using Flows can be useful to not always have to make the same flows over and over again. If you want to learn more about flows check out our guide on this. A Guide on understanding Flow in Touch Portal.

Stop Executing actions in the current Flow

You can stop the whole current Flow by using this action. No other actions in this flow will execute anymore. It does not matter where you are in the logic of the current flow, the whole flow is just dropped and nothing is executed anymore.

Important to know is that everytime something happens, an On Press or an Event for example, it will create a new flow of actions from that. So when you press a button twice, there are two separate flows running. The Stop executing actions in current Flow will only stop the actions of the flow it is called from. It cannot stop other flows, even if those are called from the same On Press or Event. This means that when you are making a loop for example, you need to add the Stop executing actions in current Flow inside of that loop to make it work.

Dynamic Text Updater

This event allows you to update the text on your button with an interval of 500 milliseconds. It will re-evaluate the contents each 500ms and send it to the mobile device. So this is very handy if you want to show some Value or state in near realtime. We have made a Guide to use this to show the time on your button but it could be used for all sorts of information. How to show the Time on a Button.

Setting button state - set a button to ON or OFF

With the knowledge of the IF statement you can create state aware toggle buttons. We have created an extended guide on toggle buttons which shows how to create such a button step by step.

Setting other button state - set an other button to ON or OFF

With the knowledge of the IF statement you can create radio buttons using the logic to set the state of other buttons. We have created an extended guide on radio buttons which shows how to create such a button step by step.


Values can hold a value and can be used in actions, events and much more. With Values you can create very complex structures for your buttons. Values are global and work across buttons and pages. We have made specific guide for Values so check that out.

Master and Slave buttons

You can combine all the logic functionality to make complex systems of buttons such as the master and slave button.

Back to Guide Overview