Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel

TSL ELSEIF statement


The ELSEIF statement is a combination of ELSE and IF, which allows you to selectively perform an alternative tasks within a TSL IF block.

The task specified after the ELSEIF part of the statement is only executed if the previous IF expression (including previous ELSEIF expressions) evaluates to FALSE and the ELSEIF expression evaluates to TRUE.

You can have any number of ELSEIF statement after each other.


Syntax

Code Block
[[[IF expr1]]] message1 [[[ELSEIF expr2]]] message2 [[[/IF]]]


Inputs

  • expr1 and expr2: are expressions which evaluate to TRUE or FALSE

  • message1 and message2: are TSL messages, so they can contain plain text and other TSL statements.


Example

Suppose you want to create a welcoming message after a user has logged in to your application. Then you could create the following TSL message:

Code Block
[[[IF time.hour >= 0 AND time.hour < 6]]]Good night [[[ELSEIF time.hour >= 6 AND time.hour < 12]]]Good morning [[[ELSEIF time.hour >= 12 AND time.hour < 18]]]Good afternoon [[[ELSEIF time.hour >= 18 AND time.hour <= 23]]]Good evening[[[/IF]]] [[[user.first_name]]] [[[user.last_name]]]

When user John Doe logged on at 8 o’clock am, the message shown in your application is: “Good morning John Doe”

When user John Doe logged on at 7 o’clock pm, the message shown in your application is: “Good evening John Doe”

Info

Make

UI Text Box
typenote
make

sure the entire time.hour range is covered, otherwise the message would simply say “John Doe”

Back to top


Panel

TSL IF ELSE statement


The ELSE statement allows to perform a task when all previous IF or ELSEIF expressions evaluated to FALSE.


Syntax

Code Block
[[[IF expr]]] message1 [[[ELSEIF expr2]]] message2 [[[ELSE]]] message3 [[[/IF]]]

Note that the ELSEIF statement is optional, and that the ELSE statement, if present, must always be the last statement within an IF.

Inputs

  • expr: is an expression that evaluates to TRUE or FALSE
  • message1, message2 and message3: are TSL messages, so they can contain plain text and other TSL statements


Example

Suppose you want to create a welcoming message after a user has logged in to your application. Then you could create the following TSL message:

Code Block
Welcome [[[IF user.gender = 'male']]]Mr.[[[ELSE]]] Mrs.[[[/IF]]] [[[user.first_name]]] [[[user.last_name]]]

When user John Doe logged on, the message shown in your application is: “Welcome Mr. John Doe”

If the gender is unknown the message will look like this: “Welcome Jane Doe”

Back to top