Introduction

Why am I reading this book?

If you've picked up this book, you probably have some interest in learning how to write your own macros in WordPerfect (or to repair someone else's broken macros). You probably want to increase your productivity, or maybe you want to learn a new job skill. You'd probably rather be doing something else with your time than creating the same old documents from scratch over and over again, especially when that $3,000 bookend that's sitting on your desk should be able to automate such chores for you.

You've probably realized that WordPerfect is a very powerful tool that can do most any word processing chore you might need -- and more -- if you know how to tell it what to do. This is known as programming to some people.

WordPerfect Advanced Macro Programming: A Learning Guide has two purposes: first to dispel the myth that you need to be a gearhead to do programming; and second, to help you understand Corel PerfectScript, also known to normal people as the macro programming language in WordPerfect for Windows.

What will I find in this book?

This book is a learning guide. You won't find a collection of ready-made macros here; rather, you'll find lessons, examples, exercises, and quizzes to help you understand the macro commands; learn common programming techniques; and help you think logically when writing your own macro applications. We'll concentrate on WordPerfect macros, although the same programming commands can be used in Presentations, and to some extent in Quattro Pro, and other Corel applications that support PerfectScript.

What do I need before I start?

Before you begin, you'll need to have WordPerfect installed on your computer. I recommend that you have a very fast 486, or better yet, a Pentium or 586 (or better) CPU with a minimum of 16 MB of RAM. I wrote this book and tested the macro examples on a 586/100 laptop with 16 MB of RAM at 640 by 480 screen resolution, and a Pentium/133 desktop machine with 32 MB of RAM at 1280 by 1024 screen resolution.

You should also have a strong working knowledge of WordPerfect: how to open and save documents; change margins, paper size, and font types; how to print, etc. A little experience with another programming language such as C or Pascal is also very helpful, but not required. You should be familiar with Windows 95.

Where do I start and how long will it take?

You'll get the best results with this book if you start at Lesson 1 and work through the lessons in consecutive order. Later, when you're comfortable with the macro language and familiar with the concepts presented, you can go back and read an individual lesson as a reference or refresher course.

The time it takes you to complete a lesson will depend on how quickly you pick up the material and how complex the lesson is. You should move quickly through the first few lessons, but as you move on to more complex topics, you'll need more time to digest the concepts. The lesson on dialog boxes may take a few days to get all the way through because you'll be building a dialog box as you go.

The first lesson starts by explaining the macro development environment, and how to create and edit macros. You'll then learn about the differences between programming and product commands. From there, the lessons will teach you how each macro programming command works.

Each lesson includes examples of common problems that you might encounter in the real world, and techniques you might use to solve them. The hands-on exercises in each lesson illustrate concepts relating to the commands covered in the lesson, and also give you practice at creating your own macros. I suggest that you type the exercises in and give them a try as you go through each lesson. You'll probably even use some of the exercise or example macro code in your own macros later on.

As you gain mastery over each command, you'll be able to implement the commands and techniques in your own complex macros. The Application exercises at the end of many of the lessons will help you get the practice you need in using new commands.

If you run into a concept you just don't get, either I did a crummy job explaining it, and you should write me a letter (I'll blame it on my cat walking across the keyboard at 3am!); or you may not have caught on to a prerequisite concept presented earlier in the book. There's a lot to learn, and you certainly are not expected to remember it all after your first exposure to a new concept. You may want to go back to a previous lesson and review, or maybe take a break from macro programming for a few hours.

If you begin to dream about macros, you're really learning the material! Our brains process new information while we sleep, storing it away in places where it can be recalled later. Don't worry; it will stop someday and your life will be back to normal.

What's in the Appendices?

The appendices include charts of the ASCII and NTOC Character values (Appendix A, NTOC/ASCII Values), Reserved Words (Appendix B, Reserved Words), System Variables (Appendix C, System Variables in WordPerfect), ?RightCode values (Appendices D and E, ?RightCode Values), Named Regions (Appendix I, Named Regions for WordPerfect), and the token names that can be used in PauseSet and PauseCommand commands (Appendix J, PauseSet and PauseCommand Tokens). After you've finished the lessons, you'll find that the book is still valuable for this important reference material.

You'll also find a list of the product commands for WordPerfect (Appendix F, Product Commands for WordPerfect ), a Macro Conversion Guide (Appendix G, Macro Conversion Guide), and the answers to the lesson quizzes (Appendix H, Answers to Lesson Quizzes).

What's in the Applications file?

You'll notice that most Application exercises at the end of the lessons include a macro filename. These files can be downloaded from the WPMacros web site at http://www.wpmacros.com/downloads.htm

You can open the corresponding macro for a look at how to solve the problem. These macros fulfill the requirements of the exercise in a simple, straightforward way, and are by no means the only way to solve the problem. You'll probably develop better, more useful solutions. But these little macros will at least get you started if you get stumped.

You can use any of the macro code presented in the book or applications files in your own macros, and you can modify the code as needed to meet your purposes.

What's new in WordPerfect 7/8/9 macros?

If you're a seasoned WordPerfect 6.x macro writer, you may want to forgo the beginning lessons and delve right into the new stuff. You should make sure you look over the lessons on Expressions & Mathematical Operators (Lesson 6), Parsing Strings (Lesson 7), The Date and Time Commands (Lesson 14), Custom Dialog Boxes (Lesson 17), Dynamic Link Libraries (Lesson 20), Dialog Callbacks (Lesson 19), and Using Registry , INI and BIF Files (Lesson 24). Most of the differences lie in these particular commands. There are also a few new features available when Using Informational Prompts (Lesson 3).

You'll also want to take a look at the Upgrade Help section in the Macros Online Help. This lists product commands that are now obsolete, new commands, and other information. It is not nearly as extensive as it should be, but this is not surprising considering all the layoffs at WordPerfect/Novell/Corel in the last few years.

When I'm done with this book, what can I expect?

After you've completed the lessons in this book, you should have gained the foundation of knowledge you need to use each macro command efficiently in your own macros. You should have a good understanding of the PerfectScript commands and what they can be used for, and you should be able to look at macros written by others and determine what they are doing. You might even find you know better ways to accomplish the same tasks in someone else's macro!

This book cannot possibly contain the exact steps and subroutines you might need in any given macro application. But by using this book, you'll have more fun while you're programming, and avoid some of the inherent frustrations that macro writers experience. The macros you can create with PerfectScript are limited only by your imagination.