Sheerpower Logo B.3  Conditionals
Conditionals, like IF and SELECT/CASE decide whether certain statements need to be executed or not. For instance, suppose you are writing a tax program. For this, you need to use the EZ form if certain conditions are met, or the short form if others are met, and the long form otherwise. You would use a conditional statement to determine which form to use.

There are two types of conditionals: IF/THEN/ELSE and SELECT CASE. 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 CASE 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.

Hide Description



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