5.2. Executing Macros and Macro Libraries

You can execute any macro file by issuing the *USE command. For example, to execute the macro called MYMACRO (no extension) residing in the current working directory, you would issue

*use,mymacro

In this case, the macro takes no arguments. If instead the macro was called MYMACRO.MACRO and resided in /myaccount/macros, you could call it with

*use,/myaccount/macros/mymacro.macro

Note that the *USE command allows you to enter the path and extension along with the file name and that these are not entered as separate arguments.

If a macro has a .mac file extension and resides in the search path, you can execute it as if it were a Mechanical APDL command by simply entering it in the command input window. For example, to call mymacro.mac you could simply enter

mymacro

You can also execute macros with a .mac extension through the Utility Menu> Macro> Execute Macro menu item.

If the same macro takes arguments (see Passing Arguments to a Macro for more information about passing arguments to macros), then these can be entered on the command line as follows

mymacro,4,3,2,1.5

or

*use,mymacro.mac,4,3,2,1.5

The Utility Menu> Macro> Execute Macro menu item dialog provides fields for arguments.

Executing macros contained in macro libraries is similar. You must first specify the library file using the *ULIB command. For example, to specify that macros are in the mymacros.mlib file, which resides in the /myaccount/macros directory, you would issue the following command:

*ulib,mymacros,mlib,/myaccount/macros/

After selecting a macro library, you can execute any macro contained in the library by specifying it through the *USE command. As with macros contained in individual files, you can specify arguments as parameters in the *USE command.


Note:  You cannot use the *USE command to access macros not contained in the specified macro library file after issuing the *ULIB command.