home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / C128CPM / PIPMAG6.ARK / MACROS.WS < prev    next >
Encoding:
Text File  |  1990-07-29  |  6.0 KB  |  110 lines

  1.                          ASCII to Wordstar - The Macro
  2.  
  3.                                        by
  4.  
  5.                              Brad Harris (BHARRIS)
  6.  
  7.  
  8.         In ASCII-TO.WS (PIPMAG5) I discussed using Wordstar's Search and 
  9.      Replace function to convert straight ASCII text to Wordstar format.  
  10.      This time around, I'd like to use that procedure as an example in a 
  11.      discussion of Shorthand keys, otherwise known as Macros.
  12.  
  13.         The Shorthand function may well be one of Wordstar4's most 
  14.      versatile features.  It allows you to do with two keystrokes what 
  15.      might otherwise take you several, or even many.  Most people, if they 
  16.      use it at all, only use it to preform simple operations like adding 
  17.      salutations or closings to letters.  But you can use it to build 
  18.      extremely complex operations, including anything that can be done with 
  19.      the Control-key combinations.
  20.  
  21.         Here are some things to remember.  When entering Control-keys in a 
  22.      macro, they have to be preceded by ^P.  So to enter a [CONTROL-Q], we 
  23.      have to hold down the [CTRL] key and hit P, then while still holding 
  24.      it, hit Q.  In the examples that follow, all the ^P's will be shown.  
  25.      As you enter them, however, they will not be visible.  ^QA would be 
  26.      entered as ^P^QA, but would appear as ^QA.  To enter a carriage return 
  27.      that ends a search or replace string, use ^P[RETURN] (a [CONTROL-P] 
  28.      followed by hitting the Return key).  To enter one that is part of a 
  29.      string, use ^P^N.  If you've used WSCHANGE to set Wordstar to use as 
  30.      little memory as possible, you might not have enough space allocated 
  31.      for the Shorthand definitions to hold the macro we are going to 
  32.      create.  If this is the case, you will either have to go back and set 
  33.      aside more room, or delete any macros that are already defined.  The 
  34.      maximum number of characters in a macro is 36.
  35.  
  36.         Let's start with the first part of the conversion process.  What we 
  37.      want to do is find all the occurrences of pairs of hard carriage 
  38.      returns, and replace them with a place-holding character.  We do this 
  39.      by hitting ^QA (holding down the control key and hitting Q, then 
  40.      releasing both keys and hitting A) to call up the Search and Replace 
  41.      function.  We then hit ^N two times followed by the Return key to tell 
  42.      Wordstar to look for the hard carriage return pairs.  Next we enter 
  43.      our place-holder and hit Return again, then hit Return a third time to 
  44.      let Wordstar know to use our default options (which we've previously 
  45.      set as <G>lobal, ig<N>ore case, <A>lign using WSCHANGE, haven't we).  
  46.      These are the same keystrokes we'll enter to begin our Shorthand.
  47.  
  48.         So we begin.  Open a document.  Hit ESCAPE (which will be 
  49.      abbreviated as [ESC] from here on) to call up the Shorthand menu.  Hit 
  50.      ? to get the editing screen.  Hit the key that you want to use to 
  51.      invoke the macro.  Finally, enter a description of the macro and hit 
  52.      [RETURN].  Don't hit the Return key again until I tell you to.  Now 
  53.      we're ready to begin entering the first part of our conversion 
  54.      procedure.  Enter the following:
  55.  
  56.                            ^P^QA^P^N^P^N^P^M`^P^M^P^M
  57.  
  58.         Note that my place-holding character is the back accent (`).  I use 
  59.      it only because I've never seen one in any text that I've ever edited, 
  60.      and it's the top left character on my keyboard, right below the [ESC] 
  61.      key, which makes it real easy to hit.
  62.  
  63.         The next part of the conversion routine simply finds all single 
  64.      occurrences of hard carriage returns and deletes them.  All global 
  65.      Search and Replace operations require that you hit [ESC] when they 
  66.      end, so that's what we need to start the next part of our macro with.  
  67.  
  68.         The [ESC] is entered like a control key -- it is preceded by a ^P, 
  69.      and shows up as ^[.  To clear out the place-holder, which is left 
  70.      over from the first Search and Replace, we'll need to enter a space.  
  71.      Moving right along then, we would continue with:
  72.  
  73.                          ^P[ESC]^P^QA^P^N^P^M ^P^M^P^M
  74.  
  75.         The last part of the conversion is to find the place-holder, and 
  76.      replace it with pairs of hard carriage returns.  Once again, we have 
  77.      to lead off with an [ESC]:
  78.  
  79.                        ^P[ESC]^P^QA`^P^M^P^N^P^N^P^M^P^M
  80.  
  81.         That's as far as I went in the last article, but since we're 
  82.      automating the process, let's add a few bells and whistles.  Not only 
  83.      do we have to hit [ESC] at the conclusion of a Search and Replace, it 
  84.      also leaves us at the end of the document, as does a global reformat 
  85.      (^QU).  Since we'd like the text to be formatted, and we want to be 
  86.      left at the top, we can add the following:
  87.  
  88.                              ^P[ESC]^P^QR^P^QU^P^QR
  89.  
  90.         What you now have should look like this:
  91.  
  92.             ^QA^N^N^M`^M^M^[^QA^N^M ^M^M^[^QA`^M^N^N^M^M^[^QR^QU^QR
  93.  
  94.         If that's what you have, hit [RETURN].  You'll be returned to the 
  95.      top Shorthand editing screen.  Hit ^U to exit Shorthand, and Y to save 
  96.      your macro.  Then go ahead and try it out.  To invoke your new macro, 
  97.      just hit [ESC] followed by the key you entered earlier.  And make sure 
  98.      you read what I had to say about working on the only copy of a file in 
  99.      the article ASCII-TO.WS in PIPMAG5.
  100.  
  101.         Note that this macro is set up to work with text that has one blank 
  102.      line between paragraphs.  If yours has more, add ^Ns in the first part 
  103.      of the definition as needed.  If there aren't any blank lines, replace 
  104.      the ^Ns with the same number of spaces as the first line of each 
  105.      paragraph is indented by.
  106.  
  107.         Now you've experienced the real power of Wordstar Shorthand macros.  
  108.      Write your own, and pretty soon you won't have to type at all.  And if 
  109.      you come up with a good one, be sure to tell us about it.
  110.