Link Search Menu Expand Document

Condition - IF

One of the reasons to use a Function in Code Blocks is to execute different logic based on one or more conditions.

Code Blocks

The way to implement conditions in Kodika is to use the If Code Block. You can find the If Code Block in the Blocks->Logic.

Block Options

You can press the white settings icon to change between different block options.

How to

Each section of the Block consists of the condition (If/Else If) and the actions that will be executed (do).
Note: A special case is the optional else, which doesn’t need a condition and its actions are executed if no prior condition is True.

Condition (IF)

The condition (IF part) of the section is where you define the condition, using the True/False Boolean Input Parameter. If the condition is true during its evaluation, then the actions in the Do section will be executed.

Actions (DO)

In the Do section, you will need to add the Code Blocks of the actions that you want to be executed when the condition is True. You need to use Code Blocks with Code Block Connection.

Else if

To check for more than one condition, you will need to add an Else If section from the block options. You can have unlimited Else If sections but only one Else section.
Note: Using Else if is different than using multiple If Code blocks. Using the Else if section, the condition is checked only if the previous condition is false.


The Else section actions are executed if none of the If and Else if conditions are true. It is common to use the else when you want to execute actions when the If condition is false.
Tip: Else section is optional.


If - Else Example

In the next example, we create a Function that checks the is On value of a Switch and changes the Background color of the My screen View accordingly.

If - Else If - Else Example

In the next example, the background color of the View is changed based on the Text Field’s text value. The special else case will be executed when the other conditions are not true and it will change the Button’s title to Wrong.