Macros: Old v. New

by Kendall Callas

I'm a regular attendee and frequent presenter at the Bar Association's WordPerfect user
group
meetings. We brown bag it at lunch meetings for wide-ranging discussions about using
WordPerfect (DOS and Windows versions).

A topic of great interest to the group has been the difference between macros in old
versus new
WordPerfect. There has been a major change in the concept.

Macros no longer record keystrokes, but the results of keystrokes. In WordPerfect for
DOS (up
through version 5.1+), macros were primarily keystroke recordings that could be augmented
with
programming statements to add menus, variables, logic, loops, and more sophisticated
functions.

NEW PARADIGM

Now, in WordPerfect for Windows (and WordPerfect for DOS starting with version
6.0), macros
do not record the keystrokes to perform a task, but the results of the task. The resulting
code is
very powerful and readable. Most importantly, it is more portable; from one DOS version to
another (say 5.1 to 6.1), or between platforms (DOS to Windows or whatever the future may
bring). As shown in the examples below, a WordPerfect for DOS 6.0 macro is almost
identical to
a WordPerfect for Windows 6.1 macro.

Instead of keystroke tokens, the new macro programming language uses simple,
powerful
statements to represent actions. Whether you use the mouse, the menu bar, or keystroke
shortcuts to retrieve a file, for example, the statement recorded is FileOpen(filename).
StyleOn(stylename) places a style. Cursor commands look like PosLineUp, PosCharNext,
and
PosLineEnd. Erasing is done with commands like DeleteWord or DeleteCharPrevious.
Blocking
text uses commands like SelectOn followed by cursor movements, or SelectWord and
SelectLineEnd. Other commands include PrintFullDoc, RevealCodes(On!), and
ToUpper(expression).

Menus are called "dialog boxes" and are brought up with statements like FileOpenDlg,
StylesListDlg, FormatMarginsDlg, etc. You can even create your own dialog boxes.

A host of improved system variables provide details about the document, cursor
position, or
current settings, such as ?Name, ?DocBlank, ?RevealCodesActive, ?TypeoverActive,
?UserName,
?LineSpacing, ?CurrentWord, ?DateWeekDay, ?SelectedText, ?LeftChar, ?RightCode, etc.

For the occasional task that the new approach makes difficult, the
SendKeys(keystrokes)
command allows the old-style macro approach of using keystrokes.

MACRO CODE COMPARISON:
FINDXX

Here are three examples of FINDXX comparing the equivalent macro code in three
current
versions of WordPerfect -- DOS 5.1, DOS 6.0, and Windows 6.1. Presented below in each
language is a simplified version of a "fill-in-the-blanks" macro that searches for a marker
("XX")
in the document, deletes it, pauses for user input, then loops.

You can see that the macros for WordPerfect for DOS 6.0 and Windows 6.1 are nearly
identical.

Creating and editing macros is also now much easier. You can edit macros just like
documents,
so you're able to search, print, and cut & paste. When you save a macro, it is
automatically
compiled and the code is screened for typing errors, syntax mistakes, and missing labels.

NEW TOOLS FOR AUTOMATING
TASKS

Macros have also been complemented with other tools that are better solutions for
some tasks.
Templates offer the "Address Book" and "Personal Info" to add a nice rolodex feature for
letters
and faxes, abbreviations speedup transcription, the QuickList remembers directories you
often
visit, and history lists remember searches, files, and macros you've used.