| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Exits from a BEGIN SEQUENCE block.
Break( <Expression> ) --> NIL
The return value is always NIL.
The Break() function branches program flow to the RECOVER statement of the last BEGIN SEQUENCE block and passes the value of <Expression> to the variable defined with the USING <errorVar> option, if defined. If BEGIN SEQUENCE is used with no RECOVER statement, program flow continues with the next executable statement following ENDSEQUENCE.
Break() is mainly used in conjunction with error handling, when a user defined code block replaces the standard ErrorBlock().
| See also: | BEGIN SEQUENCE, ErrorBlock(), ErrorNew(), Throw(), TRY...CATCH |
| Category: | Error functions |
| Source: | vm\break.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example shows a typical usage scenario for the Break() function.
// It is called from within a user defined error code block. The
// error code block receives an error object created by the xHarbour
// runtime system. The error object is passed to Break() and ends up
// in the RECOVER USING variable. The error condition can then be
// inspected.
PROCEDURE Main
OpenDatabase()
? "Files are open"
? "Program can start"
RETURN
PROCEDURE OpenDatabase
LOCAL oError
LOCAL bError := ErrorBlock( {|e| Break(e) } )
BEGIN SEQUENCE
USE Customer NEW SHARED
USE Invoice NEW SHARED
ErrorBlock( bError )
RECOVER USING oError
ErrorBlock( bError )
? "Unrecoverable error:"
? oError:description
? oError:operation
? oError:subsystem
QUIT
ENDSEQUENCE
RETURN
http://www.xHarbour.com