Titan



if

1. Conditional statement with one alternative

2. Conditional statement with two alternatives

3. Conditional statement with several alternatives

The conditional statement is used to branch in the program execution in function of Boolean expression. It is possible to chain more than one such branching in one program statement.

Related keywords:


1. Conditional statement with one alternative


if( condition ){  statement_block };

Example


2. Conditional statement with two alternatives


if( condition ){  statement_block1 } else {  statement_block2 };

Example


3. Conditional statement with several alternatives


if( condition1 ){  statement_block1 } else if( conditionn ){  statement_blockn } else {  statement_blockx };

Example


Example 1:

if (v_date == "1.1.2000") { log ( "apage" ) };

When the variable v_date equals the character string 1.1.2000, the word apage will be written to the log.

Example 2:

if (v_datum == "1.1.2000") { log ( "apage" ) } else { log ( "satanas" ) };

When the variable v_datum equals the character string 1.1.2000, the word apage, else the word satanas will be written to the log.

Example 3:

if (v_data == "red") { log ( "rot" ) } else if (v_data == "blue"){ log ( "blau" ) } else { log ( "duester" ) };

When the variable v_data equals the character string red, the word rot will be written to the log. .When the variable v_data equals the character string blue, the word blau will be written to the log. When the variable v_data contains something else, the word duester will be written to the log. 



BNF definition of if