Understanding macro commands and syntax
To edit and write macros, you must understand the PerfectScript programming language and the principles of computer programming. For most users, recording macro commands is more efficient than typing commands into the macro. WordPerfect opens a new blank window with another macro bar. After you have recorded keystrokes or commands, WordPerfect returns to the macro you are editing and inserts the newly recorded commands.
When you create macros using the macro command browser, the macro commands appear in a separate document, numbered. The first line of the macro identifies the program and default language that it uses. The remainder of the macro performs the reported instructions.
For more information about macro commands, see “Using macro conventions and formatting macros.”
Understanding components of macro commands
Macro commands consist of four parts: a command name, parameters, enumerations, and separators. The table and example below display and describe these elements of syntax.
The command in the above example has two parameters:
Adjust. They are separated by a semicolon. Adjust is a repeating parameter with two enumerations specified:
FitLineSpacing. All the Adjust parameters are enclosed in braces to group them.
When you create macros using the macro command browser, the commands are inserted in the correct format. If you type a macro without the macro command browser, you must arrange macro commands and their elements in a precise order or syntax. Each macro command must be spelled correctly and must include all the required parameters and separators.
Using types of macro commands
There are three types of macro commands: product commands, OLE object commands, and programming commands. Product commands are specific to a product, such as WordPerfect or Quattro Pro. OLE object commands perform tasks on an OLE object. Programming commands work across applications; they are PerfectScript commands.
Command names often describe an action, such as
FootnoteOption, in WordPerfect;
ToolbarCopy in Presentations; or
Range in Microsoft Excel. Command names are not case sensitive and usually do not contain spaces. Exceptions include programming commands that call a subroutine, such as
Case Call or
A macro can use more than one application product and OLE object. Commands to the non-default application or OLE object require a prefix, which is specified in an application or object statement. For example,
A1 (followed by a period) is the prefix. It tells the compiler to use the application or Object assigned A1 in a PerfectScript application or Object statement.
Syntax refers to the grammatical rules that govern the form of macro statements and expressions. For example, the syntax of the following statement, which types “John Doe,” is correct:
The syntax of the next example is incorrect and produces an error message because the statement lacks a closing parenthesis:
If you find it difficult to distinguish different parts of a macro, remember that you can add extra line spaces, tabs, and even font changes to make the macro more readable. As long as the commands are written correctly, the macro compiler ignores extra spaces and lines.