Arbortext Command Language > Using the Arbortext Command Language > Menu Paths
  
Menu Paths
A menu path is a way of indicating the exact location of an item in the menu system. (This item can be either an item on a menu, or the menu itself.)
Menu paths look like directory paths, except periods are used to separate the components instead of slashes. The leading parts of a menu path correspond to a menu name, the trailing part matches a menu item. For example, .File.New refers to the item New on the File menu.
A menu path is considered absolute if it starts with a period (.). The name following the period must be the name of one of the top level menus on the menu bar. (For example, .File, .Edit, .Tools.) If a menu path does not start with a period, the entire menu bar hierarchy for the current window is searched for the first occurrence of the item starting with the first menu on the left and progressing down through every item on a menu before moving on to the next menu to the right.
You can use the menu path to specify a destination (as with the menu_add and menu_move commands). If a dot appears at the end of a menu path, it indicates the last item on the last menu named. For example, menu_add .File.New. 'Create Invoice' specifies that the new item Create Invoice would be added at the end of the New submenu of the File menu, but menu_add .File.New 'Copy Document' would cause the new item Copy Document to be added to the File menu after the item New.
When matching a menu path against a menu item, the mnemonic key character & is ignored in both strings. For example, ".File.New" will match the "&File” menu. Also, it is not necessary to specify a trailing ellipsis ("...") or mnemonic of the form "(&X)" on the target menu item. The menu path ".File.Open" will match the "Open..." menu item of the "File" menu. Similarly, ".File.Exit" will match the "File" menu item "Exit(&Q)". The trailing mnemonic (&X) is often used with Asian localized menus.
The syntax of a menu path allows specifications of a menu item by position and also by name. If a component of a menu path begins with # and is followed by one or more digits, then this specifies a numeric position. For example, the menu path .File.#3 specifies the third item in the File menu. Numeric positions may be specified in any component. For example, .File.#1.#2 is the same as .File.New.Sample, assuming the default menu configuration. The first non-title item is referenced by #1. The menu title, if any, may be specified by using #0. Blank or separator lines within the menu count as items. The function menu_item_count may be used to obtain the number of items in a menu.
Menu item labels may contain variable references. If a menu label contains any variable references, for example, Modify $tagname, the variable reference is substituted into the label string each time the menu containing the item is posted.
Related Topics
Modifying the default menus
Special characters in menu paths
Shortcut menus