home *** CD-ROM | disk | FTP | other *** search
- ASCII to Wordstar - The Macro
-
- by
-
- Brad Harris (BHARRIS)
-
-
- In ASCII-TO.WS (PIPMAG5) I discussed using Wordstar's Search and
- Replace function to convert straight ASCII text to Wordstar format.
- This time around, I'd like to use that procedure as an example in a
- discussion of Shorthand keys, otherwise known as Macros.
-
- The Shorthand function may well be one of Wordstar4's most
- versatile features. It allows you to do with two keystrokes what
- might otherwise take you several, or even many. Most people, if they
- use it at all, only use it to preform simple operations like adding
- salutations or closings to letters. But you can use it to build
- extremely complex operations, including anything that can be done with
- the Control-key combinations.
-
- Here are some things to remember. When entering Control-keys in a
- macro, they have to be preceded by ^P. So to enter a [CONTROL-Q], we
- have to hold down the [CTRL] key and hit P, then while still holding
- it, hit Q. In the examples that follow, all the ^P's will be shown.
- As you enter them, however, they will not be visible. ^QA would be
- entered as ^P^QA, but would appear as ^QA. To enter a carriage return
- that ends a search or replace string, use ^P[RETURN] (a [CONTROL-P]
- followed by hitting the Return key). To enter one that is part of a
- string, use ^P^N. If you've used WSCHANGE to set Wordstar to use as
- little memory as possible, you might not have enough space allocated
- for the Shorthand definitions to hold the macro we are going to
- create. If this is the case, you will either have to go back and set
- aside more room, or delete any macros that are already defined. The
- maximum number of characters in a macro is 36.
-
- Let's start with the first part of the conversion process. What we
- want to do is find all the occurrences of pairs of hard carriage
- returns, and replace them with a place-holding character. We do this
- by hitting ^QA (holding down the control key and hitting Q, then
- releasing both keys and hitting A) to call up the Search and Replace
- function. We then hit ^N two times followed by the Return key to tell
- Wordstar to look for the hard carriage return pairs. Next we enter
- our place-holder and hit Return again, then hit Return a third time to
- let Wordstar know to use our default options (which we've previously
- set as <G>lobal, ig<N>ore case, <A>lign using WSCHANGE, haven't we).
- These are the same keystrokes we'll enter to begin our Shorthand.
-
- So we begin. Open a document. Hit ESCAPE (which will be
- abbreviated as [ESC] from here on) to call up the Shorthand menu. Hit
- ? to get the editing screen. Hit the key that you want to use to
- invoke the macro. Finally, enter a description of the macro and hit
- [RETURN]. Don't hit the Return key again until I tell you to. Now
- we're ready to begin entering the first part of our conversion
- procedure. Enter the following:
-
- ^P^QA^P^N^P^N^P^M`^P^M^P^M
-
- Note that my place-holding character is the back accent (`). I use
- it only because I've never seen one in any text that I've ever edited,
- and it's the top left character on my keyboard, right below the [ESC]
- key, which makes it real easy to hit.
-
- The next part of the conversion routine simply finds all single
- occurrences of hard carriage returns and deletes them. All global
- Search and Replace operations require that you hit [ESC] when they
- end, so that's what we need to start the next part of our macro with.
-
- The [ESC] is entered like a control key -- it is preceded by a ^P,
- and shows up as ^[. To clear out the place-holder, which is left
- over from the first Search and Replace, we'll need to enter a space.
- Moving right along then, we would continue with:
-
- ^P[ESC]^P^QA^P^N^P^M ^P^M^P^M
-
- The last part of the conversion is to find the place-holder, and
- replace it with pairs of hard carriage returns. Once again, we have
- to lead off with an [ESC]:
-
- ^P[ESC]^P^QA`^P^M^P^N^P^N^P^M^P^M
-
- That's as far as I went in the last article, but since we're
- automating the process, let's add a few bells and whistles. Not only
- do we have to hit [ESC] at the conclusion of a Search and Replace, it
- also leaves us at the end of the document, as does a global reformat
- (^QU). Since we'd like the text to be formatted, and we want to be
- left at the top, we can add the following:
-
- ^P[ESC]^P^QR^P^QU^P^QR
-
- What you now have should look like this:
-
- ^QA^N^N^M`^M^M^[^QA^N^M ^M^M^[^QA`^M^N^N^M^M^[^QR^QU^QR
-
- If that's what you have, hit [RETURN]. You'll be returned to the
- top Shorthand editing screen. Hit ^U to exit Shorthand, and Y to save
- your macro. Then go ahead and try it out. To invoke your new macro,
- just hit [ESC] followed by the key you entered earlier. And make sure
- you read what I had to say about working on the only copy of a file in
- the article ASCII-TO.WS in PIPMAG5.
-
- Note that this macro is set up to work with text that has one blank
- line between paragraphs. If yours has more, add ^Ns in the first part
- of the definition as needed. If there aren't any blank lines, replace
- the ^Ns with the same number of spaces as the first line of each
- paragraph is indented by.
-
- Now you've experienced the real power of Wordstar Shorthand macros.
- Write your own, and pretty soon you won't have to type at all. And if
- you come up with a good one, be sure to tell us about it.
-