Recital Flow Control and Looping

From Recital Documentation Wiki
Revision as of 14:18, 14 January 2010 by Yvonnemilne (Talk | contribs)

Jump to: navigation, search

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 .T., the otherwise commands are executed.

If no case condition evaluates to .T., 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 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. [edit] 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. [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.

if <condition as logical>
[elseif <condition as logical>]
[else]
endif

Recital Looping Statements

Recital for loops

Recital do...while loops

Recital foreach loops

Breaking a Loop

Skipping Statements in a Loop

Summary