[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_BRKRECOVER Breakable code recovery function type
------------------------------------------------------------------------------
Declaration
database.hdr
Syntax
proc _BRKRECOVER ptr
param value ulong nInfo
Arguments
nInfo is an arbitrary numeric value, forwarded by the breakout() function.
Return
None.
Description
The _BRKRECOVER function type is used to declare a pointer to a function
that is called before execution of breakable code resumes. The
_BRKRECOVER type is used by the breakbegin() and breakout() functions.
Example
#define EXAMPLE_TYPE
#include example.hdr
/*
This code could be part of a deeply nested program structure, taking
care of printing a list. Before printing a line, it checks if the
printer is ready, and allows the user to bail out if this is not the case.
*/
proc CleanUp3 static
param value ulong nInfo
? "Terminated by the user"
? "Free memory is", istr( nInfo )
endproc
proc PrintTest3
vardef
char( 1 ) cAnswer
logical lMore
enddef
lMore := .t.
do while lMore
? "Printing a line..."
if .f. // Place result of printer test here - for the demo, we
// assume that the printer is never ready.
// Print a line here, and set lMore to .f. if all lines are done
else
sound( 2000, 20 )
@ row() + 1, 0 ?? "Printer not ready - <R>etry, <A>bort"
cAnswer := ""
repeat
cAnswer := upper( chr( getkey() ) )
until cAnswer $ "RA"
if cAnswer == "A"
breakout( coreleft() )
endif
endif
enddo
? "Printing was successful"
endproc
proc Test_BRKRECOVER
vardef
ptr( _BRKEXEC ) pExec
ptr( _BRKRECOVER ) pRecover
enddef
pExec := &PrintTest3
pRecover := &CleanUp3
? "Printing list..."
?
breakbegin( pExec, pRecover )
? "end"
endproc
proc main
Test_BRKRECOVER()
endproc
See Also: breakbegin() breakout()
Online resources provided by: http://www.ClipX.Net --- NG 2 HTML conversion by Dave Pearson