条件文は、プログラム内での制御権移動を行います。
EGL は、以下の条件文を提供します。
ループ文は、一連の文の反復回数を決定する際の条件をテストします。
ループ内の何らかによって、テストする初期条件を変更する必要があります。
EGL は、以下のループ文を提供します。
また、条件文およびループ文内でのナビゲーションに使用する次の 2 つの EGL 文があります。
ループ文にラベルを付け、ナビゲーション文でそれらのラベルを
参照できます。ラベルは、次の例のようにコロン (:) で終わります。
OuterLoop:
while(moreFood())
meal string = getMeal();
while(meal!="")
course string = nextCourse(meal);
eatCourse(course);
if(indigestion())
exit OuterLoop;
end
meal = remainingCourses(meal);
end
end
外部のループ文にラベルを付けることができない場合は、コードはより複雑にする必要があります。次の例では、追加された文は太字で表示されています。
hasIndigestion boolean = false;
while(moreFood() && !hasIndigestion)
meal string = getMeal();
while(meal != "")
course string = nextCourse(meal);
eatCourse(course);
if(indigestion())
hasIndigestion = true;
exit while; // This exits only the nearest while loop
end
meal = remainingCourses(meal);
end
end