Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2024 by Barry MacDonnell. All Rights Reserved.

Page updated Jun 16, 2026
[Original date: Aug 13, 2008]
WordPerfect Tips
Main tips page | Browse more tips

How to put instructions or comments inside a macro to annotate the macro code

Related tip:

How to copy plain-text macro code from the Internet (i.e., web page, newsgroup post, or e-mail) into WordPerfect to create a functioning macro

There are several ways a macro writer can put programmer comments or other, non-command information into a macro. Examples of these are shown in dark red below.

Open the macro for editing with Tools, Macro, Edit.

Then use any one (or more) of the following methods.

1. Precede the comment with at least 2 slash (//) marks:

// This is a comment.

- These comments can be on a separate line from macro commands, or on the same line as a macro command following that command.

- Two (or more) slash marks are often used to temporarily disable -- "toggle off" everthing that follows up to a hard return ([HRt]) -- e.g., a macro command you want to test by disabling it without removing (deleting) it.

Important: Each paragraph (single-line or multi-line)--that is, any text information or macro commands that end with a hard return--cannot exceed 510 characters including the double slash marks. PerfectScript will pop up an error message if you exceed this limit. (For longer comments, just separate them into shorter "double-slashed" comments or use the IfPlatform example in the tip #3 below).

2. Bracket the comment -- or even macro commands you want to temporarily disable -- with pairs of symbols like this:

/* This is a comment. */ <- In this example single line comment, note that a space character or a Tab1 (or a hard return (see the multi-line comment example below) to separate the comment's text from the terminal bracket characters) immediately following any period/full stop (i.e.: .<space>*/) is required, as shown here, or the program will not compile the macro. [Thanks to VictorO at WordPerfect Universe.com here for this information.]
-----
1 This can be several spaces or Tabs following the period, which, for me (using WP2020), some other symbols, such as -, +, =, ), ], > in the comment's text can also be a problem: like the period they might require some "spacing" after them and before the */ delimiter. Otherwise the program can pop a Syntax Error message ("An invalid command starting token has been encountered") when you use the Save & Compile button while editing the macro. So, adding spaces (or Tabs) after the terminal period or other character symbol -- or just removing the period/symbol -- should solve the error-producing problem.

-- or like this multi-line comment example ([HRt]=hard return code, visible in the Reveal Codes window):

/*
This is a comment:
Lorem ipsum dolor sit amet.[HRt]
This is another comment: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequay.[HRt]
*/

[Note: This method is not available in some earlier versions of WordPerfect.]

[Note that each paragraph above -- text information or example macro code that ends with a hard return -- cannot exceed 510 characters including the bracket characters. PerfectScript will pop up an error message if you exceed this limit. If that happens simply break up the responsible paragraph into smaller segments.]

3. For longer comments, such as those that introduce the macro, you can put the comment inside a "dummy" IfPlatform() macro command. For this purpose, PerfectScript's command's (parameter) can be anything that is not recognized by WP as legitimate. For example:

IfPlatform ("My comments begin here.") <- This example includes my optional explanatory notation in quotes--which should be  something that will not be recognized by the program as a macro command.

This is the comment area--A single line (or more) of text typically ending with a hard return: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.[HRt]

EndIfPlatform

Here, WordPerfect will simply ignore the IfPlatform..EndIfPlatform commands and everything ibetween them.

[Note that each paragraph-- text that ends with a hard return -- inside the paired IfPlatform..EndIfPlatform commands still cannot exceed 510 characters including the bracket characters. PerfectScript will pop up an error message if you exceed this limit. If that happens simply break up the responsible paragraph into smaller segments.]

4. Put the comment inside a footnote. You can even store macros commands in the footnote: they will not execute when the macro plays.

5. Put comments inside a header and/or footer if you need to display them on one or more pages of the macro's code.

6. Since a macro being edited always displays its content -- initially, at least -- in Draft mode (see View > Draft), you can use regular WordPerfect Comments in them (Insert > Comment > Create). This is a handy way to disable and store blocks of code (cut and paste from the code to and from the WP Comment) during testing.

7. Put your comment inside a text box (see Insert > Text box), which can be "anchored" to the page or to a specific paragraph (e.g., a macro command). Note that text boxes are sometimes prone to shift and/or not display all material, depending on adjacent materials or formatting, so it might be better to avoid this method with macros intended for wide distribution to users that might be unfamiliar with WordPerfect's advanced features.

Example:

This is a comment.