Apr 17
Sample “if…elseif….else”
if condition1 (is true)
instruction a
instruction b
.
.
instructionX
elseif condition2 (if the condtition 1 returns false evaluate with condition2)
instruction c
instruction d
.
.
instructionX
else (if the result is false for both levels then the following code is executed)
instruction e
instruction f
.
.
instructionX
end
The control structure evaluates the necessary ‘contition1′, if it returns true if executes instructions that follow the if statement. If it is false, it proceeds to the elseif using ‘condition2′ to evaluate it, if it satisfies condition2, then it executes code that immediately follows the elseif control. If both evaluations return false, it then proceeds to execute the instructions after the else control.
Comments are off for this post
