home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / ASC2WS.ZIP / ASC2WS.TXT
Encoding:
Text File  |  1989-08-02  |  12.0 KB  |  278 lines

  1.  
  2.      ASC2WS.TXT
  3.      Revised 08-02-1989
  4.  
  5.      ASCII TO WORDSTAR CONVERSIONS -
  6.      REMOVING CARRIAGE RETURN/LINE FEED PAIRS (CR/LF) FROM THE
  7.      ENDS OF LINES, FROM INSIDE WORDSTAR ITSELF
  8.  
  9.      Designed for WordStar 5 but should work with all versions.
  10.      ---------------------------------------------------------
  11.      by Barry F. MacDonnell, July 1989.
  12.      CompuServe ID: 71500,3413
  13.      GEnie: B.MACDONNEL3
  14.  
  15.      Public domain: Permission to distribute
  16.      is granted without restriction.
  17.      ---------------------------------------------------------
  18.  
  19.      There may come a time when you want to take someone's text
  20.      file from another word processor, or from a BBS download or
  21.      e-mail letter and use WordStar to "massage" it into the
  22.      shape you want.  Or, perhaps you use a simple text editor
  23.      for the small stuff, but now need to import the editor's
  24.      files into WordStar so that you can enhance them.  You may
  25.      want to use new margins or highlight text, for example.
  26.  
  27.      Usually you get imported files in ASCII format: no embedded
  28.      codes, just plain text with each line ending in a hard
  29.      carriage return.  This format that can be read by any
  30.      word processor or text editor.
  31.  
  32.      But ... eliminating all unwanted hard carriage returns
  33.      and line feeds (abbreviated here as CR/LF, but which show
  34.      up on the right side of your screen as a "<" symbol) is
  35.      another matter. You have to get rid of these pesky
  36.      critters if you want to reformat paragraphs in the file
  37.      using WordStar's ^B (control-B).
  38.  
  39.      The usual method suggested in the WordStar 5.0 manual
  40.      works fine by pressing ^6 (Control-upper row 6) on each
  41.      line ending with a CR/LF.  Normally you don't want to do
  42.      this on the last line in each paragraph or the lines
  43.      between paragraphs. You then reformat the document with
  44.      ^QU or repeatedly pressing ^B.
  45.  
  46.      For any file longer than a few paragraphs, the use of ^6 can
  47.      be a real chore: hard on the hands and eyes.  Imagine
  48.      pressing ^6 several hundred times.
  49.      
  50.      I automated this process with four (4) Find-and-Replace
  51.      passes through the file.  You might find this process
  52.      helpful; it is easier than it looks!
  53.  
  54.  
  55.                          INSTRUCTIONS
  56.                          ------------
  57.  
  58.      *IMPORTANT*  If your ASCII file's text does NOT begin in
  59.      Column 1 on your screen (that is, it has an offset left
  60.      margin), and/or it is more than one page long and has "^L"
  61.      form feeds/page breaks in it, see the *NOTES* at the end of
  62.      this file before beginning.
  63.  
  64.      
  65.      First, open the ASCII file as a WordStar Document file.
  66.      Then:
  67.      
  68.      1.   Press ^QA, for WordStar's Find-and-Replace function.
  69.  
  70.           You need to Find all CR/LFs at the end of each
  71.           paragraph (not individual lines; that comes later), or
  72.           those at and below any one-line text headings.
  73.  
  74.           You do this by entering the CR/LF code, ^N (control-N,
  75.           which appears as the pair of control characters ^M^J in
  76.           the display box), as many times as needed to equal the
  77.           *maximum number* of blank lines that you can see
  78.           anywhere in the file between blocks of text -- plus
  79.           one.
  80.      
  81.           For example, say the greatest number of blank lines you
  82.           can see anywhere in your file is five. In the on
  83.           screen
  84.           "Find" box you would type
  85.  
  86.                      ^N^N^N^N^N^N <Return>
  87.  
  88.           (Five control-Ns plus one.  Don't forget to hold down
  89.           the control key while you press N six times.)
  90.  
  91.           What you'll see is
  92.  
  93.                      ^M^J^M^J^M^J^M^J^M^J^M^J
  94.  
  95.           You then Replace these six CR/LF (^M^J) pairs with six
  96.           "#" characters --
  97.  
  98.                      ###### <Return>
  99.  
  100.           -- one for each ^M^J pair. These serve as paragraph and
  101.           spacing markers. (You could use any character not used
  102.           elsewhere in your file, but "#" seems handy.  If you're
  103.           not sure what character to use, do a quick Find on that
  104.           character first.  If it's already used, try something
  105.           else, like the tilde ~.  You wouldn't use #, ~, ^, or *
  106.           to convert *this* file, for example.  The plus sign
  107.           or dollar sign would work, however.)
  108.  
  109.           For Options, press
  110.  
  111.                      AGN <Return> for Align, Replace throughout
  112.           file, and Don't ask.
  113.  
  114.           WordStar will then do a Find-and-Replace.  If it cannot
  115.           find the required number of CR/LFs it will tell you so;
  116.           this means there weren't any strings of six (or however
  117.           many) CR/LFs as you thought there were.
  118.  
  119.           In any case, press ESCape when it's finished its
  120.           complete pass through to the end of the file.
  121.  
  122.      2.   Repeat step #1, *deleting* one ^M^J pair and one "#"
  123.           symbol for each pass through the file.  Using the
  124.           Delete key while in the display box makes this easy,
  125.           but you'll press it twice for the ^M^J pair and once
  126.           for the "#" since ^M and ^J are really separate control
  127.           codes.
  128.  
  129.           Do this until only one ^M^J pair is left.  Enter a
  130.           space in the Replace box (just press the space bar
  131.           once) instead of a "#" symbol; this allows Replacing
  132.           single line CR/LFs with a space.  If you didn't
  133.           leave a space, text lines would close up and not
  134.           reformat properly later. If you left a "#" that's OK
  135.           -- just remember to use Find-and-Replace later (Find
  136.           #, Replace it with <space>).
  137.  
  138.      
  139.      3.   Now that the original ASCII file has no more CR/LFs in
  140.           it, and is all "bunched" together, reverse the above
  141.           process to reset paragraphs. That's what the "#"
  142.           symbols were used for.
  143.  
  144.           Press ^QA.  Enter the maximum number of "#" symbols to
  145.           Find (in our example, this would be six). Replace them
  146.           with the same number of ^M^J pairs needed to give hard
  147.           carriage returns and line feeds in the proper places.
  148.           Again, use AGN as your Options.
  149.  
  150.      
  151.      4.   Repeat step #3, deleting in a similar manner to step
  152.           #2, until only the last two "#" symbols are left to
  153.           Replace (which hold places for two CR/LFs -- the
  154.           typical number between paragraphs). Replace these with
  155.           ^M^Js and you now have a file in WordStar's document
  156.           format.
  157.  
  158.           (The last line in the file may need a CR/LF entered
  159.           manually, however.  Look over the newly converted
  160.           file and if everything is OK, save it to disk.)
  161.  
  162.  
  163.      By the way, I tried to turn these steps into a macro, only
  164.      to find that the ^Ms in the Find-and-Replace box would abort
  165.      the macro: ^M is like pressing the <Return> key in a running
  166.      macro.  In any event, once you try this method you'll see it
  167.      goes quite fast enough as it is.
  168.  
  169.      What happens if you start a Find-and-Replace with the
  170.      *minimum* number of blank lines and work up to the maximum
  171.      you think are in the file?  You'll get uniform paragraph
  172.      spacing -- the smallest you've set.  (Maybe only one line
  173.      between paragraphs.)
  174.  
  175.      Lastly, always make a backup of your ASCII file first, in
  176.      case you accidentally save and overwrite the original
  177.      file before checking everything out. You may want to
  178.      refer to the original later.  I cannot be responsible for
  179.      any loss or damage if you use the methods detailed in
  180.      this file. (That's a disclaimer, folks.)  Enjoy!
  181.  
  182.                            *NOTES*
  183.                            -------
  184.      *Remove* any form feed characters from the ASCII file (^L)
  185.      from inside WordStar before beginning.  These "page breaks"
  186.      were put in by the text editor or word processor that
  187.      created the ASCII file.
  188.  
  189.      Then:  If your ASCII file's left margin is not in column 1
  190.      -- that is, it's offset by some amount, typically five
  191.      columns (as in the file you are now reading), then you'll
  192.      need to clean it up first.  Here are two ways to do it:
  193.  
  194.  
  195.      1. Count the spaces from (and including) column 1 to the
  196.      left margin of the text.  Use WordStar's Find and Replace
  197.      function to get rid of these extra spaces.  If you
  198.      counted five spaces, for example, use this procedure:
  199.  
  200.         Find    ^N<space><space><space><space><space>  <Return>
  201.         Replace ^N                                     <Return>
  202.         Options AGN                                    <Return>
  203.  
  204.      After entering ^N (displayed as ^M^J) you press the
  205.      <spacebar> in the Find box five times, followed by <Return>.
  206.      This Finds only CR/LF-plus-5-space-strings.  Enter a ^N in
  207.      the Replace box: you are replacing the string with a single
  208.      CR/LF.
  209.  
  210.      Select the Options, press <Return> and the text should close
  211.      up to the left margin as you watch.
  212.  
  213.      After you've eliminated the offset left margin, you may want
  214.      to repeat this Find & Replace to remove any other spaces
  215.      (indents) that keep the text from aligning in column 1.
  216.      Just substitute the required number of spaces in the process
  217.      above.
  218.  
  219.      Finally, proceed with the Instructions to Find & Replace the
  220.      CR/LFs at the end of each line.
  221.  
  222.  
  223.      2. Use the technique described in WordStar News, Summer
  224.      1989, page 8, to create a macro to turn paragraph indents
  225.      (usually 5 spaces) into a tab.  Then use ^QA to Find the
  226.      tabs (^I) and replace them with (nothing).  The WS NEWS
  227.      article, in an example, defines Shorthand Macro #1 to be:
  228.  
  229.           ^Q~^QF^N<SPACE><SPACE><SPACE><SPACE><SPACE>
  230.              ^M<SPACE>^M^D^T^I^P<SPACE>^[1
  231.  
  232.      (Type the above into the shorthand screen for macro #1.
  233.      NOTE: Use Ctrl-P, Ctrl-Q-~ to indicate you are entering
  234.      control characters (like the ^Q~) into the macro.  Ditto for
  235.      ^QF, ^N, ^M, ^D, ^T, <Tab>, ^P<SPACE>, <ESC>1.  Each of
  236.      these control-key combinations is preceded with ^P.  The
  237.      ^P<SPACE> gives a small delay to allow you to bail out with
  238.      Ctrl-U if you need to.  This macro calls itself so you may
  239.      want to bail out at some point.
  240.  
  241.      Once executed this macro goes through the file and replaces
  242.      the 5 hard spaces following a CR/LF (^N) with a tab (^I).
  243.      In offset ASCII files with 5 spaces between the left margin
  244.      and your text, all lines will snuggle up to the left margin
  245.      after you go through with ^QA and replace the tabs.
  246.  
  247.      If you want to use another macro besides #1, replace the "1"
  248.      at the end of the string with "x" for the named macro you
  249.      want to use.
  250.  
  251.      For best results set your help level at 2 or higher.  At the
  252.      end of the Find & Replace, the macro number will print
  253.      on screen at the end of the file; just remove it.  Then go
  254.      ahead and Find & Replace the tabs with (nothing).  Voila!
  255.      Your file begins in column 1.
  256.  
  257.      After you've eliminated the offset left margin, proceed
  258.      with the above Instructions to Find & Replace the CR/LFs at
  259.      the end of each line.
  260.  
  261.      This 2nd procedure has the added advantage of giving you a 
  262.      useful macro to Convert Indents to Tabs if you later import 
  263.      any ASCII file (or *old WordStar Document files*) into 
  264.      WordStar 5.n, since the newer versions of WordStar use a 
  265.      "special binary code" instead of 5 spaces for a tab.  
  266.      This, according to the WS NEWS article, allows WordStar 
  267.      to be very precise in where the tab stop appears, and tabs 
  268.      are "completely font independent."
  269.  
  270.      The disadvantage is that you create a macro that replaces
  271.      5 spaces with a tab.  If your ASCII file's offset margin has
  272.      greater or fewer spaces than 5, you'll need to adjust the
  273.      macro above accordingly.  No big deal, but you'll have to
  274.      reset the macro for differing ASCII files.  For other than 
  275.      5-space margins, then, using the first method will be easier.
  276.  
  277.                            ** END **
  278.