# Using the extended IF statement

### Getting started with Touch Portal This guide will help you understand the extended IF statement which will allow you to make complex logical decisions in your flows.

## IF vs Extended IF

You are all already familiar with our IF statement action. A logic function that check whether some Value or State is something and then and only then will execute the flow of actions below until an end-if or an else action. This is a very handy logic action but when creating complex tasks also a bit limiting. This is where the extended IF statement comes into play. With this improved IF statement logic action you can make different kind comparisons and you can link statements together. Example of an extended if statement that checks if you are on the BRB scene in OBS AND this buttons state is ON.

## More Comparison options

With the extended IF statement you get a lot of options to compare a state or Value with. Here is an overview of all the options and what they do (A is the actual state or Value, B is the user given comparison value):

Type of Value / StateComparisonExplanation
Universalis equal toWill be true if A and B are equal.
is NOT equal to Will be true if A and B are not equal.
is greater than
is later than
If both A and B are numbers, it will compare them as numbers. So if A is higher then B it will return true.

If both A and B are time objects this will return true if time A is later than time B.

If A or B is textual, both are compared lexicographically. The comparison is based on the Unicode value of each character in the text. The character sequence represented by A is compared lexicographically to the character sequence represented by B. Will return true if A lexicographically follows B.

is less than
is earlier than
If both A and B are numbers, it will compare them as numbers. So if A is less then B it will return true.

If both A and B are time objects this will return true if time A is earlier than time B.

If A or B is textual, both are compared lexicographically. The comparison is based on the Unicode value of each character in the text. The character sequence represented by A is compared lexicographically to the character sequence represented by B. Will return true if A lexicographically preceeds B.

containsBoth A and B are evaluated as Text, will return true if text B is part of text A
does not containBoth A and B are evaluated as Text, will return true if text B is not part of text A
begins withBoth A and B are evaluated as Text, will return true if text A starts with text B
ends withBoth A and B are evaluated as Text, will return true if text A ends with text B
size is equal toIf B is a number, this will return true when the character count of A is the same as the number B

If B is text, this will return true when the character count of A is the same as the character count of B
size is NOT equal to If B is a number, this will return true when the character count of A is not the same as the number B

If B is text, this will return true when the character count of A is not the same as the character count of B
size is greater then If B is a number, this will return true when the character count of A is greater to the number B

If B is text, this will return true when the character count of A is greater than the character count of B
size is less then If B is a number, this will return true when the character count of A is less than the number B

If B is text, this will return true when the character count of A is less than the character count of B<
Timeis same hour asif A and B are a time notation and the hours are the same number it will be true
is same minute asif A and B are a time notation and the minutes are the same number it will be true
is same second asif A and B are a time notation and the seconds are the same number it will be true
is NOT same hour asif A and B are a time notation and the hours are not the same number it will be true
is NOT same minute asif A and B are a time notation and the minutes are not the same number it will be true
is NOT same second asif A and B are a time notation and the seconds are not the same number it will be true
is later in the hour than minuteif A and B are a time notation and the minute part of A is an higher number than the minute part of B it will return true
is later in the minute than secondif A and B are a time notation and the second part of A is an higher number than the second part of B it will return true
is earlier in the hour than minuteif A and B are a time notation and the minute part of A is a lower number than the minute part of B it will return true
is earlier in the minute than secondif A and B are a time notation and the second part of A is a lower number than the second part of B it will return true

## Link multiple lines of statements

Each line in the extended IF statement represents a check that can either be true or false. The line connector checks the lines together. For example the AND connector checks whether the lines connected both are true. If it is, the extended IF Statement is valuated as true.

As soon as you select a connector, a new line will appear which you can use in your logic. To remove the line, make the connector empty again.

Here is the list of connector options you have and how they will evaluate the connected lines(A is the first statement line, B is the second statement line):

ConnectorOutcome of extended IF statement
ANDWill be true if both lines are true
ORWill be true if one or both lines are true
XORWill be true only if one of the lines is true, not if both are true or if both are false
NANDWill be true if both lines are false or one line is false.
NORWill be true when both lines are false
XNORWill be true if both lines are true or if both lines are false
Important to know that each connector is tested in order. This means that the connector between line 1 and line 2 is evaluated before the connector between line 2 and line 3. As soon as the result is false the evaluation is done and will not test any other line anymore. Order is important.

## Showing current state (Cached)

One neat little feature is that the Extended If Statement also shows the actual state of the selected state or Value. The state is updated only when the list of actions is reloaded or when a new state or Value is selected. Touch Portal will show what the state or Value currently is as shown in the image. In this case the button state is currently Off but in some cases this is unknown and in those cases Touch Portal will show No state information available...

Back to Guide Overview 