home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tclX-6.4 / help / filescan / scanmatch < prev   
Encoding:
Text File  |  1992-12-17  |  2.8 KB  |  59 lines

  1.  
  2.  
  3.           scanmatch [-nocase] contexthandle [regexp] commands
  4.                Specify Tcl commands, to be evaluated when regexp is
  5.                matched by a scanfile command.  The match is added to
  6.                the scan context specified by contexthandle.  Any
  7.                number of match statements may be specified for a give
  8.                context.  Regexp is a regular expression (see the
  9.                regexp command).  If -nocase is specified as the first
  10.                argument, the pattern is matched regardless of
  11.                alphabetic case.
  12.  
  13.                If regexp is not specified, then a default match is
  14.                specified for the scan context.  The default match will
  15.                be executed when a line of the file does not match any
  16.                of the regular expressions in the current scancontext.
  17.  
  18.                The array matchInfo is available to the Tcl code that
  19.                is executed when an expression matches (or defaults).
  20.                It contans information about the file being scanned and
  21.                where within it the expression was matched.
  22.  
  23.                matchInfo is local to the top level of the match
  24.                command unless declared global at that level by the Tcl
  25.                global command.  If it is to be used as a global, it
  26.                must be declared global before scanfile is called
  27.                (since scanfile sets the matchInfo before the match
  28.                code is executed, a subsequent global will override the
  29.                local variable).  The following array entries are
  30.                available:
  31.  
  32.                matchInfo(line)
  33.                     Contains the text of the line of the file that was
  34.                     matched.
  35.  
  36.                matchInfo(offset)
  37.                     The byte offset into the file of the first
  38.                     character of the line that was matched.
  39.  
  40.                matchInfo(linenum)
  41.                     The line number of the line that was matched. This
  42.                     is relative to the first line scanned, which is
  43.                     usually, but not necessarily, the first line of
  44.                     the file.  The first line is line number one.
  45.  
  46.                matchInfo(handle)
  47.                     The file handle of the file currently being
  48.                     scanned.
  49.  
  50.           All scanmatch patterns that match a line will be processed
  51.           in the order in which their specifications were added to the
  52.           scan context.  The remainder of the scanmatch pattern-
  53.           command pairs may be skipped for a file line if a continue
  54.           is executed by the Tcl code of a preceding, matched pattern.
  55.  
  56.           If a return is executed in the body of the match command,
  57.           the scanfile command currently in progress returns, with the
  58.           value passed to return as its return value.
  59.