menu_item_array
menu_item_array (menupath, arr)
This function fills the array arr with all the menu item labels in the menu specified by menupath, returning the number of items. Menu titles are not returned.
Each menu item label is prefixed by the name of the menu to form a menu path for use in other menu functions or commands as shown in the following example.
Menu separators are returned using the form menuname.#N, where N specifies the position in the menu. For example, Insert.#10 specifies a menu separator which is the tenth item on the Insert menu.
The menupath is a string that defines the path to the menu. As a special case, "." refers to the menu bar for the current window and all top level menu items are returned.
The function returns the number of labels stored in the array.
Example:
function show_menu_items(menu)
{
local items[];
local cnt = menu_item_array(menu, items);
local i;
for (i = 1; i <= cnt; i++) {
local label = items[i];
local cmd = menu_cmd(label);
eval label, "\t", cmd output=>*
if (cmd == "#menu") {
show_menu_items(label);
}
}
}
# Recursively enumerate the menu items and commands for the Insert menu
show_menu_items(".Insert")
Related Topics