Hi
I use this recursive function on the menu. To start with I call it from the windows, passing MenuId and the string of the item to be found. This logic can be included/used in a menu function that enables/disables the menu item.
Regards
Arthur
of_FindMenuItem (menu am_current, string as_menuitem);/
******************************************
Description : Searches a menu item
Parameters : am_current: Current menu, as_menuitem: Menu item Name
Returns : menu
******************************************/
integer li_Counter, li_Max
menu lm_Item, lm_RetItem
li_Max = UpperBound( am_Current.Item )
FOR li_Counter = 1 TO li_Max
lm_Item = am_Current.Item[li_Counter]
IF lm_Item.ClassName() = as_menuitem THEN // Found
RETURN lm_Item
ELSE
IF UpperBound( lm_Item.Item ) > 0 THEN
lm_RetItem = of_FindMenuItem( lm_Item, as_MenuItem )
IF NOT IsNull( lm_RetItem ) THEN
RETURN lm_RetItem
END IF
END IF
END IF
NEXT
SetNull( lm_Item )
RETURN lm_Item
This functions is really helpful in how to understand how the menu is built up.
I can use it both for traversing the menu, and to enable/disable the menus I want.
Regards,
Bjarne