Compiling macros

You must compile a macro before you can play it. The programs that compile macros are called compilers. A macro compiler is used to compile or “translate” macros so that WordPerfect Office applications can play them. WordPerfect compiles a macro every time you save it.

Macros are written with an editor or word processor and saved as a source file. The macro compiler creates an object, which it saves in a hidden area of the source file (the macro compiler does not create a separate object file). When you edit the source file, the object is destroyed. The object is recreated each time the source file is compiled. A compiled source file (macro) contains instructions that are executed when you play the macro.

When you compile a macro, you might receive error messages which can indicate misspelled commands, missing parentheses or semicolons, and other syntax errors. If you receive an error message while the macro is compiling, you must correct all the errors before the macro will play. You can edit the macro to fix the errors.

WordPerfect macros have three types of errors: syntax errors, run-time errors, and logic errors.


Identifying syntax errors

Syntax errors appear when you are compiling a macro. The PerfectScript compiler flags unrecognizable commands, such as missing parentheses or semicolons and incorrectly spelled command names. For example, if you type Centr (WordPerfect command) instead of Center, a compile-time syntax error is displayed in a syntax error message box when you save and compile.

The compiler identifies syntax errors and suggests solutions. The error message displays information about the error and its location. The compiler makes a best guess and may not always be accurate. You must correct all errors before a macro can compile correctly. If you continue the compilation after an error is displayed, subsequent errors may be inaccurate.

Common syntax errors include

 
missing semicolons between parameters
 
missing parentheses
 
missing double quotation marks
 
missing command in a conditional or loop statement
 
misspelled macro command names
 
undefined calling statements
 
using commas between parameters instead of semicolons


Identifying runtime errors

Runtime is the same as execution time. Run-time errors occur while the macro is playing. Referencing a variable that has not been assigned a value causes a run-time error. Run-time error messages identify errors that occur while the macro plays and show where errors occur.


Identifying logic errors

When a macro does not produce the expected result, you may have a logic error. When a macro has a logic error, it plays without producing any error messages because WordPerfect accepts all of the macro commands.


Troubleshooting macro problems

The compiler can help you troubleshoot macro problems. If the compiler locates an error, a dialog box displays information about the problem. The compiler only directs you to the problem; it does not identify it.

The PerfectScript application has debugging features. For more information about PerfectScript, see the PerfectScript application online Help.

If you are writing or editing a macro, when you compile you change what is on screen to a language that PerfectScript can play. If you want PerfectScript to be able to read errors in the file, you must create a listing or log file. When you generate a listing file, PerfectScript saves it with a .wcl filename extension. If you want to debug PerfectScript macros using the PerfectScript debugger to tell you where the problems are located, you must set PerfectScript to produce a listing file every time you save and compile the macro. For more information about the PerfectScript debugger, see the PerfectScript online Help.


To compile a macro

WordPerfect Office btnbacktotopproc Compiling macros
 
Click Save & compile on the Macro toolbar.
If the Macro toolbar is not displayed, click Tools WordPerfect Office onestep Compiling macros Macro WordPerfect Office onestep Compiling macros Macro toolbar.

WordPerfect Office note Compiling macros

 
If a macro you compile has error messages, WordPerfect still saves it even if you do not fix the compile errors.

To set PerfectScript to generate a listing file when you compile a macro

WordPerfect Office btnbacktotopproc Compiling macros
1.
 
On the Windows taskbar, click Start WordPerfect Office onestep Compiling macros Programs WordPerfect Office onestep Compiling macros WordPerfect Office WordPerfect Office onestep Compiling macros Utilities WordPerfect Office onestep Compiling macros PerfectScript.
2.
 
Click Tools WordPerfect Office onestep Compiling macros Settings.
3.
 
Click the Compile tab.
4.
 
Enable the Generate listing file check box.

To find macro errors by using the PerfectScript debugger

WordPerfect Office btnbacktotopproc Compiling macros
1.
 
Click Tools WordPerfect Office onestep Compiling macros Macro WordPerfect Office onestep Compiling macros Edit.
2.
 
Choose a macro.
3.
 
Click Edit.
4.
 
Click where you want WordPerfect to begin debugging the macro.
5.
 
Type Step (On!).
If you want to display a debug window, type Display (On!).
6.
 
Click Save & compile on the Macro toolbar.
7.
 
Type a filename and path in the Listing filename box.

WordPerfect Office note Compiling macros

 
By default, listing files, which have a .wcl filename extension, are saved to the same location as the macro you are compiling.

Compiling macros