[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|             DO CASE             |
+---------------------------------+
DO CASE
        CASE <expL1>
                <statements>
        [CASE <expL2>
                <statements>
        ...
        CASE <expLN>
                <statements>]
        [OTHERWISE
                <statements>]
ENDCASE

-----------------------------------
Executes set of commands based on logical condition.
-----------------------------------

The DO CASE command is used to execute a set of FoxPro commands
(<statements>) based on the result of a logical condition.  When the DO
CASE command is executed, successive logical CASEs are evaluated; the
results of the evaluations determine which set of commands (if any) are
executed.

When the first logically true (.T.) CASE is encountered, the
<statements> following it are executed.  Execution of the <statements>
continues until the next CASE or ENDCASE is reached.  Execution then
resumes with the first command following ENDCASE.

If a CASE is logically false (.F.), the <statements> following it up to
the next CASE are ignored.

One and only one CASE will be executed - the first true CASE.  Any
succeeding true CASEs are ignored.

If all of the CASEs evaluate to a logical false (.F.), the presence or
absence of OTHERWISE determines if any additional <statements> are
executed:

        . If OTHERWISE is included, the <statements> following OTHERWISE are
executed and execution then skips to the ENDCASE.

        . If OTHERWISE hasn't been included, none of the <statements> between
DO CASE and ENDCASE are executed.

Note that comments may be placed after DO CASE and ENDCASE on the same
line - the comments are ignored during program compilation and
execution.

+---------------------------------+
|         Program Example         |
+---------------------------------+
In this example, FoxPro evaluates each CASE until MONTH variable is
found in one of lists.  Appropriate string is stored to memory variable
RPT_TITLE and DO CASE structure is exited.

STORE CMONTH(DATE()) TO month  && The month today

DO CASE  You can place comments here!
        CASE INLIST(month,'January','February','March')
                STORE 'First Quarter Earnings' TO rpt_title
        CASE INLIST(month,'April','May','June')
                STORE 'Second Quarter Earnings' TO rpt_title
        CASE INLIST(month,'July','August','September')
                STORE 'Third Quarter Earnings' TO rpt_title
        OTHERWISE
                STORE 'Fourth Quarter Earnings' TO rpt_title
ENDCASE   Or you can place comments here!

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

See Also:  DO WHILE, FOR ... ENDFOR, IF ... ENDIF, IIF(), SCAN

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

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