Difference between revisions of "IF"
Barrymavin (Talk | contribs) (→Products) |
Yvonne.milne (Talk | contribs) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Conditional command execution | Conditional command execution | ||
− | |||
==Syntax== | ==Syntax== | ||
Line 11: | Line 10: | ||
ENDIF | ENDIF | ||
− | |||
==See Also== | ==See Also== | ||
[[DO CASE]], [[DO WHILE]], [[IIF()]] | [[DO CASE]], [[DO WHILE]], [[IIF()]] | ||
− | |||
==Description== | ==Description== | ||
Line 25: | Line 22: | ||
====ELSE==== | ====ELSE==== | ||
The ELSE statement is analogous with the OTHERWISE statement. If no previous IF <condition> or ELSEIF <condition> is true, the commands following the ELSE statement up to the ENDIF statement are executed. | The ELSE statement is analogous with the OTHERWISE statement. If no previous IF <condition> or ELSEIF <condition> is true, the commands following the ELSE statement up to the ENDIF statement are executed. | ||
− | |||
==Example== | ==Example== | ||
Line 38: | Line 34: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
− | |||
− | |||
[[Category:Looping Commands]] | [[Category:Looping Commands]] |
Latest revision as of 11:00, 4 February 2013
Purpose
Conditional command execution
Syntax
IF <condition>
[ELSEIF<condition>]
[ELSE]
ENDIF
See Also
Description
The IF command provides a conditional selection of commands to execute based upon a logical <condition>. If the result of the <condition> is .T., then the commands following the IF, up to an ENDIF statement or an ELSE statement are executed. IF statements may be nested, i.e. IF statements may contain other IF statements, provided that the ELSE and ENDIF statements correspond with a valid IF.
ELSEIF
The ELSEIF clause can be added to the IF control structure allowing for the testing of more than one condition in the IF...ENDIF block. The IF block is now essentially the same as the DO CASE structure. ELSEIF is analogous with the CASE statement.
ELSE
The ELSE statement is analogous with the OTHERWISE statement. If no previous IF <condition> or ELSEIF <condition> is true, the commands following the ELSE statement up to the ENDIF statement are executed.
Example
use patrons index events, names seek "BALLET" if found() edit else dialog message "Record not found." endif