home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff374.lzh / Mat / Mat.DOC < prev    next >
Text File  |  1990-10-08  |  52KB  |  1,201 lines

  1.   ============================================================================
  2.  ||                                                                        ||
  3.  ||     MAT -- p.n.; poss. abbrev. of "Match"; also "Matte" [Motion        ||
  4.  ||          Picture Arts]: means of cutting, inserting and superposing    ||
  5.  ||          disparate items.                                              ||
  6.  ||                                                                        ||
  7.  ||                         -------------------                            ||
  8.  ||                                                                        ||
  9.  ||  This program provides a flexible string-searching, pattern-matching   ||
  10.  ||  and substitution mechanism for both text and filenames.  Searching    ||
  11.  ||  for a string in a file is fast (it can be three times as fast as the  ||
  12.  ||  AmigaDOS 'SEARCH'). The (much slower) matching scheme is an extended  ||
  13.  ||  version of the standard AmigaDOS pattern-matching convention, with    ||
  14.  ||  the added features of negation and "slicing" of matched strings. It   ||
  15.  ||  will probably be most useful within command (or ARexx) scripts to     ||
  16.  ||  extend the operations possible with AmigaDOS.                         ||
  17.  ||                                                                        ||
  18.  ||                                                                        ||
  19.  ||                                                                        ||
  20.  ||         *   Searches for strings or patterns within text files.        ||
  21.  ||                                                                        ||
  22.  ||         *   Rearranges text within matched lines to                    ||
  23.  ||             create new files.                                          ||
  24.  ||                                                                        ||
  25.  ||         *   Tags and labels can be added to the output stream          ||
  26.  ||             at desired points                                          ||
  27.  ||                                                                        ||
  28.  ||         *   Searches directories for matching file names.              ||
  29.  ||                                                                        ||
  30.  ||         *   Creates Command Script Files by inserting the whole or     ||
  31.  ||             parts of matched filenames into text templates.            ||
  32.  ||                                                                        ||
  33.  ||         *   Control commands for the program may be read from a        ||
  34.  ||             script file as well as the command line.                   ||
  35.  ||                                                                        ||
  36.  ||                                                                        ||
  37.  ||                              -- Copyright 1990  Peter J. Goodeve --    ||
  38.  ============================================================================
  39.  
  40.  
  41.                         -- by Pete Goodeve --
  42.  
  43.                               July  1990
  44.  
  45. Overview
  46. ________
  47.  
  48.  
  49.     This program is intended to fill a number of pattern matching needs
  50. not covered by other facilities.  It is very flexible, and consequently
  51. has a number of features you may never use, but it is well suited to those
  52. everyday jobs, too.
  53.  
  54. It handles both string searches (in which the string will be found anywhere
  55. it occurs on the lines being scanned), and pattern matches that compare
  56. each whole line against a pattern.  String searches can be at least three
  57. times as fast as if you used the AmigaDOS 'SEARCH' (disk access time may
  58. well limit the improvement, though).  Pattern matches are much slower of
  59. course, but provide much more precise control of the operation.  You can
  60. also often get the best of both by "filtering" the text first with a string
  61. search and applying the pattern only to those lines that contain the filter
  62. string.
  63.  
  64. Patterns are in the usual AmigaDOS format (as used by LIST and so on), with
  65. a number of extensions.  You can specify "negative match" segments, whose
  66. appearance will cause a match to fail, and you can -- most importantly --
  67. indicate "slice points" that mark pieces of the matched string to be
  68. rearranged in the output.
  69.  
  70.  
  71. To illustrate:
  72.  
  73.             MAT S #include mysrc.c
  74.  
  75.     would print out all lines that contain the string "#include" in the
  76.     file "mysrc.c".  Note that a) the keyword argument "S" signals that
  77.     this is a string search (you can also use the full keyword "SEARCH"
  78.     -- upper or lower case); b) the string can be anywhere in the line
  79.     (though this particular one will usually be at the beginning);
  80.     and c) the character '#' has no special meaning in a string search
  81.     (as opposed to being a special character in a pattern).
  82.  
  83.             MAT S #include #?.c
  84.  
  85.     would do the same thing for all files in the current directory ending
  86.     in ".c".  You can have several file specifications in one command
  87.     if you like:
  88.  
  89.             MAT S #include test/#?.c WORK:#?/#?.c
  90.  
  91.     would search all such files in the subdirectory "test" and all
  92.     (immediate) subdirectories of assigned device "WORK:".
  93.  
  94.  
  95. The preceding examples simply display all lines that fit the criterion,
  96. but you can add a "template" to specify exactly what should be output.
  97.  
  98.             MAT S #include T "^F line ^N: ^O"  #?.c
  99.  
  100.     Here, the addition of the template, with its preceding keyword "T"
  101.     (or full word "TEMPLATE"), specifies that each matching line should
  102.     be displayed in this fashion:
  103.  
  104.         "mysrc.c line 5: #include <stdio.h>"
  105.  
  106.     The marker "^F" (two characters -- the caret '^' followed by upper
  107.     case 'F' -- NOT a "control-F") indicates that the current file name
  108.     should appear here; "^N" represents the current line number, and
  109.     "^O" ("Oh", not "zero") indicates the original current line.
  110.  
  111. There are a number of other template markers you can use, especially
  112. when you are matching against a "slicing pattern" rather than doing a
  113. string search.  You can also specify a template for all the lines that
  114. FAIL to match.
  115.  
  116. In addition to templates, which apply to every line, you can supply
  117. a "Tag", which applies once per file -- immediately before the first
  118. matched line if there is one, otherwise when the whole file has been
  119. read (giving an alternative message).  The format is the same as a
  120. template.
  121.  
  122.             MAT S #include TAG "^F:^| No matches found in ^F"  #?.c
  123.  
  124.     will display the filename (once) before all lines matched in that
  125.     file, or, if there were no matches, report that fact.  The "^|"
  126.     pair separates the 'success' and 'failure' portions of the tag
  127.     (or template).
  128.  
  129.  
  130. Pattern matching can be done on the lines of a file in much the same way.
  131.  
  132.             MAT "#?printf#?,# X,#?" mysrc.c
  133.  
  134.     looks for any lines that do a "printf" on variable "X" (with
  135.     arbitrary characters intervening. (Notice that no keyword is
  136.     needed here, as this is the default case, but if you prefer you
  137.     can use the key "P" or "PAT"; for variant forms, or where there
  138.     is ambiguity, a keyword may be required.)
  139.  
  140.     You can speed things up by screening the lines first:
  141.  
  142.             MAT S printf P "#?printf#?,# X,#?" mysrc.c
  143.  
  144.     only does the full match on lines that contain printf.  The keyword
  145.     "P" is needed here to make your intention clear.
  146.  
  147. You can add "slice-marks" to a pattern, and rearrange the resulting pieces
  148. with a template.  The slice-mark is a single caret character placed at the
  149. desired point.  (When you use slice marks, you must also use a template.)
  150.  
  151.             MAT #?^(word|another)^#? "^1: ^0----^2" myfile
  152.  
  153.     Here slice marks are placed either side of the bracketed alternation
  154.     in the pattern.  In the template,"^0" is the segment of the line matched
  155.     by the part of the pattern before the first slice mark, "^1" is the
  156.     segment between the two marks (i.e. "word" or "another", depending on
  157.     which was matched), and "^2" is the rest of the line.  Thus, if the
  158.     input line was
  159.  
  160.         "this line contains the word we are looking for"
  161.  
  162.     the output would be
  163.  
  164.         "word: this line contains the ---- we are looking for"
  165.  
  166.  
  167. Up to this point, the examples have focussed on scanning text files,
  168. but the same mechanisms can equally well examine directories.  For the
  169. simple jobs, of course, one would just do a DIR or LIST, or perhaps a
  170. LIST...LFORMAT.., but Mat can do a few things that the others can't.
  171. For instance, the ability to exclude files by means of a "negative
  172. match" can be very useful.  Also the template is rather more flexible
  173. than that of "LIST..LFORMAT (and pre-dates it by about three years!),
  174. among other things allowing specifiers for directory-path separate
  175. from the filename.
  176.  
  177.     For example, for taking quick looks at a bunch of files, I have a
  178.     script that does something like this (although in fact it also
  179.     pops up a new full-screen window to do it in, and uses a PIPE:):
  180.  
  181.             .K filepat/A
  182.             MAT >T:_mm T "more ^P" F <filepat>
  183.             execute T:_mm
  184.  
  185.     "^P" represents a complete pathname, and the keyword "F" (or "FILES")
  186.     says that the file names (specified in the filepat argument) are to be
  187.     used themselves, rather than be scanned.
  188.  
  189.     The preceding example is similar to the "DPAT" script that comes with
  190.     1.3, but you can do other things, too.  Suppose (and I have actually
  191.     been in this situation) that I have a bunch of files that I have
  192.     previously renamed to "myfile.c_0", "myfile.o_0", "myfile_0" and so
  193.     on, which I now want to restore to their former names by chopping off
  194.     th "_0".  I have a script that calls Mat in a similar way to the
  195.     above, and does just what I want:
  196.  
  197.             REN myfile#?^_0 AS ^0
  198.  
  199.     The first argument to the script is a pattern to select the files
  200.     to be renamed, and the second is the template specification of the
  201.     new names.  Notice the "slice-mark" '^' in the pattern, and the
  202.     marker "^0" (meaning the part to the left of the slice) in the
  203.     template.  Without bothering to detail the script, the core is a
  204.     Mat command line that creates appropriate "RENAME" commands to be
  205.     executed.
  206.  
  207.  
  208. In most cases you will want to have Mat embedded in script files, as this
  209. can drastically simplify the otherwise sometimes complex syntax.  Mat, by
  210. the way, returns a "WARN" value (5) to AmigaDOS if no match was found --
  211. useful for conditional execution in scripts.
  212.  
  213. This has only been a brief sketch of the various modes and so on that the
  214. program has.  It is worth bearing in mind though that it has a number of
  215. features -- including the possibility of accepting commands from a script
  216. file or pipe -- that add to its usefulness in things like installation
  217. scripts.  These features also let it work well with ARexx (even though it
  218. doesn't itself have an ARexx port).
  219.  
  220.  
  221. The following sections go into more detail about Mat's capabilities.
  222. First the command line formats and operating modes are described, then
  223. the keywords are listed in detail.  Following this is a full description
  224. of AmigaDOS-type patterns in general, and the extensions used in Mat.
  225. Finally comes a discussion of Templates and File Specifiers.
  226.  
  227.                             +  +  +  +  +
  228.  
  229. Installation and Operation
  230. __________________________
  231.  
  232. Mat is like any other CLI/Shell command, and is invoked by a command line
  233. with suitable arguments.  For normal use it should be available in the
  234. C: directory (or at least on the path of the current shell).  For added
  235. speed (under AmigaDOS 1.3 or later) it may be made Resident.
  236.  
  237.  
  238. Command Line Arguments
  239. ______________________
  240.  
  241.     There are a number of basic command forms corresponding to the various
  242.     operations Mat can perform.  Each of these in turn can have variants,
  243.     and they can often be combined to achieve a particular result.  There
  244.     are several common basic components, however, which first need clear
  245.     understanding.
  246.  
  247.     In the order they normally appear in the command line, from left to
  248.     right, they are: <Search-String>, <Pattern>, <Template>, and <Name-Spec>.
  249.     Only the last of these is invariably present; the other three MAY all
  250.     appear, but quite usually don't.  Keywords precede each where necessary
  251.     to identify them, and other keywords may be interspersed to give
  252.     further control.
  253.  
  254. <Search-String>:    A literal string of characters that will be searched
  255.                     for in a text file.  Any line that contains the string
  256.     as a substring is considered to match.  No characters in the string
  257.     will get special treatment -- there are no "wild-cards" or such.
  258.     Matches must be exact, with upper and lower case distinct, unless the
  259.     NOCASE keyword is used.  Search-Strings are only used in text searches,
  260.     not in filename or key matching.  A Search-String must be identified by
  261.     the required keyword "SEARCH" or its abbreviation "S".
  262.  
  263. <Pattern>:          An AmigaDOS-type pattern specifier string, usually
  264.                     containing "pattern-structuring" characters with
  265.     special meaning.  (See the section on "Pattern Matching" later.)  It is
  266.     always matched against the whole target of concern (a line of text,
  267.     filename, or argument).  Again, case is relevant unless NOCASE is used.
  268.     If a pattern is the first argument on the command line it does not need
  269.     a keyword (as it is the default) but if it is elsewhere -- following a
  270.     Search-String for example -- it must be preceded by "PAT" or "P".  (You
  271.     would also have use the keyword in the remotely possible case that the
  272.     pattern was itself identical to another keyword.)
  273.  
  274. <Template>:         A string, usually containing "template markers",
  275.                     that directs the program as to the output it is to
  276.     generate for each matching -- and possibly non-matching item. (See the
  277.     section on "Templates".)  If it is absent, the output depends on the
  278.     mode: during a text search each matching target is simply output in its
  279.     entirety; when matching filenames or keys there is no output at all
  280.     without a template.  If a Template string immediately follows an
  281.     initial Pattern argument that REQUIRES a template (i.e. it has
  282.     slice-marks), no keyword is needed, but it is probably best to use one
  283.     anyway; it is of course "TEMPLATE" or just "T".
  284.  
  285. <Name-Spec>:        Either a simple string or a pattern that defines
  286.                     the entities to be examined.  There may be several on
  287.     one command line.  In the Text-Searching modes, it indicates a file or
  288.     group of files to be scanned (referred to as a <File-Spec> below).  For
  289.     Directory Searching, it will normally be the actual search pattern to
  290.     match.  It may also represent a "key" (such as a command script
  291.     argument) that is to be tested directly against a Pattern.  There is no
  292.     specific associated keyword, but preceding mode-selection arguments may
  293.     determine the meaning.  For searching text files, no keyword is usually
  294.     needed, as this is the default, but you may occasionally have to supply
  295.     one to prevent ambiguity (a file name the same as a keyword, for
  296.     example); if you do, the word is "FROM".  To select Directory
  297.     Searching, you use one of: "FILES" (or "F") -- to search only for files
  298.     (not directories) --; "DIRS" ("D") -- to retrieve only directory names
  299.     that match --; or "NAMES" ("N") -- to match both.  To match the
  300.     arguments themselves use "KEY" ("K").
  301.  
  302.     Not all keywords have abbreviations by the way -- only some of the
  303.     frequent, non-ambiguous ones.  All may be given in upper or lower case,
  304.     however.  If any of the above items have embedded spaces, they must of
  305.     course be enclosed in quotes (which will be stripped off before they
  306.     are used).
  307.  
  308.  
  309.  
  310. Operating Modes
  311. _______________
  312.  
  313. Text Search:
  314.  
  315.     The default function of Mat is to search text files for lines that
  316.     match a pattern:
  317.  
  318.             MAT <Pattern> <Name-Spec>...
  319.  
  320.     All lines that match are written to standard output (the screen,
  321.     normally). For details on patterns, including the Mat extensions and
  322.     the possibilities of "slicing" the matched string for use by a
  323.     template, see the section on "Pattern Matching".
  324.  
  325.  
  326.     To perform a string search rather than a pattern match, the form is:
  327.  
  328.             MAT SEARCH <Search-String> <Name-Spec>...
  329.         or
  330.             MAT S <Search-String> <Name-Spec>...
  331.  
  332.  
  333.     You can also combine string search and pattern match:
  334.  
  335.             MAT S <Search-String> P <Pattern> <Name-Spec>...
  336.  
  337.     If both a Search-String and a Pattern are specified in the command
  338.     line, each line of the text file will be tested for the presence of the
  339.     string first, and only if that succeeds will the pattern be applied.
  340.     In situations where this can be done, pattern matching is hardly slower
  341.     than the string search alone.
  342.  
  343.  
  344.     With the above forms, you can control the text output with a template
  345.     (see the section on "Templates" for full details):
  346.  
  347.             MAT <Pattern> TEMPLATE <Template> <Name-Spec>...
  348.             MAT <Pattern> T <Template> <Name-Spec>...
  349.             MAT S <Search-String> T <Template> <Name-Spec>...
  350.  
  351.     In the particular case where a pattern has slice marks (see "Pattern
  352.     Matching"), and therefore requires a template, the keyword is optional
  353.     -- provided that the template argument is in the correct place:
  354.  
  355.             MAT <Slice-Pattern> <Template> <Name-Spec>...
  356.  
  357.  
  358. Directory Search:
  359.  
  360.     When searching directories for matching names, a template is normally
  361.     expected:
  362.  
  363.             MAT NAMES <Template> <Name-Spec>...
  364.             MAT NAMES T <Template> <Name-Spec>...
  365.             MAT N T <Template> <Name-Spec>...
  366.  
  367.     The "TEMPLATE" keyword is optional with this precise form, but required
  368.     for others. For example, a separate pattern (in addition to the one in
  369.     the Name-Spec) is sometimes useful (to further subdivide the set of
  370.     found files for template formatting):
  371.  
  372.             MAT <Pattern> T <Template> NAMES <Name-Spec>...
  373.  
  374.     The template itself however is not optional.  If you really want no
  375.     template (so nothing will be sent to the output for matches, you must
  376.     specify it as a null string; for example:
  377.  
  378.             MAT NAMES "" <Name-Spec>...
  379.  
  380.     The NAMES form locates all matching entries, both file and directory.
  381.     The equivalent forms to find just one or the other are:
  382.  
  383.             MAT FILES <Template> <Name-Spec>...
  384.             MAT F <Template> <Name-Spec>...
  385.             MAT DIRS <Template> <Name-Spec>...
  386.             MAT D <Template> <Name-Spec>...
  387.  
  388.  
  389. Other Modes:
  390.  
  391.     You can check the arguments in the command line -- probably themselves
  392.     supplied as arguments to an execute script -- against a pattern:
  393.  
  394.             MAT <Pattern> KEY <Name-Spec>...
  395.             MAT <Pattern> K <Name-Spec>...
  396.  
  397.     Without a template, the KEY form simply checks for a match, and returns
  398.     WARN to AmigaDOS if it doesn't find one.  No output is generated.  Add
  399.     a template to get the desired output:
  400.  
  401.             MAT <Pattern> K T <Template> <Name-Spec>...
  402.  
  403.     A final mode simply writes all files that match the Name-Spec to
  404.     standard output in sequence.  No processing of the files is done --
  405.     they needn't even be text:
  406.  
  407.             MAT JOIN <Name-Spec>...
  408.  
  409.     You can however supply a Tag-template (see sections on "Keywords" and
  410.     "Templates") that will be output for each file. The 'success' portion
  411.     will be written BEFORE the file, the 'fail' part AFTER it; either part
  412.     may be omitted.  Labels are also valid in a JOIN command line.
  413.  
  414.  
  415.  
  416. Value returned to the CLI:
  417. _________________________
  418.  
  419.     When Mat returns to the CLI or Shell, it passes back a value of zero if
  420.     it has found at least one match.  If it has found no matches at all it
  421.     returns a "WARN" value of 5.  This happens in all modes, and can be
  422.     tested within a command script to see if the intended operation has
  423.     been successful.  If you should just want to know if a match exists,
  424.     without needing to see any output, you can simply redirect this to
  425.     NIL:.
  426.  
  427.     If Mat encounters an error which prevents it from continuing, like an
  428.     incorrectly formed pattern, it will return at once with an error code
  429.     of 20.
  430.  
  431.  
  432. Keywords:
  433. ________
  434.  
  435.     Aside from the mode selecting keywords discussed above, there are
  436.     a number used to control other features.  Some of these take arguments
  437.     ("SEARCH", "PAT", and "TEMPLATE" being examples we've already met).
  438.  
  439.     In general, keywords can be placed either at the beginning of the line,
  440.     or at any appropriate later point, as long as they don't separate a
  441.     keyword and its argument.  The exact effect may depend on where on the
  442.     command line they are placed; in many situations you could have several
  443.     interspersed along the line.  Mat always processes the command arguments
  444.     in sequence, from left to right (unlike the position independent
  445.     keywords of AmigaDOS commands).  All keywords may be in upper or lower
  446.     case.  When so specified, they may be abbreviated to their first letter.
  447.  
  448.     To summarize the mode selection keywords already mentioned:
  449.  
  450.         FILES   -- searches for matching filenames
  451.         DIRS    -- searches for matching directory names
  452.         NAMES   -- searches for both files and directories
  453.         KEY     -- checks the command line for matches
  454.         JOIN    -- sequentially copies all matching files to the output
  455.  
  456.     All the above may be abbreviated to their first letter.
  457.     You may change modes within a command line if for some reason you need
  458.     to.  The change takes place at the point the keyword is encountered.
  459.  
  460.     These component specifiers have also been mentioned:
  461.  
  462.         FROM <Name-Spec>    -- sets text search mode and specifies
  463.                             that the following argument is a Name-Spec
  464.                             (No abbreviation).  Rarely needed.
  465.         SEARCH <Search-String>
  466.                             -- declares its argument to be a string
  467.                             for quick scanning of following text files
  468.                             (abbreviation "S").
  469.         PAT <Pattern>       -- specifies that its following argument
  470.                             is a pattern (abbreviation "P").
  471.         TEMPLATE <Template> -- specifies that its following argument
  472.                             is a template (abbreviation "T").  The
  473.                             template string may be null ("") to cancel
  474.                             any previous template, or satisfy the
  475.                             Directory Search's requirement for one.
  476.  
  477.     Only one Search-String, one Pattern and one Template may be active
  478.     at any time.  You can change any of them at any point in the command
  479.     line, though, replacing the old ones.
  480.  
  481.     There are two other keywords that also take a template form argument:
  482.  
  483.         TAG <Template>      -- defines a "tag" (for text file modes only)
  484.                             that will be output at most once for each file.
  485.         The 'success' portion of the template (see the "Templates" section)
  486.         will be output immediately before the first match found in the file;
  487.         the 'failure' part will be output if no match is found by the end
  488.         of the file.  Note that this applies even if non-matching lines
  489.         are being output (by a 'fail' part of the line template)!  Non
  490.         matching lines before the first match will also appear BEFORE
  491.         the tag.  Some of the selectors that are available for a line
  492.         template (such as slices) are not so appropriate within a tag
  493.         template; they will be ignored if used.  Declaring a new tag
  494.         replaces any previous one; only one may be active at a time.
  495.  
  496.         LABEL <Template>    -- outputs a "label" at the point it is
  497.                                encountered in the command line.  There
  498.         are the same restrictions on available template selectors as for
  499.         tags.  If no "fail" part is supplied, the label will be output
  500.         unconditionally; if you do supply a fail part (after "^|"), the
  501.         "success" part preceding the divider will only be output if there
  502.         has been at least one match to that point, otherwise the fail
  503.         part will be output.
  504.  
  505.     No abbreviations are provided for either of the previous or any of the
  506.     remaining keywords.
  507.  
  508.     The following subsidiary mode controls can be put anywhere appropriate
  509.     on the command line:
  510.  
  511.         NOCASE      -- causes all subsequent searches to ignore the case of
  512.                     pattern and text characters.  It can be put anywhere in
  513.         the command line subject to the above restrictions; file specifiers
  514.         appearing before it will not be affected.
  515.  
  516.         CASE        -- cancels the effect of a previous NOCASE.
  517.  
  518.         FIRST       -- is only appropriate in text matching modes.  It
  519.                     causes the search of each file after it on the command
  520.         line to terminate when the first match is found. It is useful when
  521.         you just want to determine which files contain a pattern, rather
  522.         than listing every occurrence.  It is compatible with templates and
  523.         other options.
  524.  
  525.         ALL         -- reverses the effect of FIRST if you should need to
  526.                     do so within a command line.
  527.  
  528.         NOLINES     -- prevents the usual newline character being output
  529.                     after each match.  All subsequent matches will be shown
  530.         on the same line unless the template dictates otherwise.  Don't
  531.         forget that you will usually want some sort of separator in the
  532.         template, such as a space.  It can be used in any mode.
  533.  
  534.         LINE        -- reverses the effect of NOLINES if this has been
  535.                     given previously. (Apologies for the plural/singular
  536.         disparity, but it isn't quite the inverse.)  It also inserts a
  537.         newline into the output at that point; you can use it just for this
  538.         if you want an extra blank line between file specifiers.
  539.  
  540.         ZERO        -- resets the item and match counters (available for
  541.                     templates) to zero.  Has no other effect on the state.
  542.  
  543.         RESET       -- sets the system back to the initialized state:
  544.                     pattern, template, and tag are cleared, and the
  545.         counters are zeroed.  Only the internal success flag (that
  546.         controls the value returned to AmigaDOS) is left unchanged.
  547.         This option is intended for command script use (see below);
  548.         you are not likely to need it on a command line.
  549.  
  550.  
  551.     Two keywords can be used to control input and output channels.  Each
  552.     takes a single Filename argument (NOT a pattern!):
  553.  
  554.         OUT <File>  -- diverts future output to the named file (or
  555.                     device).  Any existing file of that name is deleted.
  556.         Any previously selected destination will be closed (except
  557.         standard output of course).
  558.  
  559.         OUT -       -- (a single dash as the argument)  closes any
  560.                     currently selected output file and restores standard
  561.         output (the screen, unless AmigaDOS redirection has also been
  562.         used).
  563.  
  564.         WITH <File> -- reads control commands from <File> instead of
  565.                     the command line.  All keywords and argument types
  566.         are valid in a script, but NOTHING is reset at the end of a line.
  567.         (Don't break a line between a keyword and its argument, though!)
  568.         The RESET keyword must be included when you need to clear the
  569.         decks.  When the end of the script is reached, control returns
  570.         to any further arguments on the command line.  As with a CLI
  571.         command line, anything after a semicolon on a line is ignored:
  572.         you may comment your scripts.
  573.  
  574.  
  575.                             +  +  +  +  +
  576.  
  577.  
  578. Pattern Matching
  579. ________________
  580.  
  581.  
  582.     The pattern matching algorithm used by Mat is an extension of the
  583. standard file pattern matching scheme used by AmigaDOS.  Many people may
  584. not appreciate how general and flexible the method is.  It is many times
  585. more capable than the simple "wild-card" matching available on most
  586. personal computers.  There are some things that the standard algorithm
  587. doesn't have which would often be useful, and I have done my best to supply
  588. some of these in this extended version.
  589.  
  590.     The discussion that follows may be a fuller exposition of how to use
  591. pattern matching than is available from other sources.  If you leave out
  592. references to the "universal-match" character "*", "negation matches", and
  593. "slicing", everything discussed applies just as well to standard AmigaDOS
  594. patterns, which can be used in commands like LIST, DELETE, and COPY.
  595.  
  596.     A pattern is a text string constructed from "plain characters" and
  597. "special characters".  It represents a set (possibly a large set) of text
  598. strings that will match it.  Remember that it always matches complete
  599. strings; this is not the same as a simple text search, where a match is
  600. signalled if the search string is found anywhere within the source text.
  601. The string being matched by the pattern is always "bounded" in some way,
  602. either because it stands alone -- like a file name -- or because, say, it
  603. is a complete line of text.  The newline character at the end is not
  604. usually available to the matching process.
  605.  
  606.     If a pattern argument in a command line contains spaces, it must of
  607. course be enclosed in quotes.  There is no way of including quotes in a
  608. pattern which is itself enclosed in quotes, unfortunately, (because of the
  609. way C handles argument strings).
  610.  
  611.     The syntax of the pattern structure is such that complex patterns can
  612. be built from simple ones.  Broadly speaking, patterns may be chained end
  613. to end so that successive segments of a complete target string may be
  614. matched by successive segments of the pattern.  In addition, each pattern
  615. segment can specify "alternatives": if any of these match, the whole
  616. segment matches.
  617.  
  618. Plain Characters:
  619.  
  620.     The simplest pattern is a string of plain characters.  This will only
  621.     match a target string consisting of exactly the same characters in the
  622.     same order, which is obviously of limited usefulness.  The only case
  623.     where you are likely to want this is when getting a particular file
  624.     name, and the program is smart enough to go directly to the file in
  625.     this case rather than doing a search.
  626.  
  627.  
  628. Special Characters:
  629.  
  630.     To build more general patterns we need the special characters. These do
  631.     not represent themselves (unless special action is taken): they are
  632.     instead structural elements that form the structure of the patterns we
  633.     desire. Using them we can build patterns -- or subpatterns -- that will
  634.     match, say, any single character, any five characters, any arbitrary
  635.     string, or a string that is one of several possible specific
  636.     alternatives. We can then put such subpatterns together to end up with
  637.     a complete pattern that will match all the various possibilities we are
  638.     looking for and no others.  The possibilities should become clearer as
  639.     we get to specific examples.
  640.  
  641.  
  642.     The seven special characters used in AmigaDOS file matching are:
  643.  
  644.             '  ?  |  (  )  #  and  %
  645.  
  646.     To these Mat adds two more:
  647.  
  648.             ~ and ^
  649.  
  650.     We'll look at them briefly in order, before we get into a fuller
  651.     exploration:
  652.  
  653.     " ' " makes the character following it into a plain character.
  654.     " ? " matches ANY single character.
  655.     " | " separates alternative patterns.
  656.     " ( " and " ) " enclose patterns used in building larger ones.
  657.     " # " causes a match to any number of repetitions of the pattern
  658.           it precedes.
  659.     " % " matches the null string when syntactically necessary.
  660.  
  661.     " ~ " is one way (of two) of sprecifying negation.
  662.     " ^ " slices a matched string into segments.
  663.  
  664.  
  665. Quoting Characters:
  666.  
  667.     The single quote (" ' ") is used to turn any special character
  668.     immediately following it into a plain character.  Thus to match against
  669.     an actual question mark in a target text you would include the pair
  670.     " '? " in the pattern.  And of course it can quote itself.
  671.  
  672.  
  673. Matching Any Character:
  674.  
  675.     The question mark matches ANY single character. Thus:
  676.  
  677.         ???
  678.  
  679.     matches "abc", "xyz", and so on, but not "ab" or "abcd".
  680.  
  681.  
  682. Matching Alternatives:
  683.  
  684.     The vertical bar (" | ") separates "alternatives".  If any of a set of
  685.     patterns separated by bars matches the target, the match is successful.
  686.     For example:
  687.  
  688.             abc|def|qwertyuiop
  689.  
  690.     would match any of those three strings, but no others.
  691.     The pattern
  692.  
  693.             abc|x?z
  694.  
  695.     would match "abc" or "x" and "z" separated by any single character.
  696.  
  697.  
  698. Building Patterns from Others:
  699.  
  700.     The left and right parentheses can be used to enclose a pattern that
  701.     you want to match as a unit when it is part of a larger pattern. As one
  702.     example we could look for any two characters followed by "abc" or "def"
  703.     with the pattern:
  704.  
  705.             ??(abc|def)
  706.  
  707.     Combine two or more patterns in sequence this way:
  708.  
  709.             (abc|def)(xxx|yyy)
  710.  
  711.     This will match "abcxxx", "abcyyy", "defxxx", and "defyyy".
  712.  
  713.     Patterns can be nested as far as you like with parentheses:
  714.  
  715.             a(bc|??(xx|yy))d
  716.  
  717.     will match "abcd", or any six-letter group beginning with "a" and
  718.     ending in "xxd" or "yyd".
  719.  
  720.     Redundant parentheses do no harm.  They may be useful to distinguish
  721.     patterns from other constructs.
  722.  
  723.  
  724. Pattern Repetition:
  725.  
  726.     The " # " character is always followed by a (sub)pattern. It will match
  727.     ANY number of (exact) repetitions of that pattern (INLUDING zero). The
  728.     pattern may be a single letter, but if it isn't it must be enclosed in
  729.     parentheses.  Thus:
  730.  
  731.             #(ab)
  732.  
  733.     matches "ab", "abababab", or simply an empty string.  It does not match
  734.     "ababa".
  735.  
  736.     Ther pattern to be repeated may be any legal pattern, including more
  737.     repetition constructs if you want:
  738.  
  739.             #(ab|?x|#(xy)z)
  740.  
  741.     will match such strings as "abab", "zxab", "qxxyxyxyxyzxyab", and so
  742.     on.  It will NOT match "abxy".
  743.  
  744.  
  745. Matching the Empty String:
  746.  
  747.     The " % " character is used where you have to specify an empty ("null")
  748.     string -- normally as one of a number of alternatives.  The
  749.     construction
  750.  
  751.             (|abc)
  752.  
  753.     is not legal; instead you must use:
  754.  
  755.             (%|abc)
  756.  
  757.     which will match either "abc" or the null string.
  758.  
  759.  
  760.  
  761. Negated Matching:
  762.  
  763.     Mat extends the basic pattern matching syntax by allowing you to
  764.     specify patterns that if matched will cause the overall match to fail.
  765.     If a negated segment is included in a pattern, and the target string
  766.     has ANY POSSIBLE match of the whole pattern that includes that segment,
  767.     the match cannot succeed.  There are restrictions on negation patterns
  768.     not shared by the structures we've talked about up to now; in
  769.     particular they can't be nested -- you can't negate a negation --
  770.     although they can be inserted at any level in the pattern.
  771.  
  772.     There are two ways of specifying negated patterns.  The first will
  773.     match ANY string UNLESS it exactly matches the pattern; it is
  774.     constructed by prefixing the pattern by the tilde (" ~ "):
  775.  
  776.             ab~(cd)e
  777.  
  778.     will not match "abcde", but will match any other string that begins
  779.     with "ab" and ends with "e", such as "abxxxe", "abe", "abce", etc..
  780.  
  781.     The second form is a "negated alternative", indicated by two adjacent
  782.     vertical bars (" || ").  This is used when, rather than matching ANY
  783.     string that is not the negated one, you have a set of patterns you want
  784.     to match UNLESS the negated part is also matched. Thus:
  785.  
  786.             a(b?d|?c?||bcd)
  787.  
  788.     will match four character strings such as "abxd", "accc", "abcx", as
  789.     long as the whole string is not "abcd".
  790.  
  791.     You can have more than one negated segment, as long as one does not
  792.     appear inside another.  Thus the following sort of thing is possible
  793.     (whether it's also useful though...?):
  794.  
  795.             a~bc~(de)(???||fgh||xyz)
  796.  
  797.     Remember that this will be forced to fail if there is any possible
  798.     match that includes a negated section.  Thus these will succeed:
  799.  
  800.             acxxx
  801.             abbbcddeabc
  802.             acdexy
  803.  
  804.     and these will fail:
  805.  
  806.             abcxxx
  807.             abbcdexxx
  808.             aczxsdefrgthcjxsxcxyz
  809.  
  810.     To stress it once again, a negated match is "aggressive": if there
  811.     is ANY possible match that includes a negated section, the whole
  812.     match will fail.
  813.  
  814.  
  815. Slicing the Matched String:
  816.  
  817.     You can include "slice marks" (the caret -- " ^ ") in your pattern to
  818.     select out pieces of the matched string that can be treated individually.
  819.     Mat will arrange these "slices" in a manner specified by a template
  820.     (next section), to generate desired output.
  821.  
  822.     Once again there is a restriction on the use of this character that
  823.     does not apply to the others:  only the first four of these marks
  824.     encountered during a match will be recorded; any after this will be
  825.     ignored.  Note that this doesn't mean you can only include a maximum of
  826.     four marks; if they are inside alternatives that don't match any part
  827.     of the target string, the scan will never encounter them.  You should
  828.     be sure of what you are doing, though, if you don't want to be
  829.     surprised by the program's choices.  We'll return to this, and some
  830.     other points you should note about the behaviour of slice marks, later.
  831.  
  832.     If there is more than one possible match of the pattern to the target,
  833.     the slice will be made at the earliest possible point.  Remember this
  834.     especially when you have repetitions in your pattern.
  835.  
  836.     Examples:
  837.  
  838.         The pattern         #?^x#?
  839.          will cut            abcdxyz
  840.          into                abcd xyz
  841.  
  842.          It will also cut    abcxxxx
  843.          into                abc xxxx
  844.  
  845.         The pattern         #?^x#?y^#?
  846.          will cut            abcxxxxyz
  847.          into                abc xxxxy z
  848.  
  849.         The pattern         #?^#x^#?
  850.          won't cut much of anything! (because "#x" also matches the null
  851.          string.)  The first two slices will simply always be empty, and
  852.          slice three will contain the whole string.
  853.  
  854.         The pattern         #?^(word|another)^#?
  855.          will cut            "here is another word for you"
  856.          into                "here is"  "another"  "word for you"
  857.          (using quotes in this case to mark off the slices).  Notice that
  858.          the cuts are made around "another" rather than "word" because the
  859.          earliest match is found.
  860.  
  861.     Slice marks within alternatives can be used, as noted above, but are
  862.     tricky. Because of the way the marks are recorded internally, if two
  863.     different alternatives containing them match, both marks will be
  864.     reported but the position of one of them will be wrong (probably at the
  865.     beginning of the string).  So it is best to keep the slice marks
  866.     outside of any alternation constructions (as shown in the last example
  867.     above).
  868.  
  869.     Be careful using negation with slice marks.  As noted above, any
  870.     match with the negated section causes the whole match to fail: it
  871.     does not try to find another match.  Therefore you can't use a
  872.     negation to force a slice mark to be in a different place.  In
  873.     general there are some limitations such as these which may prevent
  874.     you from cutting up strings exactly the way you want (chopping out
  875.     variable spaces can be very awkward for example).
  876.  
  877.  
  878. Templates
  879. _________
  880.  
  881.     The Templates Mat uses to generate output lines are basically simple
  882. text strings with "splice-markers" and other "selectors" that indicate
  883. where the pieces of the matched string and other items are to be inserted.
  884. The text segments of a template can be anything you want (except a newline
  885. -- there is a selector for this).  A special marker can be used to divide
  886. the template string into "success" and "fail" halves; the "success" part
  887. controls the format of output lines for matches, while the "fail" part will
  888. be output for each input string that doesn't match. Output strings are
  889. always terminated with a newline, unless the NOLINES option is in effect.
  890.  
  891. You can cancel an existing template by supplying a null string ( "" ).  Any
  892. current Tag may be cancelled in the same way.  The effect is slightly
  893. different in Directory Search mode: this normally EXPECTS a template to
  894. control the output (and you can't simply omit it), but you can defeat the
  895. requirement by supplying a null template, in which case matches will
  896. produce no output.
  897.  
  898.     Each marker (or selector -- the terms will be used interchangeably) is
  899. a character pair: the caret (" ^ ") followed by a selector character.
  900. Slices from the matched string are numbered -- "^0" to "^4" .  Other items
  901. have identifying letters, such as "^N" for line number; the case of these
  902. letters is important (all are currently upper case because you are already
  903. holding down the shift key for the caret). The success/fail divider uses
  904. the vertical bar: "^|".
  905.  
  906. Not all selectors are valid, or at least have exactly the same meaning,
  907. under all conditions.  For example you can't use slices from a matched line
  908. in the "fail" section of a template because -- obviously -- there aren't
  909. any.  Then, "line numbers" naturally only apply in text matching, but in
  910. file name matching mode the same selector (^N) keeps track of the number of
  911. files encountered.  If you use a selector that is not valid it is simply
  912. skipped over.  Of course you can use any selector more than once within a
  913. template.
  914.  
  915.     If a template argument in a command line contains spaces, it must of
  916. course be enclosed in quotes.  As with a pattern, you can't include quotes
  917. in a template which is itself enclosed in quotes: use the "^Q" selector
  918. instead.  You can include a caret character in the output string (if, for
  919. example you are generating a new Mat command in a script) by the pair "^^".
  920.  
  921.  
  922. Slice Selectors:
  923.  
  924.     As four slice marks are allowed in a pattern, there can be a maximum of
  925.     five slices of the matched string.  These are selected by "^0" for the
  926.     piece from the beginning of the string to the first mark, "^1" for the
  927.     piece between the first and second, up to "^4" for the remainder of the
  928.     string beyond the fourth mark.  If there are fewer than four slice
  929.     marks, the slice associated with the final existing mark extends to the
  930.     end of the string, and all higher-number pieces are empty.  Thus if
  931.     there are only two marks, "^2" covers the remainder of the string, and
  932.     "^3" and "^4" are empty.
  933.  
  934.     For instance, if we use this pattern, with two slice marks:
  935.  
  936.             #?^word ^#?
  937.  
  938.     and this template -- which will omit slice 1:
  939.  
  940.             ^0^2
  941.  
  942.     to match and rearrange the string:
  943.  
  944.             "this word will be missing"
  945.  
  946.     we will end up with:
  947.  
  948.             "this will be missing"
  949.  
  950.     Slice marks are only appropriate to match-templates.  They are
  951.     ignored by 'fail' templates (see below) and in Tags and Labels.
  952.  
  953.  
  954. Line Number Selector:
  955.  
  956.     The marker "^N" placed in a template string will insert the current
  957.     line Number within the file being scanned at that point into the output
  958.     string. It can be used in both "success" and "fail" portions of a
  959.     template.  In tags and labels it will represent the lines read to that
  960.     point.  If used in Directory Search or Argument Scanning modes, it
  961.     represents the total number of items scanned to that point; it is not
  962.     automatically reset in these modes (use ZERO to do so)..
  963.  
  964.     So the pattern                      #?^(word|another)^#?
  965.      and template                       ^N: ^1
  966.      would generate something like      234: another
  967.  
  968.  
  969. Index Number Selector:
  970.  
  971.     The pair "^I" inserts an Index number representing a count of matches
  972.     so far. The count is kept from the beginning of the program, and is not
  973.     reset with a new file (use ZERO to do so).  You may use it in the "fail"
  974.     section of a template, also in tags and labels, but remember it will
  975.     indicate the number of matches, not lines output.
  976.  
  977.     "^I" also works in Directory or Argument Search mode.  If no pattern
  978.     (aside from the file specifiers themselves) is supplied in these modes,
  979.     it will have the same value as "^N", but you can also match the total
  980.     set of files found against a Pattern argument, in which case "^I" will
  981.     reflect these matches rather than total files.
  982.  
  983.  
  984. Original String Selector:
  985.  
  986.     The pair "^O" ("Oh", not "zero" -- I probably should have chosen a
  987.     better one...) represents the unsliced Original string.  It can be used
  988.     in both the "success" and "fail" parts of a template.  Thus, to simply
  989.     put a line number in front of each matched line, you could use the
  990.     template:
  991.  
  992.             ^N: ^O
  993.  
  994.     In File Matching mode, this selector is the same as "^F" (below); in
  995.     Argument Matching it represents the current argument. It is a null
  996.     string for tags and labels in all cases.
  997.  
  998.  
  999. Line Break Selector:
  1000.  
  1001.     The pair "^B" Breaks the output line at that point with a newline
  1002.     character.  For instance, to output line number and slice-1 on one
  1003.     line, followed by the original string on a new line, you would use:
  1004.  
  1005.             ^N: ^1^B^O
  1006.  
  1007.  
  1008. Quote Mark Selector:
  1009.  
  1010.     It is not usually possible to embed quote marks in template strings
  1011.     directly, so you can use the selector "^Q" to make them appear at that
  1012.     point in the output line.
  1013.  
  1014.             ^0 ^Q^1^Q ^2
  1015.  
  1016.  
  1017. File Name Selector:
  1018.  
  1019.     "^F" selects the local name of the current File (i.e without any
  1020.     directory prefix), in both text and file name matching modes.  (Only
  1021.     in Argument Match is it a null string.)
  1022.  
  1023.     For example, if you have a filename specifier argument (see later)
  1024.  
  1025.             :work#?/#?.txt
  1026.  
  1027.     which has found the file
  1028.  
  1029.             Work Disk:work_1/sample.txt
  1030.  
  1031.     the "^F" selector will insert
  1032.  
  1033.             sample.txt
  1034.  
  1035.     If the item referenced by the specifier is a Device (such as a PIPE:)
  1036.     rather than a file, "^F" will return the FULL name as specified
  1037.     (pattern specifiers will never find devices, anyway). Thus the
  1038.     specifier:
  1039.  
  1040.             PIPE:xyz
  1041.  
  1042.     simply returns:
  1043.  
  1044.             PIPE:xyz
  1045.  
  1046.     Warning: if the found object is a directory AND is a root device (e.g.
  1047.     "DF0" or "DF1:") the Filename is the full name of that disk but WITHOUT
  1048.     the terminating colon! (but the Full Pathname (below) is correct).
  1049.  
  1050.  
  1051.  
  1052. Full Pathname Selector:
  1053.  
  1054.     "^P" represents the FULL pathname (from the parent device) of the
  1055.     file. Thus for the immediately preceding example, it would supply:
  1056.  
  1057.             Work Disk:work_1/sample.txt
  1058.  
  1059.  
  1060. Directory Path Selector:
  1061.  
  1062.     "^D" in a template will insert the full path to the Directory of the
  1063.     current file.  Thus for the above file, ^D would insert:
  1064.  
  1065.             Work Disk:work_1
  1066.  
  1067.     If the object found is a Device rather than a file, this is a null
  1068.     string (but the Full Pathname (^P) will be the same as the Filename
  1069.     (^F) -- see above).  It will also be a null string if the found object
  1070.     is a directory and the specifier was in the form of a "Device" or
  1071.     "Parent" reference -- in other words like "xyz:" or "/"; in this case,
  1072.     the Filename ^F is NOT the full pathname -- just the usual simple name
  1073.     string.
  1074.  
  1075.  
  1076. Literal Caret mark Selector:
  1077.  
  1078.     "^^" included in a template will generate a single caret mark in the
  1079.     output.
  1080.  
  1081.  
  1082. Failure Template Marker:
  1083.  
  1084.     A simple template is only applied to strings which have been matched,
  1085.     and nothing is output when there isn't a match.  You can split the
  1086.     template, however, into two subsections with the special success/fail
  1087.     division marker "^|".  The section preceding this mark is applied for a
  1088.     successful match just like a simple template; the section following it
  1089.     is used if the match fails. In the "fail" section, any selectors
  1090.     desired can be used, except the five slices "^0" - "^4".
  1091.  
  1092.     A simple use would be to output all lines, whether or not they matched,
  1093.     but mark or rearrange the matched lines in some way.  For example the
  1094.     following would output them all but put a flag and index number on
  1095.     each matched line (and corresponding blanks before an umatched one):
  1096.  
  1097.             MATCH[^I]> ^O^|             ^O
  1098.  
  1099.  
  1100.     A tag may be split with the same "^|" divider, in which case the
  1101.     success part will be output immediately before the first match as
  1102.     usual, but the fail part will only appear if there is no match in
  1103.     the file.  (In JOIN mode the behaviour is a little different: both
  1104.     parts will be output if present, 'success' before, and 'fail' after,
  1105.     each file.) In addition, the success part may be empty (the tag begins
  1106.     with the marker); in this particular case, ONLY the fail part will ever
  1107.     appear -- nothing, not even a newline, is output before the first
  1108.     match.
  1109.  
  1110.     This last does not apply to match-templates, where a newline will
  1111.     be written even when the success part is empty.  If you really want no
  1112.     output on matches, add the NOLINES keyword and place "^B" markers
  1113.     suitably where you DO want newlines.
  1114.  
  1115.  
  1116.  
  1117. File Specifiers
  1118. _______________
  1119.  
  1120.     The arguments in the command line you supply to specify the files that
  1121. Mat will examine are really just like those you might give to any AmigaDOS
  1122. command, but there are one or two extra features.
  1123.  
  1124.     For text file searches you will probably most often want to specify a
  1125. single file.  You do this in the usual way with either the local name of a
  1126. file in the same directory, or a path name that includes the chain of
  1127. directories needed to reach that file in another.  Unlike many other
  1128. programs that allow pattern matching in filenames, by the way, Mat is
  1129. perfectly happy with specific Device names (non filesystem), such as PIPEs
  1130. or the Serial Device.
  1131.  
  1132. In place of the simple file name, you can use a pattern to match a group of
  1133. files in the same directory.  Unlike other AmigaDOS commands this pattern
  1134. can employ the extended matching features described above ("*", "~", and
  1135. "||"). Slice marks can also be used where they are appropriate (see below).
  1136. As is usual in AmigaDOS, case is always ignored when searching for matching
  1137. filenames.
  1138.  
  1139.     You can also use patterns in the directory part of the specification,
  1140. in just the same way as in the filename part.  (Did you know that you can
  1141. also do this in most AmigaDOS commands supporting patterns, such as
  1142. DELETE?)  All the directories matching that specification will be searched
  1143. in turn. However, you cannot split a pattern across directories -- in other
  1144. words, a pattern must not include a device or directory separator (":" or
  1145. "/"). This means that a given pattern can only match directory names at a
  1146. certain "level" in the file hierarchy of the disk.  Also you cannot use a
  1147. pattern in a device specifier -- these must be simple names.  To search
  1148. more than one level, or more than one device, you must have more specifier
  1149. arguments.
  1150.  
  1151. In File Name Search mode, if you don't supply any other pattern, you may
  1152. put slice marks in the file name portion of the specifier.  You cannot
  1153. place them in the directory part.  Except in this particular situation
  1154. (no main pattern present), the program will ignore slices in the filename.
  1155.  
  1156.  
  1157. Examples:
  1158.  
  1159.     These are valid file specifiers:
  1160.  
  1161.             myfile.txt
  1162.             my#?file(.txt|_bak)
  1163.             df1:work/myfile
  1164.             :work/myfile
  1165.             /work/myfile
  1166.             :(work|old)/my^#?
  1167.  
  1168.     These are not:
  1169.  
  1170.             df(0|1):#?/#?           -- pattern in device part
  1171.             df1:/#(work/)myfile     -- pattern includes directory separator
  1172.             :w^#?/my^#?             -- slice mark in directory part
  1173.  
  1174.  
  1175.  
  1176.                             +  +  +  +  +
  1177.  
  1178.                                ========
  1179.  
  1180.  
  1181.  
  1182. Distribution and Copyrights
  1183. ___________________________
  1184.  
  1185.  
  1186.     Mat itself and this manual are copyright, but may be freely distributed
  1187. without charge.  Commercial use is prohibited without the express written
  1188. permission of the author.
  1189.  
  1190. No fee is asked for the non-commercial use of this program, but if one
  1191. day you're feeling generous...
  1192.  
  1193.  
  1194. Remarks and Suggestions to:
  1195.                                         Peter Goodeve
  1196.                                         3012 Deakin Street #D
  1197.                                         Berkeley, Calif. 94705
  1198.  
  1199.                             %%%%%%%%%%%%
  1200.  
  1201.