MnuAdd (Magic xpa 2.x)

« Go Back


Created ByKnowledge Migration User
Approval Process StatusPublished


Enables the programmer to dynamically add a menu structure to the current runtime pulldown menu structure.


MnuAdd (Menu Entry, Menu Path)


Menu Entry – A numeric value for the number of the menu in the Menu repository. You can use the MENU literal, this will ensure that the code stays correct even if the menu item changes position in the repository.

Menu Path – The menu path that tells where to add the menu.
The menu path is made up of menu Entry Names. A backslash (\) will define a submenu. The format of the path is:
Entry name[\entry name][\]

The backslash defines whether the menu structure will be added into the submenu defined in the last <entry name>. It will be inserted as the first option in that menu.
For example: “Options\Project\” will insert this menu in the Project submenu of the Options menu entry.

For more information, see: Setting Up a Menu Path


Logical – True if successful


MnuAdd ('3'Menu, 'Edit'Customers')

This will add the third menu to the runtime menu structure. It will appear in the Edit menu, after the Customers entry.

In this example, the Customers entry was defined as a submenu in the Default Pulldown menu’s Menu Definition repository.


  • Magic xpa will scan the runtime pulldown menus to find a match for the path outlined in the Menu Path parameter. If a match is found, it will be added where the match is found.

    The menu structure will be added in the first place in which a match is found.

    If a match is not found, the function will fail.

    The structure will be added after the last entry name in the path. If you want to add it to a further submenu, you can use the backslash. If at runtime the entry name defined before the backslash is evaluated not to be a submenu, the function will return false.

    If the menu path is blank, the structure will be added to the top-level pulldown menu.

    The following Menu functions are valid for this new menu: MnuEnabl, MnuShow, MnuName, MnuCheck.

  • When you use this function to add menus to a parallel program, the menu entries are added to the pulldown menu and the context menu. (Since version: 2.1)

Platform specific:

This function is not supported for mobile devices.

See also:

How Do I Change the Menu of a Running Program?

The Online and Rich Client Samples projects (program MN02 and RMN02)