Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>begin sequence...end</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
BEGIN SEQUENCE...END


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

Purpose:    To define a code sequence of statements.

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

Usage:      BEGIN SEQUENCE...END defines a sequence of statements as a
            control structure.  When a BREAK is encountered anywhere in
            the structure, control branches to the program statement
            immediately following the END statement terminating the
            current SEQUENCE.  BREAK can occur in a nested or the
            current procedure.  Execution continues after the matching
            END statement either by executing to the END or by BREAKing
            to the END.  A maximum of 15 nested SEQUENCEs are allowed.
            Procedures where BREAK is appropriate include any of the
            runtime error procedures.  This allows you to define local
            recovery operations for runtime error conditions specific to
            the context in which they occur.

            There are a number of uses for BEGIN SEQUENCE two of which
            include:

            . Localize runtime error handling by placing code likely
              to cause a runtime error within a BEGIN SEQUENCE...END
              construct and BREAK from within the error function to the
              error handling code following the END statement.

            . Return to master by placing main menu code within a
              BEGIN SEQUENCE...END construct and then execute a BREAK
              from wherever you want to RETURN to master.  Note that
              this concept can be extended to include RETURNing to any
              level within the program structure.

Library:    CLIPPER.LIB


----------------------------------- Examples -------------------------------

   This 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 example demonstrates how you can modify the
   Print_error() function to BREAK to local recovery for certain types
   of printing errors:

   * Main procedure.
   ok = .T.
   error_state = .F.
   local_err = .T.

   DO WHILE ok
      BEGIN SEQUENCE
      .
      .
      .
      END

      IF error_state
         ok = Print_Recover()       && Your recovery routine.
         error_state = .F.
      ELSE
         ok = .F.
      ENDIF

   ENDDO


   * Within Errorsys.prg.
   FUNCTION Print_error
   PARAMETERS name, line
   PUBLIC local_err

   IF local_err
      error_state = .T.
      BREAK
   ENDIF

   <rest of error function>...


See Also: RETURN

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson