[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
BEGIN SEQUENCE...END

    BEGIN SEQUENCE...END defines a control structure for user-defined error
    scoping within the flow of a program.

Syntax

    BEGIN SEQUENCE
       <statements>...
       [BREAK]
       <statements>...
    END

Options

    Break: The BREAK statement branches execution to the statement
    immediately following the matching END statement.

Usage

    BEGIN SEQUENCE...END is a control structure that allows relatively easy
    definition of exception handling.  When an exception occurs, issue a
    BREAK to branch control to the program statement immediately following
    the END statement that terminates the current SEQUENCE program
    structure.  BREAK can occur in a nested or the current procedure.
    Nested procedures can be nested any number of levels below the BEGIN
    SEQUENCE structure which may also include any of the runtime error
    procedures.  The latter allows you to define local recovery operations
    for runtime error conditions specific to the context in which they
    occur.  It can also be used to simulate RETURN TO MASTER (see below for
    example).

Examples

    The following code fragment demonstrates the SEQUENCE construct within
    a nested or the current procedure:

    BEGIN SEQUENCE          
       <statements>...      
       IF break_cond        
          BREAK             
       ENDIF                
       <statements>...      
    END                     
                            
    <recovery statements>...

    The following code fragment demonstrates simulation of RETURN TO
    MASTER.

    *1st level menu                                         
    *                                                       
    DO WHILE .T.                                            
       BEGIN SEQUENCE                                       
       CLEAR                                                
       @ 01,01 say "Master Menu..."                         
       @ 05,05 PROMPT "Go one level down"                   
       @ 06,05 PROMPT "No operation     "                   
       @ 07,05 PROMPT "Quit             "                   
       MENU TO first                                        
       DO CASE                                              
          CASE first = 1                                    
             DO menu2                                       
          CASE first = 2                                    
             @23,01 say "No-op choice...press any key..."   
             inkey(0)                                       
          CASE first = 3                                    
             EXIT                                           
       ENDCASE                                              
       END SEQUENCE                                         
    ENDDO                                                   
    RETURN                                                  
                                                            
    *********                                               
    * 2nd level menu                                        
    *                                                       
    PROCEDURE menu2                                         
    DO WHILE .T.                                            
       CLEAR                                                
       @ 01,01 say "Menu 2 ..."                             
       @ 05,05 PROMPT "Go one level down"                   
       @ 06,05 PROMPT "No operation     "                   
       @ 07,05 PROMPT "Quit             "                   
       MENU TO second                                       
       DO CASE                                              
          CASE second = 1                                   
             DO menu3                                       
          CASE second = 2                                   
             @23,01 say "No-op choice...press any key..."   
             inkey(0)                                       
          CASE first = 3                                    
             EXIT                                           
       ENDCASE                                              
       @ 24,01 say "exiting"                                
       INKEY(0)                                             
    ENDDO                                                   
    RETURN                                                  
                                                            
    *********                                               
    * 3rd level menu                                        
    *                                                       
    PROCEDURE menu3                                         
    DO WHILE .T.                                            
       CLEAR                                                
       @ 01,01 say "Menu 3 ..."                             
       @ 05,05 PROMPT "Return to Master "                   
       @ 06,05 PROMPT "No operation     "                   
       @ 07,05 PROMPT "Quit             "                   
       MENU TO third                                        
       DO CASE                                              
          CASE third = 1                                    
             BREAK                                          
          CASE third = 2                                    
             @23,01 say "No-op choice...press any key..."   
             inkey(0)                                       
          CASE third = 3                                    
             EXIT                                           
       ENDCASE                                              
       @ 24,01 say "exiting"                                
       INKEY(0)                                             
    ENDDO                                                   
    RETURN                                                  

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