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 - menuseterror() set the menu error handler method http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menuseterror()      Set the menu error handler method
------------------------------------------------------------------------------
 Declaration
   menu.hdr

 Syntax
   proc menuseterror extern
   param value logical lSet

 Arguments
   lSet is the new error mode.

 Return
   None.

 Description
   The menu system functions base upon dynamic structures in memory that are
   created at runtime. Therefore, it is important to make sure that the
   functions are not called with illegal parameters to avoid system crashes.

   If, for example, the menusetprompt() would be called with an invalid menu
   pointer, it is most likely that an area in memory that is reserved for
   other important purposes would be overwritten with the new prompt text,
   thus causing unpredictable effects.

   By default, all menu functions check the validity of the passed parameters,
   like the menu pointer, and the prompt id if applicable. If invalid data is
   passed, the functions generate a run-time error message, and the program
   terminates. This is compatible to former versions of Force.

   Calling menuseterror() with .f. for the lSet argument turns off the
   default error handling, so that now the application program must include
   the necessary routines to test for invalid parameters. This requires
   careful programming, on the other hand, it allows for more flexible error
   handling, and debugging.

   You can call the menuchk() function to validate a menu pointer, and the
   other menu functions return a specific value if called with invalid para-
   meters, as described with the individual functions.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   proc Test_menuseterror
   vardef
      _MENU pMenu
   enddef
   
   clear
   
   // This has been made inactive to cause trouble
   //
   // pMenu := menunew()
   
   menuseterror( .f. )    // Turn default error handling off
   
   // Prints -1
   //
   ? menupromptnew( pMenu, 5, 10, " 1st prompt ", 1, .t., .t. )
   
   menuseterror( .t. )    // Turn default error handling on
   
   // Causes a run-time error
   //
   ? menupromptnew( pMenu, 6, 10, " 2nd prompt ", 2, .t., .t. )
   
   endproc

   proc main
   Test_menuseterror()
   endproc

See Also: menuchk()

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