Difference between revisions of "Recital Flow Control and Looping"
Yvonnemilne (Talk | contribs) (→The Recital if Statement) |
Yvonnemilne (Talk | contribs) (→Recital Flow Control and Looping) |
||
Line 15: | Line 15: | ||
</pre> | </pre> | ||
− | Each ''case condition'' is evaluated in turn. As soon as one of the conditions evaluates to true (.T.) the ''commands'' for that case are executed and any further case statements are ignored. Following execution of the ''commands'', the program continues after the ''endcase'' statement. If an ''otherwise'' statement is present and no ''case condition'' evaluates to | + | Each ''case condition'' is evaluated in turn. As soon as one of the conditions evaluates to true (.T.), the ''commands'' for that case are executed and any further case statements are ignored. Following execution of the ''commands'', the program continues after the ''endcase'' statement. If an ''otherwise'' statement is present and no ''case condition'' evaluates to true, the ''otherwise commands'' are executed. |
− | If no ''case condition'' evaluates to | + | If no ''case condition'' evaluates to true, and there is no ''otherwise'' statement specified, then control skips to the next command following the ''endcase''. |
'''Example''' | '''Example''' | ||
Line 25: | Line 25: | ||
===The Recital if Statement=== | ===The Recital if Statement=== | ||
− | The [[IF|if]] command | + | The [[IF|if]] command processes commands based on the evaluation of a logical condition. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<pre> | <pre> | ||
Line 41: | Line 33: | ||
endif | endif | ||
</pre> | </pre> | ||
+ | |||
+ | If the result of the ''if condition'' is true (.T.), then the commands that follow up to an ''else'', ''elseif'' or ''endif'' statement are executed. | ||
+ | |||
+ | The ''elseif'' clause can be added to the 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. | ||
+ | [edit] | ||
+ | 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. | ||
+ | |||
+ | |||
===Recital Looping Statements=== | ===Recital Looping Statements=== |
Revision as of 14:25, 14 January 2010
Contents
Recital Flow Control and Looping
Recital Conditional Statements
Recital do...case statements
The do...case command selects one course of action out of one or more alternatives.
do case case <condition as logical> [<commands>] [case <condition as logical> [<commands>]] [otherwise [<commands>]] endcase
Each case condition is evaluated in turn. As soon as one of the conditions evaluates to true (.T.), the commands for that case are executed and any further case statements are ignored. Following execution of the commands, the program continues after the endcase statement. If an otherwise statement is present and no case condition evaluates to true, the otherwise commands are executed.
If no case condition evaluates to true, and there is no otherwise statement specified, then control skips to the next command following the endcase.
Example
The Recital if Statement
The if command processes commands based on the evaluation of a logical condition.
if <condition as logical> [elseif <condition as logical>] [else] endif
If the result of the if condition is true (.T.), then the commands that follow up to an else, elseif or endif statement are executed.
The elseif clause can be added to the 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. [edit] 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.