home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / text / textport / readme < prev    next >
Text File  |  1995-02-27  |  9KB  |  196 lines

  1.  
  2. TEXT FILE PORTABILITY AIDS    6/6/92 public domain
  3. --------------------------    Alex Matulich, Unicorn Research Corp
  4.                               4621 N. Landmark Drive
  5.                               Orlando, FL 32817-1235
  6.                               (407) 657-4974
  7.                               alex%bilver@peora.sdc.ccur.com
  8.  
  9. This archive contains three programs plus C source code for each:
  10.    AddCR    -- converts unix or AmigaDOS text files to MS-DOS
  11.    StripCR  -- converts MS-DOS text files to unix or AmigaDOS
  12.    StripHR  -- selectively strips hard returns from a text file.
  13.    Reformat -- reformats a text file using a different line length
  14.  
  15. Typing the name of each command on the command line will display its
  16. function and syntax.
  17.  
  18. These 4 utilities are helpful when transferring text files between
  19. dissimilar operating systems or when importing text files into word
  20. processing (WP) or desktop-publishing (DTP) software, or uploading
  21. text into BBS message editors.
  22.  
  23. IMPORTANT:  Normally, you specify an input file to process, and an output
  24. file to write.  However, all these utilities are capable of processing a
  25. file "in place" if you do not specify an output file.  This practice is
  26. not recommended because (1) it is MUCH slower, and (2) your original file
  27. may be destroyed if something goes wrong.  Be warned!
  28.  
  29.  
  30. Explanation (i.e. why bother?)
  31. ------------------------------
  32.    The end-of-line (EOL) code used in MS-DOS text files is different
  33. from that used in other operating systems such as unix or AmigaDOS.
  34. MS-DOS uses two characters at the end of each text line: a carriage
  35. return (CR) plus a linefeed (LF).  Unix uses only one character as the
  36. EOL code, LF.
  37.  
  38.    The programs StripCR and AddCR will convert EOL codes from CR+LF to
  39. LF and back again.  StripCR strips out the CR characters from a text
  40. file, leaving only LF characters at the end of each line.  AddCR looks
  41. for LF characters in a file, and inserts a CR in front of those that are
  42. not already preceded by CR, thus ensuring that all LF's will be
  43. converted to CR+LF.
  44.  
  45.    Now that you have your text file all nice and compatible with your
  46. operating system, you probably want to import it into WP or DTP
  47. software, right?  Before doing so, run the text file through the StripHR
  48. utility.  Why, you ask?  Well, all WP or DTP packages have the ability
  49. to import text.  Invariably, however, the imported text will not fit
  50. properly within the margins you wish to use, which means that you will
  51. have to reformat everything in your WP program manually.  Many software
  52. packages give you the option to strip out the hard returns (EOL codes)
  53. in your text file as it is being imported, so that the software can
  54. format it to your margins by itself.  Trouble is, often ALL, or too
  55. many, of the hard returns are stripped out, and this messes up paragraph
  56. breaks and section titles, so you still have to go through your text
  57. and reformat everything manually.
  58.  
  59.    StripHR is more selective about removing hard returns.  It removes
  60. all hard returns except the ones that precede a paragraph indent or a
  61. blank line.  This means that the paragraph formatting in your text file
  62. will be preserved.  A normal paragraph which is flush to the left will
  63. have all hard returns removed within it, but there will still be a hard
  64. return at the end of the paragraph.  Also, indented blocks of text
  65. (where each line in the block starts with a space or a tab) will be left
  66. alone, as will lines that are intentionally blank.  After running your
  67. text file through StripHR, just import it straight into your WP or DTP
  68. software, without stripping any more hard returns.
  69.  
  70.    Reformat will take a text file and reformat it to fit within a
  71. specified line length.  This is useful if you have to upload a text file
  72. into an online editor that has its own idea about where the wrap margin
  73. is located.  Two situations can occur:  The lines in your text file
  74. might be a little too long, and the editor will split each line, usually
  75. leaving single words on lines by themselves.  Or, if you have a
  76. "continuous" text file (say, the output of StripHR), you might be using
  77. an online editor that doesn't insert carriage returns into the text as
  78. you upload it, resulting in long one-line paragraphs that wrap around
  79. and around the screen.  Running a text file through Reformat first
  80. should take care of most problems, though some minor post-editing may be
  81. necessary.
  82.  
  83.    StripHR and Reformat leave indented text alone.  So if you have a
  84. textfile with a "left margin" throughout, these utilities won't have any
  85. effect.  If I feel like it, I'll modify these utilities to handle this
  86. special case, but it's not likely to be soon, because I'm satisfied.
  87.  
  88.  
  89. Usage
  90. -----
  91.  
  92. Each of these utilities will give you an explanation on its use when you
  93. enter its name by itself on the command line.  More detailed information
  94. is below.
  95.  
  96.  
  97. ----- AddCR -----
  98.  
  99. To add CR characters to a text file, type:
  100.  
  101.     AddCR file             (operates on the file "in place" - avoid this!)
  102.  or AddCR infile outfile   (infile left alone, new version is outfile)
  103.  Example:  addcr unixfile.txt msdos.txt
  104.  
  105. If there are existing CR+LF codes, AddCR will leave them alone, instead
  106. of converting them to CR+CR+LF codes, which are meaningless.
  107.  
  108.  
  109. ----- StripCR -----
  110.  
  111. To strip CR characters from a text file, type:
  112.  
  113.     StripCR infile         (operates in place)
  114.  or StripCR infile outfile (infile left alone, stripped version is
  115.                             saved in outfile)
  116.  Example:  stripcr msdos.txt unixfile.txt
  117.  
  118. When stripping is done in place, the resulting file size is equal to or
  119. shorter than the original (because characters are being removed).  The
  120. new replaced file will have its end flagged with a ctrl-Z character,
  121. followed by some useless text from the old version of the file.  Most
  122. MS-DOS software will ignore anything after the ctrl-Z.  You can delete
  123. anything after the ctrl-Z with a text editor if you wish.
  124.  
  125.  
  126. ----- StripHR -----
  127.  
  128. To strip out hard returns from a file, leaving paragraphs intact, type:
  129.  
  130.     StripHR infile           (operates in place)
  131.  or StripHR infile outfile   (creates a new modified file)
  132.  Example:  striphr article.txt article.wp
  133.  
  134. Here's the decision logic that determines which hard returns will be
  135. kept and which will be thrown out:  A hard return is discarded unless
  136. (1) it is followed by "white space" (a space, tab, or blank line), or
  137. (2) it is preceded by another hard return.
  138. These rules ensure that paragraphs and blank lines will be kept intact.
  139.  
  140.  
  141. ----- Reformat -----
  142.  
  143. To reformat a text file to new line lengths, the command syntax is:
  144.  
  145.     Reformat [-r] [-lN] [-tM] infile [outfile]
  146.  Example:  Reformat -l70 -t4 article.wp article.txt
  147.  
  148. Parameters for Reformat:
  149.    -r  = Re-wrap lines that happen to be shorter than the specified
  150.          length.  The default is to leave shorter lines alone.  Either
  151.          setting may be a compromise, depending on what you want.
  152.    -lN = Set maximum line length to N characters.  Default is 72.
  153.    -tM = Assume that tabs are M characters wide.  Default assumes 8.
  154.  
  155. Reformat can also be used as a functional equivalent to StripHR.  You
  156. could delete StripHR altogether, and set up a command alias to use
  157. Reformat, something like:
  158.  
  159.    alias StripHR = Reformat -r -l20000
  160.  
  161. This will work exactly like StripHR, assuming each paragraphs is less
  162. than 20,000 characters long!  (StripHR itself has no limitation, and
  163. and it's a bit faster as well.)
  164.  
  165. -----
  166.  
  167. >>> IMPORTANT! >>>  Be sure your input text file is compatible with
  168. your operating system, or the output of Reformat/StripHR could be trash!
  169. If you're running MS-DOS, make sure that the EOL codes are the CR+LF
  170. type. To be safe, specify both an input and output file when using
  171. StripHR or Reformat; this will preserve your original file in case
  172. something goes awry, or if you just don't like the result.
  173.  
  174.  
  175. Changes from the previous release
  176. ---------------------------------
  177.  
  178. All utilities are now capable of operating on files in place, instead of
  179. just the stripping utilities.  This practice is not recommended, however,
  180. because it is slower and you risk destroying your original file if
  181. something goes wrong.  But if you have little disk space to spare, this
  182. method might be the best way.
  183.  
  184. In-place operations used to be excruciatingly slow.  Now the in-place
  185. mode is significantly faster.  Instead of reading & writing one character
  186. at a time, a 16K buffer is used to hold the output so that reads will be
  187. smoother.
  188.  
  189. The Reformat utility was added to the collection.
  190.  
  191. Online help is now more informative.
  192.  
  193. StripHR used to lose the last character in a file.  No more.
  194.  
  195. Endless-loop condition on buffer-emptying process in AddCR fixed.
  196.