Sheerpower Logo B.3  Conditionals
There are two major types of conditionals: IF/THEN/ELSE/END IF and SELECT/CASE/END SELECT. The IF construct is useful to check one or more conditions and execute a different block of code depending on the result. For instance, say that you need to print one statement if the user is male and under 20, another if the user is male and between 20 and 40, and still another if the user is male and over 40. The IF construct works well in this kind of situation.

The SELECT construct is useful when comparing one main expression with several values and executing a different block of code for each possible match. For instance, suppose that in the tax program we mentioned before, you need to execute a different block of code depending on the user's tax bracket. SELECT CASE would let you compare a main expression of tax_bracket with all the possible tax brackets (10000-15000, 15000-25000, etc.).

Here are details on conditionals.

SWITCH and END SWITCH can be used instead of SELECT CASE and END SELECT.
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.
Wide screen