If

The If statement allows a process to execute a statement or series of statements when a given expression is true. You can use arithmetic operators, logical operators, and comparison operators to construct an expression.

The TurboIntegrator If statement differs from the Rules IF function in that the TurboIntegrator statement can accept multiple ElseIf or Else statements to evaluate multiple expressions, while the Rules IF function can evaluate only one expression.

You can nest up to 20 If/ElseIf/Else statements in a TurboIntegrator process. If you exceed 20 nested If/ElseIf/Else statements, you will receive an error when attempting to save the process.

This function is valid in processes only.

Syntax

If(expression);
statement1;
ElseIf(expression);
statement2;
ElseIf(expression);
statement3;
Else;
statement4;
EndIf;

Arguments

None.

Examples

If (x=5);
	ASCIIOutput('c:\temp\if.txt','x equals five');
ElseIf (x=1);
	ASCIIOutput ('c:\temp\if.txt', 'x equals one');
ElseIf (x=2);
	ASCIIOutput ('c:\temp\if.txt', 'x equals two');
ElseIf (x=3);
	ASCIIOutput ('c:\temp\if.txt', 'x equals three');
ElseIf (x=4);
	ASCIIOutput ('c:\temp\if.txt', 'x equals four');
Else;
	ASCIIOutput ('c:\temp\if.txt', 'x falls outside expected range');
EndIf;

This example evaluates the value of X. If X=5, the ASCIIOutput function is executed to write the string x equals five to c:\temp\if.txt. If X does not equal 5, the first ElseIf statement is evaluated. If X=1, the ASCIIOutput function is executed to write the string x equals one to c:\temp\if.txt. This processing continues until the EndIf is executed.

Simple If statements can also be constructed without the use of ElseIf, as in this example:

IF(expression); 
	statement1; 
ELSE; 
	statement2; 
ENDIF;