if | ||||||||||||||||
Type | control structure | |||||||||||||||
Dictionary | LCS | |||||||||||||||
Library | LiveCode Script | |||||||||||||||
Syntax |
| |||||||||||||||
Summary | Evaluates a condition|conditional expression to determine if it is true and if so executes a subsequent statement or statementlist|statement list. If the conditional expression|condition is false and the if control structure contains an else keyword the statement or statementlist|statement list following the else keyword is executed. The if control structure may contain one or more else if keywords which have a condition|conditional expression. If the condition|conditional expression for one of these evaluates to be true then the statment|statement or statementlist|statement list following that else if keyword is executed. If the if control structure contains more than one line then the if control structure must end with an end if keyword. | |||||||||||||||
Introduced | 1.0 | |||||||||||||||
OS | mac, windows, linux, ios, android | |||||||||||||||
Platforms | desktop, server, mobile | |||||||||||||||
Parameters |
| |||||||||||||||
Example |
| |||||||||||||||
Related | Keyword: then, else, else if, end if, word Function: commandNames Glossary: statement, command, evaluate, execute, control structure Control Structure: repeat, switch, try | |||||||||||||||
Description | Use the if control structure to execute a statement (or statementlist|list of statements) only under certain circumstances. The if control structure always begins with the word if. There are four forms of the if control structure:
This form may have a line break before the words
If the condition evaluates to true, the statement or statementList is executed; if the condition evaluates to false, the statement or statementList is skipped. if the condition evaluates to false and the if control structure contains an else keyword, the elseStatement or elseStatementList which follows it is executed. If the if control structure contains one or more else if keywords which have a condition|conditional expression, and one of those condition|conditional expressions evaluates to be true, then the respective elseIfstatement|else if statement or elseIfstatementlist|else if statement list following that else if keyword is executed. If one if control structure is nested inside another, use of the second form described above is recommended, since the other forms may cause ambiguities in interpreting which else clause belongs with which if statement. The if control structure is most suitable when you want to check a single condition. If you need to check for multiple possibilities, doing something different for each one, use a switch control structure instead.
|