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.


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.


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.

WordPerfect for DOS 5.1 (or 5.1+):

{STATUS PROMPT}Press ENTER to find next XX marker - F1 quits~

WordPerfect for DOS 6.0:

StatusPrompt("Press ENTER to find next XX marker -- Esc quits")

WordPerfect for Windows 6.1:

SearchCaseSensitive (No!)
MacroStatusPrompt(On!;"Press ENTER to find next XX marker -- Esc quits")

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.


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.

Copyright (C) 1996 by microCounsel, (415) 921-6850. All rights reserved.

[ Home Page | Articles List | Top of this article ]