Programming Guide |
Returns the last error returned by a menu function
int sm_menu_bar_error(void);
- 0
MNERR_OK
: Success.
- -1
MNERR_SCRIPT
: Script not found, or script or menu name not supplied.
- -2
MNERROR_EMPTY_SCOPE
: Menu not installed at specified scope.
- -3
MNERR_NOT_SUPPORTED
: Menus not supported.
- -4
MNERR_MENU
: Menu name not found.
- -5
MNERR_ITEM
: Item name not found.
- -7
MNERR_MALLOC
: Memory allocation error.
- -8
MNERR_NULL
: Property has a value of null string pointer.
sm_menu_bar_error
returns the error generated by the last call to a menu function. This is particularly useful for calls to sm_menu_get and sm_mnitem_get and their variants. These functions return the value of the specified property when successful; otherwise, they return-1
for failure of the_get_int
variants, and0
for the_get_str
variants.sm_menu_bar_error
returns the actual cause of failure. It also lets you determine whether a return of-1
indicates the property's actual value or an error condition.Because Panther retains the error code only for the last call to one of the menu functions, call
sm_menu_bar_error
immediately afterward to evaluate the call's return status.
/*enable and disable menu tear-offs*/
int ToggleTearOffs(void)
{
int errorCode;
switch(sm_menu_get_int(MNL_SCREEN, "menucom", "main", MN_TEAR))
{
case 0: /*enable tear-offs */
sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 1, NULL);
break;
case 1: /*disable tear-offs */
sm_menu_change
(MNL_SCREEN, "menucom", "main", MN_TEAR, 0, NULL);
break;
case -1: /* if error returned, find out why */
errorCode = sm_menu_bar_error();
menuErrorHandler(errorCode);
break;
}
}