WP51 Macros   
  Voice Pro Home | WP51 home | macros | how-to | quick tips | links | feedback          Just for MTs  WP51 Forum

   

The Medical Banner Exchange
This site is a member of the Medical Banner Exchange

    Quick Envelopes

Managing Dates

The Mobile MT

Quick Envelopes

Keyboard Templates

Remap keys

WP51 & Win95

Create Envelopes or Labels with a Single Keystroke!

It's easy enough to write a macro that copies a single block of text (in this case, an address) to an envelope page or into the second WP51 document. But what do you do if you've typed 50 letters in the same document? Do you use your envelope macro 50 times? That gets a little old!

My solution relies on two features of WP51--the built-in index markers and the ability to write a macro that repeats Task A until Condition B exists. The following instructions will explain: the quick envelope concept, index and other hidden WP51 markers, anchoring your envelope macro, snags to plan for, and modifications you might make. Based on this explanation, you can write your own envelope macros. I'll provide snippets of the macro codes for your convenience (and full code at the bottom of the page). If you prefer, we have a starter set of Envelope Creator macros available.

Concept

The quick envelope concept is easy to understand. First, almost all addresses in letters "look" about the same in terms of their structure. An address has about three lines or so of text, each line has a hard-return ([HRt]) at the end, and the last line has a double [HRt]. Addresses may occur at the beginning of a letter, the inside address, or they may occur at the end of a letter, the cc.

It's easy to write a macro that starts a block at the beginning of the address, searches forward to extend the block to the next occurrence of a double [HRt], and then copies that block elsewhere. That's how most envelope or label macros I've seen work. What most of these macros don't or can't do is find the beginning of an address without your assistance.

To do this, you might have your macro search for items that you know will occur above or below an address, for instance, "dear," the date, a certain number of lines from the top of a letter, etc. The problem with this approach is that it works for some, but not all letters, and becomes very unreliable when you have multiple letters inside a document.

The best approach I've found is to use a marker that is hidden in your document and will definitely not be found anywhere other than at the beginning of an address! Because few of us would ever have need to use an index marker (more about these later) in a letter, I've used them to mark the beginning of addresses.

Here are the steps that the envelope creator macros take:

markadd.wpm - one step only - use this macro to place an index marker at the beginning of an address or address placeholder in a letter or a letter template.

makeenv.wpm -
  • Marks the spot where the envelopes or labels will be placed
  • corrects possible snags (more about these later)
  • finds the first index marker and begins a block
  • searches for the end of the address, extends the block, and copies the address
  • pastes the address in the proper place
  • goes back to the last address it found and searches for another
  • when it finds no more index markers, cleans up after itself
  • calls the envelope format macro
envdef.wpm -
  • formats the envelopes or labels (page size and margin definitions)
  • reports the number of envelopes that were created
Now for the details, let's look at some example macro codes.

markadd.wpm -

{DISPLAY ON}{Mark Text}i{Enter}{Enter}

This macro code places an index marker to the left of some text that is entered in your document. If you are setting up a template that will be used to create thousands of letters, then you might mark the address placeholder with an asterisk, for example. Place your cursor to the left of the asterisk and invoke the markadd.wpm. I have this macro hot-keyed as alta.wpm.

makeenv.wpm -

Keep in mind that these are code snippets, and they do not appear below in the exact order we use them in our macros! Instead, we're breaking them out by function for explanation purposes. At the end of this page, you'll find the complete macro code listings in order.

{Home}{Home}{Home}{Down}
<<>>
{Home}{Home}{Home}{Up}

This is where our macro marks the spot where the addresses will be placed. In this case, we're placing all envelopes together at the bottom of the document. The <<>> is our placeholder.

{ASSIGN}counter~1~

Here, we're initializing the envelopes-created counter to a value of one. Our assumption is that at least one envelope will exist each time we use this macro. We need to reassign the value, because we may use the variable counter for other purposes in any one WP51 session.

{LABEL}top~
{Search}{Mark Text}i{Search}
{Block}{Search}{Enter}{Enter}{Search}{Move}bc{Home}{Home}{Home}{Down}
{HPg}{Enter}
{Home}{Home}{Goto}{Goto}
{ON NOT FOUND}{GO}next~~
{ASSIGN}counter~{VARIABLE}counter~+1~
{GO}top~

This little bit of code is a real workhorse! First, it finds an address by looking for the index marker. Next, it blocks and copies the address and pastes it in the appropriate spot (in this instance, the end of the document). Then, it looks for the next address. If it finds one, it increments our counter by one, and, if not, it goes on to the next routine.

