Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - breakout() perform a break http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 breakout()          Perform a break
------------------------------------------------------------------------------
 Declaration
   system.hdr

 Syntax
   proc breakout extern
   param value ulong nInfo

 Arguments
   nInfo is an arbitrary numeric value.

 Return
   None.

 Description
   The breakout() function interrupts normal program flow by breaking
   out of the code executed by the breakbegin() function. Calling
   breakout() from breakable code results in executing the recovery function
   installed by breakbegin(), then control is returned to the point just
   after the call to breakbegin().

   The breakout() function performs the break, i. e. it calls the recovery
   procedure, passing the nInfo parameter to it, provided that a recovery
   procedure has been defined via the call to the breakbegin() function.
   Finally, program execution resumes with the instruction following
   the breakbegin() call.

 Example
   #define EXAMPLE_SYSTEM
   #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 CleanUp static
   param value ulong nInfo
   ? "Terminated by the user"
   ? "Free memory is", istr( nInfo )
   endproc
   
   proc PrintTest
   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_breakout
   ? "Printing list..."
   ?
   breakbegin( &PrintTest, &CleanUp )
   ? "end"
   endproc

   proc main
   Test_breakout()
   endproc

See Also: breakbegin()

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