Conditional Statements

Conditional statements are used where your program must evaluate whether a logical statement is true or false. These include, but are not limited to:

Click each link to expand and collapse each sample window...

IF-THEN-ELSE

General form:
IF(CONDITION evaluates to TRUE) THEN
DO SOMETHING
ELSE
DO SOMETHING ELSE

WHILE, DO-WHILE, and DO-UNTIL loops

General form:
WHILE(CONDITION evaluates to TRUE)
DO SOMETHING
LOOP

DO
SOMETHING
WHILE(CONDITION evaluates to TRUE)

DO
SOMETHING
UNTIL(CONDITION evaluates to TRUE)

FOR and FOREACH loops

General form:
FOR(ITERATOR; CONDITION; INCREMENTOR)
DO SOMETHING

FOREACH(ELEMENT in COLLECTION)
DO SOMETHING

SWITCH or SELECT CASE statements

General form:
SWITCH (COMPARITOR)
CASE (VALUE1):
    DO SOMETHING
    BREAK
CASE (VALUE2):
    DO SOMETHING
    BREAK
CASE (DEFAULT VALUE):
    DO SOMETHING
    BREAK
END SWITCH

Back to top Comments ( 0 ) • Login to comment.

Sorry. There are currently no comments for this article.