The IF Control Structure
IF statement is a conditional branching statement.The statement block starts with IF and concludes either with ENDIF, ELSEIF, or ELSE.
IF Statement
In conditional branching statement a condition is evaluated, if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.
IF <condition1>.
<statement block>
ENDIF.
IF ELSE Statement
This feature permits the programmer to write a single comparison, and then execute one of the two statements depending upon whether the test expression is true or false. The general form of the if-else statement is
IF <condition1>.
<statement block>
ELSE.
<statement block>
ENDIF.
IF ELSEIF ELSE Statement
ELSEIF statement is useful where two or more alternatives are available for selection.The various conditions are evaluated one by one starting from top to bottom, on reaching a condition evaluating to true the statement group associated with it are executed and skip other statements. If none of expression is evaluate to true, then the statement or group of statement associated with the final ELSE is executed.
IF <condition1>.
<statement block>
ELSEIF <condition2>
<statement block>.
ELSEIF <condition3>.
<statement block>
.....
ELSE.
<statement block>
ENDIF.
To formulate conditions in IF or ELSEIF statements, you can use any logical expressionThe CASE Control Structure
The CASE statement is much like a nested if .. else statement. Its mostly a matter of preference which you use, CASE statement can be slightly more efficient and easier to read.The statement block starts with CASE and concludes either with WHEN, WHEN OTHERS, END CASE.
When the CASE statement is executed, the expression in the CASE statement is evaluated and the control is transferred directly to the group of statements whose WHEN label value matches the value of the expression.If none of expression is matched, then the statement or group of statement associated with the final OTHERS is executed.
CASE <f>.
WHEN <f11> [OR <f 12> OR ...].
<Statement block>
WHEN <f21>.[OR <f 22> OR ...]
<Statement block>
WHEN <f31> [OR <f 32> OR ...].
<statement block>
WHEN ...
......
WHEN OTHERS.
<statement block>
ENDCASE.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.