DO CASE ... ENDCASE Command Example

In this example, Visual FoxPro evaluates each CASE clause until the MONTH variable is found in one of the lists. The appropriate string is stored  to the variable rpt_title and the DO CASE structure is exited.

STORE CMONTH(DATE( )) TO month  && The month today
   
DO CASE  && Begins loop
   
   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  && Ends loop
WAIT WINDOW rpt_title NOWAIT