{LABEL}next~
{Home}{Home}{Home}{Up}
{Search}<<>>{Search}
{Backspace}{Backspace}{Backspace}{Backspace}{Down}
{Home}{Left}

{CHAIN}envdef.wpm~

When we run out of addresses, the macro repositions itself, deletes the placeholder, and calls the envelope format macro.

envdef.wpm

{Format}psnenvelope·-·wide{Enter}
sm2{Enter}0{Enter}{Enter}
lm4.5{Enter}0{Enter}{Enter}{Enter}

This is the code that places an envelope definition in our document.

{DISPLAY ON}
{PROMPT}Envelopes·created:··({VARIABLE}counter~)··Press·enter·to·continue.~

This is the code that tells us how many envelopes were created. This can be cut, if you don't want or need to know!

Markers

WP51 provides various ways of "invisibly" marking text for later creation of indices, tables of contents, cross references, and the like. You can place some markers by blocking text and pressing [ALT][F5] and some just by accessing the [ALT][F5] menu without block turned on.

Basically, WP51 markers fall into two categories: those that mark and name a position and those that mark sections of text. Index markers are in the first category; they mark the position of a word and give the position a name (the word being marked). The obvious intended use of these is to later create an index that lists every word you marked and gives its page number (or, position). These markers consist of a single hidden code placed in your document.

Cross reference and table of contents markers, on the other hand, mark sections of text. Like some format and style codes, they have both a beginning and an ending code. Their purpose is to place the marked text in another location in a list or summary format.

You can exploit the power of these markers to perform an amazing number of tasks! For instance, using markers and macros you can, with a single keystroke, create patient lists that include name, demographics, drugs prescribed, drugs discontinued, date of visit, and more.

In the envelope creator macros, we use the index marker because it marks position only. It does not require that you type between two previously placed markers or that you block and mark a section of text.

Anchors

We use an anchor in these macros to bring us safely back to a specific spot in the document--the spot where we'll be placing our envelope or label format. Our anchor is the <<>> mark.

At first glance, it may seem that makeenv.wpm macro uses <<>> to determine where to place the copied addresses, but on closer examination you'll see that our example macro is actually just placing the addresses at the absolute bottom of the document.

We've chosen <<>> simply because it is unlikely to ever occur in our letters. If for some reason your letters include that combination of characters, you can choose another anchor. Just make sure that it's unlikely to occur naturally. Other choices might be: *&(), @@@@, or whatever. It helps, if you use anchors often in your macros, to choose a character string that remains consistent from macro to macro.

Another anchor we use in these macros is the {Goto}{Goto}. This little bit of code takes our cursor back to the spot we were before our last major move. This is a neat way of maneuvering around a document, and it prevents us from having to place temporary anchors every time we copy and paste.

Snags

{Block}{Search}{Enter}{Enter}{Search}{Move}bc{Home}{Home}{Home}{Down}

This code snippet from makeenv.wpm brings up a possible snag in your macro. The code {Search}{Enter}{Enter}{Search} is looking for a double [HRt] at the end of your address. If the double [HRt] does not exist at the end of your address, the block will be extended to the next occurrence of a double [HRt]. That means that instead of an address, you may end up with an address and half a letter in your envelopes!

You may be thinking that this isn't a problem, because you always put a double [HRt] at the end of envelopes. Well, maybe--maybe not! Here is an example of a real snag: [HRt] [HRt]. That's two hard returns with a space in between. With [Reveal Codes] off, this will look just like a double [HRt] on your screen, but the macro will pass it by. You'll want to be sure that you don't have any spaces or other nonprinting characters between those hard returns.

Another spot where you may not have a double [HRt] after an address is at the bottom of a letter when the address is a cc. For this reason, you'll see that our example macros include this next little bit of code:

{Home}{Home}{Home}{Up}{Replace}n{HPg}{Search}{Enter}{Enter}{HPg}{Search}

This replaces every hard page break with two hard returns followed by a hard page break. Later, the macros clean this up and restore the page breaks to their original condition, but the temporary fix makes certain that we get those cc addresses included in our envelopes or labels.

The next snag we need to consider is that some dictators require that the inside address spell out the full state name and that the envelope carry only the state abbreviation. We get around this by replacing state names with abbreviations in the envelopes only:

{Replace}nIllinois{Search}IL{Search}{Goto}{Goto}

Sometimes this can create a snag itself when a street name is also a state name: 341 Illinois Avenue would become 341 IL

You can expand this search and replace routine to include every state or province to which you regularly address envelopes. Also, it can be used to abbreviate avenue, boulevard, and the like.

The last snag we need to discuss is the format of cc addresses. Often, these are tabbed over from the left margin of the document. This next bit of code deletes those tabs or indents, so that cc addresses line up right with your envelope or label margins.

