home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / f / finrep28.lbr / FINREP.DZC / FINREP.DOC
Encoding:
Text File  |  1993-10-26  |  14.6 KB  |  320 lines

  1.  
  2.                         FINREP.DOC  Version 2.8
  3.                                 05/28/88
  4.  
  5.                                Eric Gans
  6.                         French Department, UCLA
  7.                          Los Angeles, CA 90024
  8.  
  9.  
  10.       * MS-DOS users: FINREP now exists for DOS. MS-DOS v2.6 is *
  11.       * (more or less) equivalent to CP/M v2.7.                 *
  12.  
  13.  
  14. Version 2.8
  15. Corrects another couple of bugs introduced into v2.6 (sigh). It would be
  16. nice if this were the final version for a while.
  17.  
  18. Version 2.7
  19. Corrects  a bug introduced in  v2.6  that  cut  the output file short in
  20. certain cases.
  21.  
  22. Version 2.6
  23. Corrected a bug in reading words across sectors.
  24.  
  25. Version 2.5
  26. Corrected a bug in the wild-card file routine (thanks to faithful FINREP
  27. user John Stensvaag).  Improved verify routine (as per DOS version); re-
  28. duced program size.
  29.  
  30. Version 2.4
  31. The  search routines have been extensively revised and debugged.  FINREP
  32. should now find just about any string, however perverse.
  33.  
  34. Version 2.3
  35. Fixed bug that made  verification  incompatible with multiple (wildcard)
  36. files.  Allow wildcard (?, not *) at end of search string.
  37.  
  38. Version 2.2
  39. Added "V" flag to allow  user verification ("Replace (y/n)?") before re-
  40. placement in text files; a few minor improvements.
  41.  
  42. Version 2.1
  43. Fixed bug that treated wildcard  filetypes as single files.  Added a few
  44. clarifications to .DOC file.
  45.  
  46. Version 2.0
  47. Allows wildcard searches  (various options), wildcard filetypes.  Easier
  48. entry of caps (!string!  instead of !s!t!r!i!n!g).  Allows control char-
  49. acters other than letters (e.g., ^[,^@).
  50.  
  51.                               *****
  52.  
  53.      FINREP is a search/replace program that remedies most of the defic-
  54. iencies of Wordstar's ^QA and  other similar commands.  Aside from being
  55. faster, it has important additional features:
  56.  
  57.      - allows wildcards in search string (v2.0)
  58.      - allows wildcard filename (find/replace in groups of files)
  59.      - command-line entry allows batch processing by SUBMIT, etc.
  60.      - allows entry of control or hex characters (0-FF)
  61.      - can be used with object files (e.g., COM files)
  62.      - sets  capitalization (first letter or whole word) and high
  63.        bit of the last character according to the old string
  64.  
  65. This last feature means that, for example, if you are writing a scenario
  66. where the characters' names appear  sometimes in CAPS and sometimes just
  67. Capitalized, you don't need two search/replaces to replace one name with
  68. another: JOE will be replaced by HARRY, Joe by Harry,  and  even  joe by
  69. harry.
  70.  
  71.                                  *****
  72.  
  73.     Format: FINREP [D:]fn [NEWFN] /[SWITCHES]/ OLDSTRING [NEWSTRING]
  74.  
  75.           (Enter "FINREP" alone for a brief command summary.)
  76.  
  77. If a second filename is given, the  changes will be placed in that file;
  78. if not the old filename will hold the changes and the original file will
  79. be changed from fn.ft to fn.BAK  (unless  the "B" switch is used).
  80.  
  81. Wildcards (*,?) may be used anywhere in the filename; if there are wild-
  82. cards in the filetype (after the ".") the B switch will be set automati-
  83. cally to suppress creation of  BAK files.  If wildcards are used,  a se-
  84. cond filename cannot be entered.  If you enter:
  85.  
  86.                    A>FINREP URK*.DOC // "blurk" "zap"
  87.  
  88. the files URK01.DOC,  URK33.DOC,  URKTTY.DOC would be modified as expec-
  89. ted and files URK01.BAK, URK33.BAK etc. would be created.
  90.  
  91. The characters "//" must be entered even if no switches are used.
  92.  
  93. The switches are as follows:
  94.  
  95. B = no BAK file.  This switch  disables  making a BAK file; the original
  96.     file will be lost.  (Use only if you did not  enter  a  second file-
  97.     name.)
  98.  
  99. Q = allow wildcards in search  string.  (The program runs faster if this
  100.     switch is not used.)  The various options for this  command  are de-
  101.     scribed below.
  102.  
  103. V = verify replacement.  If this switch is used, the context of the
  104.     search string will be displayed on  the screen and you will be quer-
  105.     ied re replacement.  This switch cannot be used along with the  O or
  106.     H switches (see below).
  107.  
  108. O = Object file.  If this switch  is  used, the program will ignore end-
  109.     of-file markers (1AH), as in PIP's "o" command.  Use for search/re-
  110.     place in non-text files.  WARNING: if you don't use "O" with a non-
  111.     text file it will be cut off after the first 1Ah. That's why FINREP
  112.     makes .BAK files!
  113.  
  114. H = keep High bit.  With this  switch, all bytes are searched exactly as
  115.     they are; letters with the high bit set will not be  identified with
  116.     their standard ASCII counterparts.
  117.  
  118. W = no Whole-word search. This switch is used to search a string whether
  119.     or not it is a whole word; with it, a search for "the" will find
  120.     "other", "their" etc.
  121.  
  122. NB= The program defines a  "word"  as  anything preceded and followed by
  123.     something other than a letter (space, punctuation mark, number, con-
  124.     trol character, beginning or end of file). Thus this  switch  is not
  125.     needed if  the search string is a serie  of words, a  word  preceded
  126.     by a control character that is  not contiguous to another word, etc.
  127.  
  128. C = respect case.  This switch allows you  to  distinguish  capital from
  129.     lower-case letters:  in a search for "the", "The" will not be found/
  130.     replaced. (NB: Upper case  letters  cannot be entered within quotes;
  131.     see below.)
  132.  
  133. &&&&&&&&&&
  134. ex
  135. In normal operation (with  no  switches),  the search will include whole
  136. words only; it will ignore case and high  bits,  but  will  set  the new
  137. string to  correspond to the old in this respect, capitalizing the first
  138. letter or the whole string and setting  the  high bit of the last as re-
  139. quired.  This last feature is only useful if the  replacement  string is
  140. one word  long;  if it contains more than one word, you may set the high
  141. bits when you enter the string  or let your word-processor e.g. Wordstar
  142. do it.  If you include capitals in your replacement string, they will be
  143. respected even if the find string is not capitalized.
  144.  
  145. If you want to search for a capitalized word you must use the "C" switch
  146. (or the "H" or "O" switch); FINREP will give you an error message if you
  147. don't.
  148.  
  149. The last four switches are in the relation O > H > C
  150.                                                  > W ; the "higher"
  151. switch includes the smaller.  Thus if  the  "H" switch is used, capitals
  152. and lower case will be distinguished, and the search will not be limited
  153. to whole words.
  154.  
  155. ************************************************************************
  156.  
  157. String entry:
  158.  
  159. The find and replace  strings  must  be  separated  by  a space from the
  160. switch entry and from each other.  Strings should be entered as follows:
  161.  
  162. ASCII - in quotes:  "blurk", "54%**90er @"
  163.  
  164. The following characters must NOT be placed between quotes:
  165.  
  166. HEX - separate  by  commas:  d,1A,cd,10,ff,3  CAPITALS - between !!:!A!,
  167. !hello!  [NEW IN V2.0] CONTROL CHARACTERS - preceded  by  ^: ^M,^m^j,^c,
  168. ^C,^[,^^ WILDCARDS - ????, ?n (1 <= n <= 9) or ?* (indeterminate)
  169.  
  170.      The "|" character is used to  display a break in the replace string
  171. (see below).
  172.  
  173. All ASCII letters entered within  quotes  will be treated as LOWER CASE.
  174. If you want to search upper case letters with the "C" switch, or  to put
  175. upper case  letters  in  the replace string, you must surround them with
  176. "!!", unless you enter them as  hex  characters:  (A  = 41, B = 42 ...).
  177. Sorry about this, but the CP/M  command  line  cannot  distinguish upper
  178. from lower case.
  179.  
  180. Any combination of characters  is  valid;  for clarity, groups should be
  181. separated by commas, although this is only necessary for  individual hex
  182. characters:  !h!"ello",^m^j,e5,?7,32,!blurk!,^q Quotes and !..!  must be
  183. closed.  To search/replace the quotation mark, enter it as a hex charac-
  184. ter ("=22h).  You can search for "!" if you keep it between quotes.
  185.  
  186. The length of the  find/replace  strings  is  limited  to 30 bytes; this
  187. length applies to the strings themselves and not to the  keyboard entry,
  188. which cannot exceed 127 bytes in all (blame CP/M for this).  ^j,cd,ff,3d
  189. is 4 bytes long.  In the case of indeterminate wildcards up to 255 bytes
  190. are allowed.  The  limit of 30 still stands for the find/replace strings
  191. themselves.
  192.  
  193. If you do not enter  a  replace  string, the searched-for string will be
  194. replaced by nothing, i.e., deleted.
  195.  
  196. WILDCARDS
  197.  
  198. The wildcard search has a  great  deal of flexibility.  For obvious rea-
  199. sons, wildcards cannot appear at the  beginning  of  the  search string.
  200. (In versions  below  2.3 they can't be at the end either.  For some not-
  201. so-obvious reason this seemed a bad thing at the time.)  The options are
  202. as follows:
  203.  
  204. 1.  Simple wildcard search:  all bytes of  the search string will be re-
  205. placed.
  206.  
  207. FINREP ZZ.TXT /q/ "d"?2"e"  "xxyz"  will  replace all words like "done",
  208. "dare", "dove" etc.  by "xxyz" A maximum of four wildcard groups are al-
  209. allowed in this form:  thus "a"?"cd"?4"ijk"??"nopq"?"s" is a permissible
  210. search string
  211.  
  212. 2.  Simple wildcard search with  break.  Only  one wildcard group is as-
  213. lowed; the replace string is divided in two,  with  the  first  part re-
  214. placing what precedes the wildcards and the second what follows; the in-
  215. termediate bytes  are left alone.  The break CAN appear at the beginning
  216. or end of the replace string  to indicate that the corresponding part of
  217. the find string is to be deleted. A blank replace string (entered simply
  218. as:  | ) will delete both.
  219.  
  220. FINREP xx.TXT /qw/ "d"?2"e" "xx"|"yzz" will replace the "d" in this pat-
  221. tern with "xx" and the  "e"  with  "yzz"; "done" becomes "xxonyyz", "ma-
  222. dame" -> "maxxamyxx", etc.  (This last example  only  works  if  the "W"
  223. switch is used.)
  224.  
  225. 3.  Indeterminate wildcard  search/replace.  The  indeterminate wildcard
  226. "?*" must be the only wildcard in the search string.  In this option the
  227. whole string from the beginning to end is  replaced.  A  maximum  of 255
  228. characters will be allowed in the search string; longer strings will not
  229. be found.
  230.  
  231. finrep blurk.let /qw/ "xy"?*"zq" "garbage"  will replace all strings be-
  232. ginning and ending  with  the  indicated  letters:  "xyrwerwerzq", "xyuu
  233. is the nbrzq", "xy ^C^Yzq" will all be replaced by "garbage"
  234.  
  235. NB - Since FINREP only looks for  one  thing at a time, it will not find
  236. nested pairs of strings, and will appear to miss  some  pairs  where the
  237. second half  of  the search string is over 255 bytes away from the point
  238. at which the search began.  (FINREP  checks  this only every 128 bytes.)
  239. Thus if you are looking for "the"?*"of", FINREP will sometimes  miss the
  240. apparent "hit"  in  a text like this:  ...  the [ ...  the ...  ] of ...
  241. where the  []  contain  over  255  bytes.  This  is  not  a  bug,  but a
  242. limitation of the program.
  243.  
  244. 4.  Indeterminate wildcard with break.  This  is  a very powerful option
  245. that allows you, for example,  to  replace  PerfectWriter  "fences" with
  246. WordStar control  toggles  (& vice versa).  Here again only one wildcard
  247. group is allowed in the  search  string; the intermediate bytes are left
  248. unchanged.
  249.  
  250. finrep zap.kkk /qw/ "123"?*"45" "6"|"789" will replace "zz123blurk blurk
  251. xxxc oo45rr" by  "zz6blurk  blurk  xxxc  oo789rr"; finrep perf.wri /qwc/
  252. "@"!ux!"{"?*"}" ^s|^s will replace the PW underline fence @UX{ ...  } by
  253. WS's ^S ...  ^S Note that the "C" flag is used here to search  for caps;
  254. if l.c.  as  well  as  caps  are acceptable, it could be omitted and the
  255. search string written "@ux{"?*"}".  You can delete the fences altogether
  256. by replacing the ^s|^s by | in the last example.
  257.  
  258. One user thought the word "break"  was misleading and should be replaced
  259. by "save," since the "|" in the replace string means  that  you preserve
  260. the wildcard part of the search string.  In other words:  finrep zap.txt
  261. /qw/ "<<"?*">>"  will  kill  everything  between  the  "<<..>>" whereas:
  262. finrep zap.txt /qw/ "<<"?*">>" | will just kill  the  "<<>>"  and "save"
  263. their contents.
  264.  
  265. FINREP can be aborted at any time by typing <ESC> (=1B HEX). I preferred
  266. this to ^C since an extra ^C will be read by CP/M as a Warm Boot.
  267.  
  268. Except when the "V" switch is used, the only screen output is the number
  269. of strings replaced and, if you  use wildcards, the names & total number
  270. of files processed.  If you want to  see  the  replacement  procedure in
  271. action, use a word-processor!
  272.  
  273. Notes:
  274.  
  275. 1.  FINREP will modify files of  any  length;  it uses the entire memory
  276. below the CCP as its buffer, and  writes  to  disk  whenever  the buffer
  277. fills up.  Since  it  doesn't  overwrite the CCP, it doesn't have to end
  278. with a Warm Boot.
  279.  
  280. 2.  There is no intrinsic limit on the number of files allowed under the
  281. wildcard filename option; for sanity's sake,  you will get an error mes-
  282. sage if there are more than 255.
  283.  
  284. 3.  If you want to create a version  of FINREP with some of the switches
  285. preset, run the program without a filename:  finrep /[sw1][sw2]../ After
  286. it returns to  the  CP/M  prompt,  save  13  finrep1.com  will  keep the
  287. switches as  you  like  them.  This procedure is NOT REVERSIBLE, so keep
  288. your original FINREP unchanged.
  289.  
  290. 4.  In deciding whether to capitalize  a whole word/string, FINREP looks
  291. at the first two letters.  If the find string has only one  letter, only
  292. the first  letter of the replacement string will be capitalized.  If the
  293. word to be replaced has unusual captalization (e.g.  BBrrOOOmm), use the
  294. "C" switch  and/or  enter  separate  replacement  strings  for different
  295. variants.
  296.  
  297. 5.  In using indeterminate  wildcards,  you  should  use  the "W" switch
  298. unless  BOTH  HALVES  of  the  search  string  begin  and  end  on  word
  299. boundaries.
  300.  
  301. 6.  Re speed, FINREP  is  somewhat  faster  than Wordstar's ^QA command.
  302. But if all you want to do is replace a string, it  is  over  three times
  303. faster, since  its  time includes loading and saving the file.  Measured
  304. on a long (84 K) file, FINREP  took  27  seconds and WS 34 for a typical
  305. search/replace.  But WS needs at least 10 seconds  to  load  and  a good
  306. minute to  save  the file and exit.  With a little practice, the command
  307. line can be entered as fast  as  WS's,  and it can be included in SUBMIT
  308. files or reproduced by programs like SYNONYM or my SYN.COM.
  309.  
  310.                                  *****
  311.  
  312. FINREP was written at the  request  of John-Mark Stensvaag of Vanderbilt
  313. University.  At first I couldn't see the use for it, but he convinced me
  314. (he is a professor of Law).  The wildcard  features  added  in  v1.1 and
  315. v2.0 were also his idea; the verification feature in v2.2 was ssuggested
  316. by J.  Olsen  of Chicago.  I would appreciate hearing from you about (a)
  317. bugs and (b) suggestions for further enhancements.
  318.  
  319. --------------------------------- end ----------------------------------
  320.