[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DO CASE
 Execute one of several alternative blocks of statements
------------------------------------------------------------------------------
 Syntax

     DO CASE
     CASE <lCondition1>
        <statements>...
     [CASE <lCondition2>]
        <statements>...
     [OTHERWISE]
        <statements>...
     END[CASE]

 Arguments

     CASE <lCondition> defines a block of statements to be executed if
     <lCondition> evaluates to true (.T.).

     OTHERWISE defines a block of statements to be executed if none of
     the specified CASE conditions evaluates to true (.T.).

 Description

     DO CASE...ENDCASE is a control structure that executes one of several
     blocks of statements depending on which of the associated conditions is
     true (.T.).  It works by branching execution to the statements following
     the first CASE <lCondition> that evaluates to true (.T.).  Execution
     continues until the next CASE, OTHERWISE, or ENDCASE is encountered.
     Control then branches to the first statement following the next ENDCASE
     statement.

     If none of the CASE conditions evaluates to true (.T.), the statements
     following the OTHERWISE statement are executed up to the matching
     ENDCASE statement.  If an OTHERWISE statement is omitted, control
     branches to the first statement following the matching ENDCASE
     statement.

     You may nest any number of statements, including other control
     structures (i.e., DO WHILE and FOR), within a single DO CASE structure.
     In addition, within a single DO CASE structure, there is no fixed limit
     on the number of CASE statements that a DO CASE structure may contain.

     DO CASE...ENDCASE is identical to IF...ELSEIF...ENDIF with neither
     syntax having a specific advantage over the other.

 Examples

     .  This example uses DO CASE in a menu structure to branch
        control based on user selection:

        @ 3, 25 PROMPT "First choice"
        @ 4, 25 PROMPT "Second choice"
        MENU TO nChoice
        //
        DO CASE
        CASE nChoice = 0
           RETURN
        CASE nChoice = 1
           ChoiceOne()
        CASE nChoice = 2
           ChoiceTwo()
        ENDCASE


See Also: BEGIN SEQUENCE DO WHILE FOR IF IF()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson