home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / bfind604.zip / BFIND.DOC next >
Text File  |  1996-04-20  |  13KB  |  297 lines

  1. BFIND.DOC                            1                         Revised: 04/20/96
  2.  
  3. The BFIND.EXE program adds Boolean logic to DOS's FIND command.  In  most  ways,
  4. it's identical to the FIND command except:
  5.  
  6.   * Adds AND, OR, NOT, and XOR options to searches (finding all lines with
  7.     "Apples" or "Bananas", for example).
  8.   * Allows you to specify the starting column of the desired string.
  9.   * Adds a pause (/P) option to have the output pause every 24 lines.
  10.   * Avoids need to include the search string in quotation marks so you can
  11.     use the program more easily in batch commands.
  12.   * The input file specification can include standard DOS wildcards or an
  13.     external file (@listfile) containing the files to be processed, e.g:
  14.         BFIND /I "SOUND" *.DOC > TEMP.X
  15.   * Allows you to skip the by-file heading information ("----- filename").
  16.   * Can avoid showing file name header if no hits in the file (/-EMPTY option).
  17.   * Handles DOS text files (lines end with CR/LF), Mac text files (lines end
  18.     with CR), or Unix text files (lines end with LF).
  19.   * Should be able to handle input files with line lengths of 5000 characters
  20.     or more.
  21.   * Allows you to remove non-text characters from the output or even specify
  22.     your own character-translation file for them.
  23.  
  24. The only FIND feature that BFIND does *not* support is the  ability  to  specify
  25. multilple single input  files  without  using  wildcards  ("FIND  ...  BRUCE.TXT
  26. BRUCE.DOC" works--"BFIND ... BRUCE.TXT BRUCE.DOC" does not).  In  addition,  you
  27. cannot do piping into BFIND (e.g. DIR | BFIND ...).
  28.  
  29. The DOS FIND command allows you to find lines in a text  file  which  contain  a
  30. given string.  You can also have the program tell you how  many  lines  met  the
  31. search criteria without actually viewing them which is an ideal way to find  out
  32. how many times a given string appears in your file.  You can even  use  FIND  to
  33. tell you how many total lines are in a given file just by  requesting  a  string
  34. that you know will never appear in your file  like  "#X$S$"  and  using  the  /C
  35. (count) parameter.
  36.  
  37. BFIND adds to these capabilities.  It gives you the power of AND, OR,  NOT,  and
  38. XOR, allowing you to find any line, for example, that contains both "Apples" and
  39. "Oranges" or to present any lines that contain either "Bananas" and "Pears".  In
  40. addition, you can do column-specific searching, finding only those  lines,  say,
  41. that contain "PRINT" beginning in column 10.
  42.  
  43. BFIND allows you to specify wildcards for the input file.  You can also put  the
  44. list of file names to process in a text file and tell BFIND to process the files
  45. listed therein.
  46.  
  47.  
  48. Specifying parameters:
  49.  
  50. Parameters for this program can be set in the following ways.  The last  setting
  51. encountered always wins:
  52.   - Read from an *.INI file (see BRUCEINI.DOC file),
  53.   - Through the use of an environmental variable (SET BFIND=whatever), or
  54.   - From the command line (see "Syntax" below)
  55.  
  56.  
  57.  
  58. BFIND.DOC                            2                         Revised: 04/20/96
  59.  
  60. Syntax:
  61.  
  62.     BFIND [ /V | /-V ] [ /C | /-C ] [ /N | /-N ] [ /I | /-I ] [ /P | /-P ]
  63.       [ /-HEADER | /HEADER ] [ /EMPTY | /-EMPTY ] [ /FILTER | /FILTER=filename ]
  64.       [ /Iinitfile | /INULL ] [ /? ] [ /?&H ]
  65.       { search } { filespec | @listfile } [ >filename ]
  66.  
  67. where:
  68.  
  69. "/V" says to find those items that do NOT match the specification.
  70.  
  71. "/-V" is the opposite of /V and is typically the default.
  72.  
  73. "/C" says to show the count of the items found (no individual lines).   One  use
  74. for this is to count the number of lines in a file.  Search for all  lines  that
  75. do *not* (/V) contain a totally improbable string and then tally them.  E.g.
  76.  
  77.         BFIND /V /C "&^&^&#" MYFILE.TXT
  78.  
  79. "/-C" is the opposite of /C and is typically the default.
  80.  
  81. "/N" says to number the output lines.
  82.  
  83. "/-N" is the opposite of /N and is typically the default.
  84.  
  85. "/I" says to make it a case-insensitive search.  So a search  for  "Apple"  will
  86. find "APPLE", "apple", ApPle", etc.
  87.  
  88. "/-I" is the opposite of /I and is typically the default.  A search for  "Apple"
  89. will not find "APPLE".
  90.  
  91. "/P" says to have the display pause every 24 lines.
  92.  
  93. "/-P" is the opposite of /P and is typically the default.
  94.  
  95. "/-HEADER" says to skip the normal -----infile output line that  appears  before
  96. the results of the output.
  97.  
  98. "/HEADER" is the opposite of /-HEADER and is typically the default.
  99.  
  100. "/EMPTY" says that the -----infile information is to be shown even if  the  file
  101. doesn't have any hits in it.  This is initially the default.
  102.  
  103. "/-EMPTY" says to only show the -----infile information if the file has hits.
  104.  
  105. "/FILTER" says to remove all nonprintable characters from the output.  Initially
  106. defaults to "/-FILTER".
  107.  
  108. "/FILTER=filename" specifies that a filter is to be  applied  and  all  non-same
  109. character replacements are in the file "filename".   This  feature  is  of  very
  110. limited usefulness in the  BFIND  program  unless  you're  reading  native  word
  111. processing files.  If this excites you for some reason, get the ZIP  READymm.ZIP
  112. and read the documentation for the READY program.  The feature works identically
  113. in both programs.
  114.  
  115.  
  116. BFIND.DOC                            3                         Revised: 04/20/96
  117.  
  118. "/Iinitfile" says to read an initialization file with the file name  "initfile".
  119. The file specification *must* contain a period.  Initfiles are described in  the
  120. BRUCEINI.DOC file.  Initially defaults to "/IBFIND.INI".
  121.  
  122. "/INULL" says to skip loading the initialization file.
  123.  
  124. "/?" or "/HELP" or "HELP" shows you the syntax for the command.
  125.  
  126. "/?&H" gives you a hexadecimal and decimal conversion table.
  127.  
  128. "search" is described below.
  129.  
  130. "filespec" tells the routine which file or  files  are  to  be  processed.   The
  131. specification can include path and wildcards  if  desired.   One  thing  I  find
  132. useful with wildcards is that is allows me to create an output that concatenates
  133. all of the input files together with the typical headers (/HEADER) that separate
  134. each portion.  This requires searching for all lines in a file so  you  need  to
  135. use the  /V  option  and  look  for  an  improbable  string.   For  example,  to
  136. concatenate all *.TXT files together as a new file called TEMP.NEW and have  the
  137. little header between each, say this:
  138.  
  139.         BFIND /V "&#$#" *.TXT > TEMP.NEW
  140.  
  141. "@listfile" allows you to have a variety of file specifications saved in a  text
  142. file named "listfile".  Each line  in  the  file  should  consist  of  one  file
  143. specification, each of which can include a path and wildcards if desired.  Blank
  144. lines and lines beginning with semi-colons, colons, or quotes are  ignored.   An
  145. example using this is provided at the end of this documentation.
  146.  
  147. ">filename" redirects the output to a text file.  This automatically invokes the
  148. /-P option.  This is useful for saving the found lines into another  file.   For
  149. example:
  150.  
  151.         BFIND "Bruce" TEMP.TXT > TEMP2.TXT
  152.  
  153.  
  154.  
  155. BFIND.DOC                            4                         Revised: 04/20/96
  156.  
  157. For search, the syntax is:
  158.  
  159.   [ ( ]... search_item [ boolean [ ( ]... search_item [ ) ]...] [ ) ]...
  160.  
  161. where:
  162.  
  163.   ( and )     are used to group items
  164.   search_item is shown below
  165.   boolean     is AND, OR, or XOR (NOT is included with search_item)
  166.  
  167. for search_item, the syntax is:
  168.  
  169.   [ NOT ]  "string" [ column ]
  170.  
  171. where:
  172.  
  173.   NOT         is obvious
  174.   string      the string to search; the quotation marks are typically not
  175.               required unless the string contains a space or a reserved word
  176.   column      is the column in which the string must be found.
  177.  
  178. So, let's cover some examples:
  179.  
  180.         BFIND "Bugs Bunny" OR "Elmer Fudd" TEST.TXT
  181.  
  182. Finds any lines in the file TEST.TXT containing either "Bugs  Bunny"  or  "Elmer
  183. Fudd" in them.
  184.  
  185.         BFIND (Apples or Oranges) AND NOT Pears TEST2.TXT
  186.  
  187. Finds any lines in the file  TEST2.TXT  which  contain  the  words  "Apples"  or
  188. "Oranges" in them and ignores any  lines  containing  "Pears".   Note  that  the
  189. quotes around the search words are not required unless the words include  spaces
  190. or unless they could be confused with some other keywords.   "BFIND  OR  OR  AND
  191. TEST3.TXT" might cause the program to get confused since "OR" and  "AND",  which
  192. you want to look for, are also keywords.
  193.  
  194.         BFIND /C "Bugs Bunny" AND Martians TEST.TXT
  195.  
  196. Gives you a total for the number of  lines  containing  both  "Bugs  Bunny"  and
  197. "Martians".
  198.  
  199. The search string can include any text characters.  It can  also  contain  ASCII
  200. codes, created either using the Alt key in combination with the  numeric  keypad
  201. (e.g. Alt-228 to get a Sigma character) or else by embedding a hexadecimal  code
  202. (in the form &Hxx) or a decimal code (in the form  \nnn)  in  the  text.   These
  203. codes are described in the BRUCEHEX.DOC file.  For example, to find  the  smiley
  204. face character in a file called TEST.TXT, either of the following work:
  205.  
  206.         BFIND "" TEST.TXT
  207.         BFIND \001 TEST.TXT
  208.  
  209.  
  210. BFIND.DOC                            5                         Revised: 04/20/96
  211.  
  212. If you search for more than one word without using  a  Boolean  operator,  BFIND
  213. presumes you wanted the words searched with an "AND" Boolean operator.  So this:
  214.  
  215.         BFIND Print Form *.TXT
  216.  
  217. is the same thing as saying:
  218.  
  219.         BFIND Print AND Form *.TXT
  220.  
  221. If you wanted to search for the *phrase* "Print Form", you'd have to say:
  222.  
  223.         BFIND "Print Form" *.TXT
  224.  
  225. You can press the Esc key to abort the search early.
  226.  
  227. BFIND, unlike FIND, typically doesn't require the search string to be in quotes.
  228. As a result, you can create a text file (presume it's  called  C:\BAT\PHONE.TXT)
  229. containing phone numbers or  something  and  then  create  a  batch  file  (like
  230. PHONE.BAT) that looks like this:
  231.  
  232.         BFIND %1 %2 %3 %4 %5 C:\BAT\PHONE.TXT
  233.  
  234. When you want to find a phone number, you just say  "PHONE  name".   This  is  a
  235. little more natural that using FIND which would require  that  you  enclose  the
  236. name in quotes.  You can still use the Boolean operators  in  BFIND;  the  batch
  237. file above would allow up to five parameters.
  238.  
  239. If you have multiple phone books, use the @listfile option in  the  batch  file.
  240. For example, I have four phone files I search; a personal  one  (PHONES.TXT),  a
  241. list of e-mail addresses (PHONMAIL.TXT), a list of  work-related  phone  numbers
  242. that  are  distributed  to  the  office  (EBBPHONE.TXT),  and  an  office   list
  243. (OBAPHONE.TXT).  My @listfile is called  C:\MINE\PHONE.LST  and  contains  these
  244. lines:
  245.  
  246.         c:\mine\phones.txt
  247.         c:\mine\phonmail.txt
  248.         c:\mine\ebbphone.txt
  249.         c:\mine\obaphone.txt
  250.  
  251. My PHONE.BAT file contains this line:
  252.  
  253.         BFIND /I /P /-EMPTY %1 %2 %3 %4 @C:\MINE\PHONE.LST
  254.  
  255.  
  256.  
  257. BFIND.DOC                            6                         Revised: 04/20/96
  258.  
  259. Return codes:
  260.  
  261. BFIND returns the following ERRORLEVEL codes:
  262.         0 = no problems, string found
  263.         1 = no problems, string not found
  264.       255 = syntax problems, file not found, or /? requested
  265.  
  266.  
  267. Author:
  268.  
  269. This program was written by Bruce Guthrie of Wayne Software.  It is free for use
  270. and redistribution provided relevant documentation is kept with the program,  no
  271. changes are made to the program or documentation, and it  is  not  bundled  with
  272. commercial programs or charged for separately.  People who need to bundle it  in
  273. for-sale packages must pay a $50 registration fee to  "Wayne  Software"  at  the
  274. following address.
  275.  
  276. Additional information about this and other Wayne Software programs can be found
  277. in the file BRUCEymm.DOC which should be included  in  the  original  ZIP  file.
  278. ("ymm" is replaced by the last digit of the year and the two digit month of  the
  279. release.  BRUCE512.DOC came out in December 1995.  This same  naming  convention
  280. is used in naming the ZIP file that this program was included in.) Comments  and
  281. suggestions can also be sent to:
  282.  
  283.                 Bruce Guthrie
  284.                 Wayne Software
  285.                 113 Sheffield St.
  286.                 Silver Spring, MD 20910
  287.  
  288.                 fax: (301) 588-8986
  289.                 e-mail: bguthrie@nmaa.org
  290.                 http://hjs.geol.uib.no/guthrie/
  291.  
  292. See BRUCEymm.DOC file for additional contact information.
  293.  
  294. Foreign users:  Please provide an Internet e-mail address in all correspondence.
  295.  
  296. 
  297.