[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
IF                       Conditional Branch

 1. Block syntax

    IF expression THEN
       statement1
       [statement2]
       .
       .
       .
    [ELSEIF expression THEN
       statement10
       [statement11]
       .
       .
       .
    [ELSE
       statement15
       [statement16]]
       .
       .
       .
    ENDIF


 2. Single-line syntax (three variants)

    IF expression THEN statement1 [ELSE statement2]

    Causes QuickBASIC to make a decision based on the value of an
    expression.

  expression    A numeric expression; 0 is equivalent to FALSE, while all
                other values are equivalent to TRUE.

   statement    Any legal statement.  The single-line mode's statement can
                be just a line number or line label.  This is equivalent
                to a GOTO statement with the specified label.

   ----------------------------------------------------------------------

      Notes:    Each expression in the IF/ELSEIF construct is tested in
                order.  As soon as an expression is found to be TRUE, then
                its corresponding statements are executed.  If no
                expressions are TRUE, then the statements following the
                ELSE keyword are executed.  If ELSE is not specified, then
                execution continues with the statement following the ENDIF
                or the single-line IF statement.

                The only difference between QuickBASIC's one-line
                construct and that of interpreted BASIC is that QuickBASIC
                allows the use of labels as well as numbered lines.

                In the block construct, the following rules apply:

                    IF, ELSE, ELSEIF, and ENDIF must all be the first
                    keywords on their respective lines.

                    THEN must be the last keyword on its line; if anything
                    other than a comment follows on the same line with
                    THEN, QuickBASIC thinks it's reading a single-line
                    IF/THEN/ELSE construct.

                IF blocks may be nested.

                Do not put a colon before the ELSE keyword.

See Also: ON...GOTO ON...GOSUB SELECT
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson