Executes a set of statements if a specified condition is true. If the condition is false, another set of statements can be executed.
Syntax
if ( condition )
{
statements1
}
[else
{
statements2
}]
Parameters
Parameter | Description |
---|---|
condition | Can be any MetaScript expression that evaluates to true or false. Parentheses are required around the condition. If condition evaluates to true, the statements in statements1 are executed. |
statements1,statements2 | Can be any MetaScript statements, including further nested if statements. Multiple statements must be enclosed in braces. |
Description
You should not use simple assignments in a conditional statement. For example, do not use the following code:
If you need to use an assignment in a conditional statement, put additional parentheses around the assignment. For example, use if ((x = y)).