Editor scripts

From Axaptapedia

Jump to: navigation, search

Contents

[edit] Use

Editor scripts are the short programs for automating tasks in the Axapta code editor.

Scripts can be called via:

  • Pressing Alt+M and selecting scripts in menu
  • Calling context menu in the editor (Scripts submenu)
  • Pressing the Scripts button in the editor toolbar

Autohotkey macros can be used to assign hotkeys to Editor Scripts

[edit] Development

The Scripts menu is constructed from the structure EditorScripts class using the following rules:

  • each method which takes a single argument with the type Editor class is an editor script
  • if the method name contains an underscore (_) it is placed under a submenu with the same name as the part of the method name before the underscore. For example, \Classes\EditorScripts\template_method_parm becomes menu item "parm" in "method" submenu under "template" submenu in the scripts menu.

[edit] Example

This script adds item "context" to the Scripts menu. This item shows standard Add-ins menu.

void context(Editor _e)
{
  SysContextMenuTreeNode toolsMenu=
      SysContextMenuTreeNode::newPath(_e.path());
  PopupMenu popupMenu = toolsMenu.buildMenu(InfoLog.hWnd());
  int x, y;
  ;
 
  [x, y] = WinAPI::getCursorPos();
  toolsMenu.runMenu(popupMenu.draw(x, y), toolsMenu, _e);
}

[edit] Links

Editor_scripts_OpenInAOT - a good script that is added into the addIns submenu. Opens the selected object and its properties.

Personal tools