Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Cobol

Idiom #131 Successive conditions

Execute f1 if condition c1 is true, or else f2 if condition c2 is true, or else f3 if condition c3 is true.
Don't evaluate a condition when a previous condition was true.

IDENTIFICATION DIVISION.
PROGRAM-ID. condition.
PROCEDURE DIVISION.
    EVALUATE TRUE
	WHEN c1
	   PERFORM f1
	WHEN c2
	   PERFORM f2
	WHEN c3
	   PERFORM f3
    END-EVALUATE  
STOP RUN.
if c1 then
    f1;
elsif c2 then
    f2;
elsif c3 then
    f3;
end if;

assume that f, g, and h are procedure and that a and b are Boolean

New implementation...
< >
programming-idioms.org