General information about macros
Macros provide a way to save various expressions as named variables that can then be used in other expressions you write. Macros are available to PDL, XPDL and SRL.
There are three different areas in which to create macros. You can create:
-
a list of macros that belong to your user profile;
-
a list of macros that are available to all users of the same server;
-
a list of a macros available for a specific project.
In general, wherever you decide to create a macro, the macro will have the same processing logic. Choosing the appropriate scope (the project, the server, or your own profile) is more a matter of how you want to organize your macros for reuse across multiple projects and/or how you plan to share your macros with other users.
Although the context of where you store a macro does not affect its logic, there is a precedence of evaluation. It does matter where you store macros when you write two macros with the same name in multiple scopes. In this case, project macros take precedence over profile and server macros, and profile macros take precedence over server macros. When you use a macro in an expression in a node, PolyAnalyst first looks for a macro with the given name within the project’s macro list. If no macro is found, PolyAnalyst next looks for the macro in your user profile. Then, if no macro is found again, PolyAnalyst looks for the macro in the server-wide macro list. Then, if no macro with the given name was found, the expression will fail to work and PolyAnalyst will report an error (such as when you attempt to execute a node containing an SRL or PDL expression that uses a non-existent macro). If you encounter this error, check your spelling, then look at each list of macros (in the same order, from project to profile to server) to find the macro yourself and ensure it exists.
Because macros can be stored in different scopes (server, profile, project), there are different ways to access the list of macros to view which macros you have defined, make changes to existing macros, delete macros, and create new macros. To edit macros within the scope of your personal profile scope, select User settings from the Settings menu, and then locate the SRL/PDL macros section in the section list on the left side of the window. Make a node that there is also a section named SRL/PDL variables, which are not to be confused with macros. Variables are described in a separate topic. Server macros can be edited within the Administrative Tool (select Server options from the Actions menu). To edit project macros, you must have a project open within the Analytical client. Select Program options from the Settings menu, and then switch to the User settings tab, and again locate the SRL/PDL macros section.
To add a new macro, right click on the section name (SRL/PDL macros) and select Add item. A new item appears underneath the section. If you do not see it immediately, click the + symbol to expand the SRL/PDL macros section, and then left click on the newly created macro (which will be named something like "Item (n)") to select the new macro and begin editing it.
To select a macro for editing, left click on its name underneath the SRL/PDL macros section name in the hierarchy of items on the left side of the options window. Upon selecting a macro, a form appears on the right side of the window containing editable fields.
To delete a macro, right click on its name in the section list and select Remove. To delete all macros (within the scope), right click on the SRL/PDL macros section name and select Remove all.
To save your changes to your macros, make sure you click OK or Apply within the Options window. Clicking OK will save your changes and close the options window. Clicking Apply will save your changes but leave the options window open. It is recommended to periodically click Apply (e.g. after editing each macro) to save your changes, as closing with window without saving will revert the state of the list of macros back to the state when you first opened the window.
Like any section of options, you can export a set of options to an XML file as well as import an XML file to automatically generate a set of macros. Exporting and importing a list of macros is a helpful way of backing up your macro list. Exporting is also a way to archive older versions of your macros if you are concerned about changes you are making or would like to experiment. You can also use the export and import methods to move macros from one list to another.