Writing a Template
    

A global macro template simply names the group of macro commands, whereas a local macro template lists the name and the macro command language. While the local macro template does not include macro statements or control statements, it does contain the command, its subcommands and any associated arguments.

Template Requirements

The first line of the template contains the macro name. You should use the same name for the template as the file name, unless you intend on using the template for multiple macro files. The file name is used when you invoke a macro, whereas the template name is used in constructing a macro file.

The only lines that can appear between the word MACRO and the template are comment lines that begin with #.

Command and subcommand names can contain letters, numbers, and the underscore character, up to a maximum of eight characters. They must start with a letter. Only the first four letters of macro subcommands are used by Minitab.

Command and subcommand arguments must have legal variable names.

You may have two or more macros in one file. Each macro must follow the local macro structure, and each must have a unique template name. When you invoke the macro containing multiple macros, Minitab executes the first macro in the file. You can invoke subsequent macros within the file by using a CALL statement with each template name.

If the command has subcommands, use punctuation just as in interactive Minitab: end each line with a semi-colon, and put a period after the last subcommand.

Example of a template for a command with arguments

Template

Invoked by

Trim X Xbar

%TRIM C5 K1

In the template, Trim is the command (and name of the macro), X is the first argument, and Xbar is the second argument. The X variable is the column (to be specified when the macro is invoked) where the macro should look for data. Xbar is the constant where the macro should store the result.

Example of a template for a command with a subcommand

Template

Invoked by

Trim X Xbar;
  Percent Pct.

%TRIM C1 C5;
  PERCENT 5.

In the template, the TRIM command has its arguments X and Xbar. The subcommand is Percent. Percent has an argument, Pct, that can contain a constant.