5.3. Local Variables

APDL provides two sets of specially named scalar parameters which are available for use as local variables. These consist of

  • A set of scalar parameters that provide a way of passing command line arguments to the macro.

  • A set of scalar parameters that can be used within the macro. These provide a set of local variables that can be used to define values only within that macro.

The following sections discuss both of these variable types in detail.

5.3.1. Passing Arguments to a Macro

There are 19 scalar parameters that you can use to pass arguments from the macro execution command line to the macro. These scalar parameters can be reused with multiple macros; that is, their values are local to each macro. The parameters are named ARG1 through AR19 and they can be used for any of the following items:

  • Numbers

  • Alphanumeric character strings (up to 32 characters enclosed in single quotes)

  • Numeric or character parameters

  • Parametric expressions


Note:  You can pass only the values of parameters ARG1 through AR18 to a macro as arguments with the *USE command. If you create a macro that can be used as a Mechanical APDL command (the macro files has a .mac extension), you can pass the values of parameters ARG1 through AR19 to the macro.


For example, the following simple macro requires four arguments, ARG1, ARG2, ARG3, and ARG4:

/prep7
/view,,-1,-2,-3
block,,arg1,,arg2,,arg3
sphere,arg4
vsbv,1,2
finish

To execute this macro, a user might enter

mymacro,4,3,2.2,1

5.3.2. Local Variables Within Macros

Each macro can have up to 80 scalar parameters used as local variables (AR20 through AR99). These parameters are completely local to the macro, and multiple macros can each have their own unique values assigned to these parameters. These parameters are not passed to macros called from macros (nested macros). They are passed to any files processed through a /INPUT command or a "do loop" processed within the macro.

5.3.3. Local Variables Outside of Macros

Mechanical APDL also has a similar set of ARG1 through AR99 scalar parameters that are local to an input file, and are not passed to any macros called by that input file. Thus, once a macro finishes and execution returns to an input file, the values of ARG1 through AR99 revert to whatever values were defined within the input file.