{Replace}n{Tab}{Search}{Search}
{Goto}{Goto}
{Replace}n{Indent}{Search}{Search}
{Goto}{Goto}

If your practice is to space over your cc addresses, you may want to consider changing that practice! Or you can search for the exact number of spaces you use and delete them:

{Replace}n {Search}{Search}
{Goto}{Goto}

Personally, I don't find this to be a satisfactory solution because the first line of a cc address includes the cc designation and has a different number of spaces in it. Much simpler to just use tabs.

Modifications

You can download our starter macros or you can write your own. The full code for our macros appears below. You can modify this code in a number of ways.

For instance, these macros place the envelopes at the bottom of the document. You can just as easily place them in a separate document. If you do, you might include a snippet of code that checks to make sure that second document screen is empty! You can format for labels instead of envelopes. You can convert the case of your labels or envelopes to all uppercase.

Rename the macros! We use alta for markadd.wpm, alts for makeenv.wpm, and we don't care about envdef as it's called from within the makeenv.wpm. Renaming the macros gets you down to a single keystroke for making envelopes, if you've placed the index marker in your templates.

You might use this same basic concept to copy something besides addresses. Use this concept as a jumping off point to accomplish any repetitive listing task. If you come up with a particularly elegant solution to an annoying problem, why not share it with us? We'll be happy to place your macro(s) and explanation in our collection with a link to your web site and/or email address.

The Code

Finally, here's the code associated with each macro. We've deleted the comments included in the starter macros.

markadd.wpm

{DISPLAY ON}{Mark Text}i{Enter}{Enter}

makeenv.wpm

{DISPLAY OFF}
{Home}{Home}{Home}{Up}
{Replace}n{HPg}{Search}{Enter}{Enter}{HPg}{Search}
{Home}{Home}{Home}{Down}
<<>>
{Home}{Home}{Home}{Up}
{ASSIGN}counter~1~
{LABEL}top~
{Search}{Mark Text}i{Search}
{Block}{Search}{Enter}{Enter}{Search}{Move}bc{Home}{Home}{Home}{Down}{HPg}{Enter}
{Home}{Home}{Goto}{Goto}
{ON NOT FOUND}{GO}next~~
{ASSIGN}counter~{VARIABLE}counter~+1~
{GO}top~
{LABEL}next~
{Home}{Home}{Home}{Up}
{Search}<<>>{Search}
{Backspace}{Backspace}{Backspace}{Backspace}{Down}
{Home}{Left}
{Replace}n{Enter}{Enter}{Search}{Search}
{Goto}{Goto}
{Replace}nIllinois{Search}IL{Search}
{Goto}{Goto}
{Replace}n{Tab}{Search}{Search}
{Goto}{Goto}
{Replace}n{Indent}{Search}{Search}
{Goto}{Goto}
{CHAIN}envdef.wpm~

envdef.wpm

{DISPLAY OFF}
{Format}psn
envelope - wide
{Enter}sm2{Enter}0{Enter}{Enter}
lm4.5{Enter}0{Enter}{Enter}{Enter}
{Home}{Home}{Home}{Up}
{Replace}n{Enter}{Enter}{HPg}{Search}{HPg}{Search}
{Home}{Home}{Home}{Down}
{DISPLAY ON}
{PROMPT}Envelopes created: ({VARIABLE}counter~) Press enter to continue.~

download the starter macros


Pssst! Can you spare a moment?

We'd like to know if this page was helpful to you today
and how it might have been more helpful.

Please answer the four questions below and click submit.
You'll be returned to this page pronto!

How helpful was the information presented about the Quick Envelope concept?
(1=Extremely and 5=Not at all)

1
2
3
4
5

How would you rank the skill level required to use information found on this page?
(1=Complete beginner could use this information
and 5=Requires an expert to understand)

1
2
3
4
5

What brought you to this page?
I regularly visit this site.
I came to this page to find information on a specific topic.
I was just browsing.
I was looking for information on another word processor
I followed a link here, but this site isn't relevant to my search.

Is there anything we might do to make this page more helpful?

Thanks for your comments and opinions.
Click Submit and you'll be returned to this page.



  Voice Pro Home | WP51 Center | macros | how-to | quick tips | links | feedback           FAQs
Voice Pro, Inc.   

Copyright © 2000-2001 Voice Pro, Inc.
Portions Copyright © 1995-2001 Mitzi L. D. Ponce

WordPerfect is a registered trademark of Corel Corporation.
Windows is a registered trademarks of Microsoft Corp.
This site is not affiliated with Corel Corporation or Microsoft Corporation.


web site design by
Nightshade Systems