home *** CD-ROM | disk | FTP | other *** search
/ Tools en Utilities / CDASS_5.ISO / shell / util / parse260.arj / POM.INF < prev    next >
Encoding:
Text File  |  1995-01-01  |  45.4 KB  |  1,102 lines

  1.  
  2.     ===========================================================================
  3.     ===========================================================================
  4.     ============================                   ============================
  5.     ============================                   ============================
  6.     ============================   PARSE-O-MATIC   ============================
  7.     ============================                   ============================
  8.     ============================                   ============================
  9.     ===========================================================================
  10.     ===========================================================================
  11.     
  12.  
  13.  
  14.     ---------------------------------------------------------------------------
  15.     |                                                                         |
  16.     |        HERE ARE A FEW OF THE THINGS PARSE-O-MATIC CAN DO FOR YOU:       |
  17.     |                                                                         |
  18.     |      Importing             Exporting             Automated Editing      |
  19.     |      Text Extraction       Data Conversion       Table Lookup           |
  20.     |      Retabulation          Info Weeding          Selective Copying      |
  21.     |      Binary-File to Text   Report Reformatting   Wide-Text Folding      |
  22.     |      Auto-Batch Creation   Comm-log Trimming     Tab Replacement        |
  23.     |      Character Filtering   Column Switching      Time-Saving!           |
  24.     |                                                                         |
  25.     |      "Parse-O-Matic is a wonderful time saver .... Each report that     |
  26.     |      I can convert from our ... accounting system saves our company     |
  27.     |      about 500 man hours per year" -- R. Brooker (a happy POM user)     |
  28.     |                                                                         |
  29.     ---------------------------------------------------------------------------
  30.  
  31.  
  32.  
  33.                    Parse-O-Matic is Copyright (C) 1992, 1994 by:
  34.  
  35.            Pinnacle Software, CP 386 Mount Royal, Quebec, Canada H3P 3C6
  36.            U.S. Office: Box 714 Airport Road, Swanton, Vermont 05488 USA
  37.  
  38.            Support Line (514) 345-9578 --- Free Files BBS (514) 345-8654
  39.  
  40.  
  41.  
  42.     ---------------------------------------------------------------------------
  43.     |                                                                         |
  44.     |                                                                         |
  45.     |      This is a SHAREWARE product.  That means we would like you to      |
  46.     |      pass around unregistered copies to other people.  If you have      |
  47.     |      a modem, you can upload a copy to a local BBS, or give a copy      |
  48.     |      to a friend who will save time and effort with Parse-O-Matic.      |
  49.     |                                                                         |
  50.     |                                                                         |
  51.     ---------------------------------------------------------------------------
  52.                                                                                
  53.  
  54.  
  55.     ===========================================================================
  56.                                       OVERVIEW
  57.     ===========================================================================
  58.  
  59.  
  60.     This manual contains the following sections:
  61.  
  62.     INTRODUCTION
  63.     ------------
  64.     Why you need Parse-O-Matic -- an example
  65.     Parse-O-Matic to the rescue!
  66.     How it works
  67.  
  68.     FUNDAMENTALS
  69.     ------------
  70.     The Parse-O-Matic command
  71.     The POM file
  72.     Padding for clarity
  73.  
  74.     COMMAND WORDS
  75.     -------------
  76.     Command formats
  77.     The SET command
  78.     The IF command
  79.     The BEGIN and END commands
  80.     The OUT and OUTEND commands
  81.     The MINLEN command
  82.     The IGNORE command
  83.     The ACCEPT command
  84.     The TRIM command
  85.     The PAD command
  86.     The INSERT command
  87.     The CHANGE command
  88.     The SPLIT command
  89.     The CHOP command
  90.     The LOOKUP command
  91.     The LOOKFILE command
  92.     The LOOKCOLS command
  93.     The LOOKSPEC command
  94.  
  95.     TERMS AND TECHNIQUES
  96.     --------------------
  97.     Values
  98.     Delimiters
  99.     Illegal characters
  100.     Incrementing
  101.     Line counters
  102.     Tracing
  103.     Examples
  104.  
  105.  
  106.  
  107.     ===========================================================================
  108.                                     INTRODUCTION
  109.     ===========================================================================
  110.  
  111.  
  112.       Parse-O-Matic is a programmable file-parser. Simple enough for a non-
  113.       programmer to master, it can help out in countless ways. Here are some
  114.       of the things Parse-O-Matic can do: Importing, Exporting, Automated
  115.       Editing, Text Extraction, Data Conversion, Table Lookup, Retabulation,
  116.       Info Weeding, Selective Copying, Binary-File to Text, Tab Replacement,
  117.       Report Reformatting, Wide-Text Folding, Auto-Batch Creation, Character
  118.       Filtering, Column Switching and more!
  119.  
  120.  
  121.  
  122.                       ----------------------------------------
  123.                       WHY YOU NEED PARSE-O-MATIC -- AN EXAMPLE
  124.                       ----------------------------------------
  125.  
  126.     There are plenty of programs out there that have valuable data locked away
  127.     inside them.  How do you get that data OUT of one program and into another
  128.     one?
  129.  
  130.     Some programs provide a feature which "exports" a file into some kind of
  131.     generic format.  Perhaps the most popular of these formats is known as a
  132.     "comma-delimited file", which is a text file in which each data field is
  133.     separated by a comma.  Literal strings -- which might themselves contain
  134.     commas -- are surrounded by double quotes.  So a few lines from a
  135.     comma-delimited file might look something like this (an export from a
  136.     hypothetical database of people who owe your company money):
  137.  
  138.     +-------------------------------------------------------------------------+
  139.     |      "JONES","FRED","1234 GREEN AVENUE", "KANSAS CITY", "MO",293.64     |
  140.     |      "SMITH","JOHN","2343 OAK STREET","NEW YORK","NY",22.50             |
  141.     |      "WILLIAMS","JOSEPH","23 GARDEN CRESCENT","TORONTO","ON",16.99      |
  142.     +-------------------------------------------------------------------------+
  143.  
  144.     Unfortunately, not all programs export or import data in this format.
  145.     Even more frustrating is a program that exports data in a format that is
  146.     ALMOST what you need!
  147.  
  148.     If that's the case, you might decide to spend a few hours in a text editor,
  149.     modifying the export file so that the other program can understand it.  Or
  150.     you might write a program to do the editing for you. Both solutions are
  151.     time-consuming.
  152.  
  153.     An even more challenging problem arises when a program which has no export
  154.     capability does have the ability to "print" reports to a file.  You can
  155.     write a program to read these files and convert them to something you can
  156.     use, but this can be a LOT of work!
  157.  
  158.  
  159.  
  160.                             ----------------------------
  161.                             PARSE-O-MATIC TO THE RESCUE!
  162.                             ----------------------------
  163.  
  164.     Parse-O-Matic is a utility that interprets text and fixed-length files and
  165.     converts them to other formats.  It can help you "boil down" reports into
  166.     their essential data.  You can also use it to convert NEARLY compatible
  167.     file formats.
  168.  
  169.  
  170.                                     ------------
  171.                                     HOW IT WORKS
  172.                                     ------------
  173.  
  174.     You need three things:
  175.  
  176.     1) The Parse-O-Matic program
  177.     2) A Parse-O-Matic "POM" file (to tell Parse-O-Matic what to do)
  178.     3) The input file
  179.  
  180.     The input file is usually a report from another program, or a fixed record
  181.     length data file.  We've provided several examples of typical input files.
  182.     For example, the file EXAMPLE2.TXT comes from the AccPac accounting
  183.     software.  AccPac is a great program, but its export capabilities leave
  184.     something to be desired.  Parse-O-Matic can help!
  185.  
  186.  
  187.  
  188.     ===========================================================================
  189.                                     FUNDAMENTALS
  190.     ===========================================================================
  191.    
  192.  
  193.     This documentation assumes that you are an experienced computer user.  If
  194.     you have trouble, you might ask a programmer to help you -- POM file
  195.     creation is a little like programming!
  196.  
  197.  
  198.  
  199.                              -------------------------
  200.                              THE PARSE-O-MATIC COMMAND
  201.                              -------------------------
  202.  
  203.     The basic format of the Parse-O-Matic command line is:
  204.  
  205.         POM pom-file input-file output-file
  206.  
  207.     Here's an example, as you would type it at the DOS command line:
  208.  
  209.         POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  210.  
  211.     For a more formal description of the command line, start up POM by typing
  212.     this command at the DOS prompt:
  213.  
  214.         POM
  215.  
  216.                                     ------------
  217.                                     THE POM FILE
  218.                                     ------------
  219.  
  220.     The POM file is a text file with a .POM extension.  The following
  221.     conventions are used when interpreting the POM file:
  222.  
  223.     - Null lines and lines starting with a semi-colon (comments) are ignored.
  224.  
  225.     - A POM file may contain up to 500 lines of specifications.
  226.       Comment lines do not count in this total.
  227.  
  228.     A POM file contains no "loops" (to use the programming term).  Each line of
  229.     the input file is processed by the entire POM file.  If you'd like it
  230.     expressed in terms of programming languages, here's what POM does:
  231.  
  232.     +-------------------------------------------------------------------------+
  233.     |      START: If there's nothing left in the input file, go to QUIT.      |
  234.     |             Read a line from the input file                             |
  235.     |             Do everything in the POM file                               |
  236.     |             Go to START                                                 |
  237.     |      QUIT:  Tell the user you're finished!                              |
  238.     +-------------------------------------------------------------------------+
  239.  
  240.  
  241.  
  242.                                 -------------------
  243.                                 PADDING FOR CLARITY
  244.                                 -------------------
  245.  
  246.     Spaces and tabs between the words and variables in a POM file line are
  247.     generally ignored (except in the case of the OUT and OUTEND commands).  You
  248.     can use spaces to make your POM files easier to read.
  249.  
  250.     Additionally, in any line in the POM file, the following terms are ignored:
  251.  
  252.         =   THEN   ELSE
  253.  
  254.     These can be added to make the lines easier to read.  For example, the IF
  255.     command can be written in any of the following ways:
  256.  
  257.         Very terse:          IF PRICE "0.00" BONUS "0.00" "1.00"
  258.  
  259.         Padded with spaces:  IF PRICE   "0.00"   BONUS   "0.00"   "1.00"
  260.  
  261.         Fully padded:        IF PRICE = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  262.  
  263.  
  264.  
  265.     ===========================================================================
  266.                                    COMMAND WORDS
  267.     ===========================================================================
  268.  
  269.  
  270.     For ease of learning, the commands words are explained in the following
  271.     order:
  272.  
  273.     +-------------------------------------------------------------------------+
  274.     |                                                                         |
  275.     |  COMMANDS WHICH WILL...              LIST OF COMMANDS                   |
  276.     |  ----------------------------------  ---------------------------------  |
  277.     |  Break up an input line into fields  SET IF                             |
  278.     |  Control processing flow             BEGIN END                          |
  279.     |  Generate output                     OUT OUTEND                         |
  280.     |  Accept or reject input              MINLEN IGNORE ACCEPT               |
  281.     |  Alter fields                        TRIM PAD INSERT CHANGE             |
  282.     |  Preprocess input                    SPLIT CHOP                         |
  283.     |  Look up data in another file        LOOKUP LOOKFILE LOOKCOLS LOOKSPEC  |
  284.     |                                                                         |
  285.     +-------------------------------------------------------------------------+
  286.  
  287.  
  288.     Here is a quick-reference table of all the commands.  The following conven-
  289.     tions are used in the table:
  290.  
  291.     "var"   means a variable that is being set.
  292.     "value" means a variable whose value is being read.
  293.     Square brackets [like this] indicate optional items.
  294.  
  295.  
  296.     -------------------------------------------  ------------------------------
  297.     COMMAND FORMATS                              EXAMPLE
  298.     ===========================================  ==============================
  299.     SET      var1 value1                         SET     NAME $FLINE[20 26]
  300.     IF       value1 value2 var1 value3 [value4]  IF      X = "Y" THEN Z = "N"
  301.     -------------------------------------------  ------------------------------
  302.     BEGIN    value1 value2                       BEGIN   LINECNTR = "3"
  303.     END                                          END
  304.     -------------------------------------------  ------------------------------
  305.     OUT      [value1 value2] |output-picture     OUT     "X" "X" |{PRICE}
  306.     OUTEND   [value1 value2] |output-picture     OUTEND  "X" "X" |{$FLINE}
  307.     -------------------------------------------  ------------------------------
  308.     MINLEN   number                              MINLEN  "15"
  309.     IGNORE   value1 value2                       IGNORE  PRICE "0.00"
  310.     ACCEPT   value1 value2                       ACCEPT  $FLINE[1 3] "YES"
  311.     -------------------------------------------  ------------------------------
  312.     TRIM     var1 spec1 character                TRIM    PRICE "R" "$"
  313.     PAD      var1 spec1 character len            PAD     SERIALNUM "L" "0" "10"
  314.     INSERT   var1 spec1 value1                   INSERT  PRICE "L" "$"
  315.     CHANGE   var1 value1 value2                  CHANGE  DATE "/" "-"
  316.     -------------------------------------------  ------------------------------
  317.     SPLIT    from to [,from to] [...]            SPLIT   1 250, 251 300
  318.     CHOP     from to [,from to] [...]            CHOP    1 250, 251 300
  319.     -------------------------------------------  ------------------------------
  320.     LOOKUP   var1 value1                         LOOKUP   PHONENUM "FRED JONES"
  321.     LOOKFILE value1                              LOOKFILE "C:\TABLES\DATA.TBL"
  322.     LOOKCOLS value1 value2 value3 value4         LOOKCOLS "1" "3" "8" "255"
  323.     LOOKSPEC value1 value2 value3                LOOKSPEC "Y" "N" "N"
  324.     -------------------------------------------  ------------------------------
  325.  
  326.  
  327.     The commands are explained in more detail (and in the same order) in the
  328.     following sections.
  329.  
  330.  
  331.  
  332.                                   ---------------
  333.                                   The SET Command
  334.                                   ---------------
  335.  
  336.                               FORMAT:  SET var1 value1
  337.  
  338.     SET assigns a value to a variable.  The usual reason to do this is to set a
  339.     variable from the input line (represented by the variable $FLINE) prior to
  340.     cleaning it up with TRIM. For example, if the input line looked like this:
  341.  
  342.         JOHN       SMITH     555-1234   322 Westchester Lane    Architect
  343.         |          |         |          |                       |
  344.         Column 1   Col 12    Col 22     Col 33                  Col 57
  345.  
  346.     then we could extract the last name from the input line with these two POM
  347.     commands:
  348.  
  349.         SET  NAME = $FLINE[12 21]      (Sets the variable from the input line)
  350.         TRIM NAME  "R"  " "            (Trims any spaces on the right side)
  351.  
  352.     SET would first set the variable NAME to this value:     "SMITH     "
  353.     After the TRIM, the variable NAME would have the value:  "SMITH"
  354.  
  355.     You will also use SET if you plan to include a substring of $FLINE in the
  356.     output, since the OUT and OUTEND commands do not recognize substrings after
  357.     the "|" marker, only complete variables.
  358.  
  359.  
  360.  
  361.                                    --------------
  362.                                    The IF Command
  363.                                    --------------
  364.  
  365.                    FORMAT:  IF value1 value2 var1 value3 [value4]
  366.  
  367.     If value1 contains value2, var1 is set to value3.  Otherwise, it is set to
  368.     value4.  If value4 is missing, nothing is done (i.e.  var1 is not changed).
  369.     Here's an example of the IF command...
  370.  
  371.         SET  EARNING = $FLINE[20 26]
  372.         TRIM EARNING  "A"  " "
  373.         IF   EARNING = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  374.  
  375.     This would obtain the value between columns 20 and 26, remove any spaces,
  376.     then check if it equals "0.00".  If it does, the variable BONUS is set to
  377.     0.00.  If not, BONUS is set to "1.00".
  378.  
  379.  
  380.  
  381.                              --------------------------
  382.                              The BEGIN and END Commands
  383.                              --------------------------
  384.  
  385.               The format for the BEGIN and END commands is as follows:
  386.  
  387.                                 BEGIN value1 value2
  388.                                 :
  389.                                 Dependant code
  390.                                 :
  391.                                 END
  392.  
  393.     If value1 equals value2, then the dependant code (the POM lines between
  394.     the BEGIN and the END) are executed.  If value1 does not equal value2,
  395.     then the dependant code is skipped.
  396.  
  397.     It is traditional in programming to indent code that appears in blocks
  398.     such as Parse-O-Matic's BEGIN/END technique.  This makes the logic of
  399.     the program easier to understand.  For example:
  400.  
  401.     BEGIN datatype = "Employee"
  402.       SET phone    = $FLINE[ 1 10]
  403.       SET address  = $FLINE[12 31]
  404.     END
  405.  
  406.     BEGIN/END blocks can be nested.  That is to say, you can have BEGIN/END
  407.     blocks inside other BEGIN/END blocks.  Here is an example, with arrows
  408.     to indicate the levels of each BEGIN/END block...
  409.  
  410.     BEGIN datatype = "Employee"      <---------------------
  411.       SET phone    = $FLINE[ 1 10]                        |
  412.       SET address  = $FLINE[12 31]                        |
  413.       SET areacode = phone[1 3]                           | First
  414.       BEGIN areacode = "514"         <------- Second      | Level
  415.         SET local = "Y"                     | Level       | Block
  416.         SET tax   = "Y"              <------- Block       |
  417.       END                                                 |
  418.     END                              <---------------------
  419.  
  420.     In this case, the "inner" block (starting with BEGIN areacode = "514")
  421.     would only be reached if the "outer" block (BEGIN datatype = "Employee")
  422.     was true.  If the outer block was false, the inner block would never be
  423.     executed.
  424.  
  425.     A nested BEGIN/END block must always be completely inside the outer
  426.     block.  Study the following (incorrect) example:
  427.  
  428.     BEGIN datatype = "Employee"             <----
  429.       SET phone    = $FLINE[ 1 10]              |  First
  430.       SET areacode = phone[1 3]                 |  Level
  431.       BEGIN areacode = "514"         <---       |  Block?
  432.         SET local = "Y"                 |       |
  433.     END                                 |   <----
  434.       SET tax = "Y"                     |
  435.       END                            <---  Second Level Block?
  436.  
  437.     Parse-O-Matic does not pay attention to the indenting -- it is only a
  438.     tradition we use to make the file easier to read.  The code will be
  439.     understood this way:
  440.  
  441.     BEGIN datatype = "Employee"      <---------------------
  442.       SET phone    = $FLINE[ 1 10]                        | First
  443.       SET areacode = phone[1 3]                           | Level
  444.       BEGIN areacode = "514"         <--- Second          | Block
  445.         SET local = "Y"                 | Level           |
  446.       END                            <--- Block           |
  447.       SET tax = "Y"                                       |
  448.     END                              <---------------------
  449.  
  450.     You can nest BEGIN/END blocks up to 25 deep.  (It is quite unlikely you
  451.     will ever actually need that much nesting)  Here is an example of code
  452.     that uses nesting up to three deep:
  453.  
  454.     BEGIN datatype = "Dog"           <----------------------------------
  455.       SET breed = $FLINE[1 10]                                         | First
  456.       BEGIN breed = "Collie"         <-----------------------          | Level
  457.         SET sound = "Woof"                                  | Second   | Block
  458.         BEGIN name = "Spot"          <------ Third          | Level    |
  459.           SET attitude = "Friendly"        | Level          | Block    |
  460.         END                          <------ Block          |          |
  461.       END                            <-----------------------          |
  462.       BEGIN breed = "Other"          <----------------------- Another  |
  463.         SET sound = "Arf"                                   | Second   |
  464.         SET attitude = "Unknown"                            | Level    |
  465.       END                            <----------------------- Block    |
  466.     END                              <----------------------------------
  467.  
  468.     Once again, the indentation is for clarity only and does not affect the
  469.     way the POM file runs.  However, you will find that it makes your POM
  470.     file much easier to understand.
  471.  
  472.  
  473.  
  474.                             ---------------------------
  475.                             The OUT and OUTEND Commands
  476.                             ---------------------------
  477.  
  478.                  FORMAT:  OUT[END] [value1 value2] |output-picture
  479.  
  480.     The OUT command generates output without an end-of-line (i.e. carriage
  481.     return and linefeed characters).  The OUTEND command generates output and
  482.     also adds an end-of-line.
  483.  
  484.     When value1 matches value2 (or if the comparison is omitted), a line is
  485.     output to the output file, according to the output picture.  Within the
  486.     output picture, all text is taken literally (i.e. " is taken to mean
  487.     literally that -- a quotation mark character).
  488.  
  489.     The only exception to this is variable names, which are identified by the
  490.     { and } characters.  For example, a POM file that contained the following
  491.     single line:
  492.  
  493.         OUTEND "X" = "X" |{$FLINE}
  494.  
  495.     would simply output every line from the input file (not very useful!).
  496.  
  497.     The "X" = "X" part of the command is the comparator which controls when
  498.     output occurs; if both parts of the comparator are both forced to the same
  499.     value, output will always occur.
  500.  
  501.     NOTE: For efficiency, OUT does not write immediately to the output file; it
  502.     accumulates the output until it reaches 255 characters before writing.  You
  503.     must do an OUTEND command to ensure that the data is actually written.
  504.  
  505.     You can not use substrings after the "|" marker.  Thus, the following line
  506.     is NOT legal:
  507.  
  508.         OUTEND $FLINE[1 3] = "IBM" |{$FLINE[1 15]}
  509.  
  510.     The correct way to code this is as follows:
  511.  
  512.         SET CODE = $FLINE[1 15]
  513.         OUTEND $FLINE[1 3] = "IBM" |{CODE}
  514.  
  515.     This would output the first 15 characters of any line that contains the
  516.     letters IBM in the first three positions.
  517.  
  518.  
  519.  
  520.                                  ------------------
  521.                                  The MINLEN Command
  522.                                  ------------------
  523.  
  524.                                FORMAT:  MINLEN number   
  525.  
  526.     MINLEN specifies the minimum length a line must be to be considered for
  527.     parsing.  If you omit the MINLEN command, the minimum length is assumed to
  528.     be 1.  That is to say, all lines longer than 1 character will be processed
  529.     and shorter lines (null lines in other words) will be ignored.
  530.  
  531.     MINLEN is useful for ignoring brief information lines that clutter up a
  532.     report that you are parsing.  For example, in the sample file EXAMPLE2.POM,
  533.     the MINLEN command is set to 85 to ensure that all lines shorter than 85
  534.     characters long will be ignored.  This simplifies the coding considerably.
  535.  
  536.     The longest allowable input line is 255 characters, unless you use the
  537.     SPLIT or CHOP command (described later).
  538.  
  539.  
  540.  
  541.                                  ------------------
  542.                                  The IGNORE Command
  543.                                  ------------------
  544.  
  545.                            FORMAT:  IGNORE value1 value2
  546.  
  547.     When value1 contains value2, the input line is ignored and all further
  548.     processing on the input line stops.  The usual format of this command is as
  549.     in this example:
  550.  
  551.         IGNORE $FLINE[3 9] = "Date"
  552.  
  553.     This would skip any input line that contains the word "Date" between
  554.     columns 3 and 9 ($FLINE is the line just read from the input file).
  555.  
  556.  
  557.  
  558.                                  ------------------
  559.                                  The ACCEPT Command
  560.                                  ------------------
  561.  
  562.                            FORMAT:  ACCEPT value1 value2
  563.  
  564.     The ACCEPT command accepts the input line if value1 contains value2.  For
  565.     example, if the entire POM file read as follows:
  566.  
  567.         ACCEPT $FLINE[15 17] = "YES"
  568.         OUTEND "X" = "X" |{$FLINE}
  569.  
  570.     then any input line that contains "YES" starting in column 15 would be sent
  571.     to the output file.  All other lines would be ignored.
  572.  
  573.     CLUSTERED ACCEPTS: Sometimes you have to check more than one value to see
  574.     if the input line is valid.  You do this by using "clustered ACCEPTs",
  575.     which are several ACCEPT commands in a row.
  576.  
  577.     Briefly stated, if you have several ACCEPTs in a row ("clustered"), they
  578.     are all processed to determine if the input line is acceptable or not.  If
  579.     even one ACCEPT matches up, the line is accepted.  To express this in more
  580.     detail...
  581.  
  582.     When value1 contains value2, the line is accepted, and processing of the
  583.     POM file continues for that input line, even if the immediately following
  584.     ACCEPTs do NOT produce a match.  After all, we've already got a match!
  585.  
  586.     If value1 does NOT contain value2, Parse-O-Matic looks at the next commmand
  587.     in the POM file.  If it is not another ACCEPT, the input line is ignored.
  588.     If it is another ACCEPT, maybe it will product a match -- so Parse-O-Matic
  589.     moves to that command.
  590.  
  591.     The following POM file uses clustered ACCEPTs to accept any line that
  592.     contains the name "FRED" or "MARY" between columns 5 and 8, or contains the
  593.     word "MEMBER" between columns 20 and 25.
  594.  
  595.         SET    NAME = $FLINE[5 8]         (Set the variable)
  596.         ACCEPT NAME = "FRED"              (Look for FRED)
  597.         ACCEPT NAME = "MARY"              (Look for MARY)
  598.         ACCEPT $FLINE[20 25] = "MEMBER"   (Look for MEMBER)
  599.         OUTEND "X" = "X" |{$FLINE}        (Output the line if we get this far)
  600.  
  601.     The following example would NOT work, however:
  602.  
  603.         ACCEPT $FLINE[20 25] = "MEMBER"
  604.         SET    NAME = $FLINE[5 8]
  605.         ACCEPT NAME = "FRED"
  606.         ACCEPT NAME = "MARY"
  607.         OUTEND "X" = "X" |{$FLINE}
  608.  
  609.     It would not work because the ACCEPTs are not clustered; if the first
  610.     ACCEPT fails, the input line will be rejected as soon as the SET command is
  611.     encountered.  The next two ACCEPTs would not be reached in such case.
  612.  
  613.  
  614.  
  615.                                   ----------------
  616.                                   The TRIM Command
  617.                                   ----------------
  618.  
  619.                          FORMAT:  TRIM var1 spec1 character
  620.  
  621.     Removes characters from var1.  This is usually used to remove blanks.
  622.  
  623.     spec1 can be:  A=All   B=Both ends   L=Left side only   R = Right side only
  624.  
  625.     For example:
  626.  
  627.         SET  PRICE = $FLINE[20 26]
  628.         TRIM PRICE "A" ","
  629.         TRIM PRICE "L" "$"
  630.  
  631.     This would remove all commas from the variable "PRICE", and remove the
  632.     leading dollar sign.  Thus:
  633.  
  634.         If the input contained the string:   "$25,783"
  635.         The first TRIM would change it to:   "$25783"
  636.         The second TRIM would change it to:  "25783"
  637.  
  638.  
  639.  
  640.                                   ---------------
  641.                                   The PAD Command
  642.                                   ---------------  
  643.  
  644.                        FORMAT:  PAD var1 spec1 character len
  645.  
  646.     PAD makes var1 a specified length, padded with a specified character.
  647.  
  648.         spec1      is "L", "R", or "C" (Left, Right or Center)
  649.         character  is the character used to pad the string
  650.         len        is the desired string length
  651.  
  652.     For example, if the variable ABC is set to "1234" ...
  653.  
  654.     PAD ABC "L" "0" "7"   left-pads it 7 characters wide with zeros ("0001234")
  655.     PAD ABC "R" " " "5"   right-pads it 5 characters wide with spaces ("1234 ")
  656.     PAD ABC "C" "*" "8"   would center it, 8 wide, with asterisks ("**1234**")
  657.  
  658.     If the length is less than the length of the string, it is unchanged.  For
  659.     example, if you set variable XYZ to "PINNACLE", then
  660.  
  661.         PAD XYZ "R" " " "3"
  662.  
  663.     would leave the string as-is ("PINNACLE").
  664.  
  665.     Thus, PAD can not be used to shorten a string.  If it was your intention to
  666.     make XYZ 3 letters long, it would be appropriate to use the SET command:
  667.  
  668.         SET XYZ = XYZ[1 3]
  669.  
  670.  
  671.                                  ------------------
  672.                                  The INSERT Command
  673.                                  ------------------
  674.  
  675.                          FORMAT:  INSERT var1 spec1 value1
  676.  
  677.     The INSERT command inserts text on the left or right of var1, or at a
  678.     "found text" position.
  679.  
  680.         spec1  is "L" or "R" (Left or Right) or a find-string (e.g.  "@HELLO")
  681.         value1 is the value to be inserted
  682.  
  683.     For example, if the variable ABC is set to "Parse-O-Matic", then
  684.  
  685.         INSERT ABC "L" "Register "   would set ABC to "Register Parse-O-Matic"
  686.         INSERT ABC "R" " is super"   would set ABC to "Parse-O-Matic is super"
  687.  
  688.     You can use a find-string to insert text at the first occurance of the text
  689.     you specify.  For example:
  690.  
  691.         INSERT ABC "@-O-Matic" "!" would set ABC to "Parse!-O-Matic"
  692.  
  693.     If the find-string is not found, nothing is done.
  694.  
  695.  
  696.  
  697.                                  ------------------
  698.                                  The CHANGE Command
  699.                                  ------------------
  700.  
  701.                          FORMAT:  CHANGE var1 value1 value2
  702.  
  703.     The CHANGE command replaces ALL occurances of value1 with value2.  This is
  704.     more powerful than TRIM, but is not as efficient.  Here is an example of
  705.     the CHANGE command in action:
  706.  
  707.         SET    DATE = $FLINE[31 38]
  708.         CHANGE DATE "/" "--"
  709.  
  710.     If the SET command assigned DATE the value:    "93/10/15"
  711.     Then the CHANGE command would convert it to:   "93--10--15"
  712.  
  713.  
  714.  
  715.                                  -----------------
  716.                                  The SPLIT Command
  717.                                  -----------------
  718.  
  719.        FORMAT:  SPLIT from-position to-position [,from-pos'n to-pos'n] [...]
  720.  
  721.     The maximum length of an input line from a text file is 255 characters.  If
  722.     your input file is wider than that, you must break up the file into
  723.     manageable chunks, using the SPLIT command.  This command lets you specify
  724.     the way in which each input line is broken up so that it will look like
  725.     several SEPARATE lines.
  726.  
  727.     For example, if your input lines were up to 300 characters wide, you could
  728.     specify:
  729.  
  730.         SPLIT 1 255, 256 300
  731.  
  732.     This would break up each line as if it was two lines.  (If some of the
  733.     lines were less than 256 characters they would still be treated as two
  734.     lines, though the second line would be null (i.e.  empty).)
  735.  
  736.     You can specify up to 100 splits (use multiple SPLIT commands if
  737.     necessary).  With SPLIT, Parse-O-Matic can handle input records of up to
  738.     32767 characters.
  739.  
  740.     The best way of handling SPLIT or CHOPped files is to use a combination of
  741.     $SPLIT (explained in more detail later) and BEGIN/END.  For example:
  742.  
  743.         SPLIT 1 250, 251 300
  744.         BEGIN $SPLIT = "1"
  745.           SET a = $FLINE[ 1 10]
  746.           SET b = $FLINE[11 20]
  747.         END
  748.         BEGIN $SPLIT = "2"
  749.           SET x = $FLINE[ 1 10]
  750.           SET y = $FLINE[11 20]
  751.           OUTEND |{a} {b} {x} {y}
  752.         END
  753.  
  754.     This would output the data which appears (in the input file) in columns
  755.     1-10, 11-20, 251-260 and 261-280.
  756.  
  757.  
  758.  
  759.                                   ----------------
  760.                                   The CHOP Command
  761.                                   ----------------
  762.  
  763.         FORMAT:  CHOP from-position to-position [,from-pos'n to-pos'n] [...]
  764.  
  765.     The CHOP command works the same way as the SPLIT command, with one
  766.     exception:  it informs Parse-O-Matic that the input is a fixed-record-
  767.     length file. In other words, it means that the input records are
  768.     distinguished by having a particular (and exact) length, rather than being
  769.     separated by end-of-line characters (Carriage Return, Linefeed) as is the
  770.     case for a standard text file.
  771.  
  772.     Thus, if you have an input file containing fixed-length records, each of
  773.     which is 200 characters wide, you could specify it like this:
  774.  
  775.         CHOP 1 200
  776.  
  777.     If the input record is more than 255 characters, you must break it up into
  778.     smaller chunks.  For example, if the input record was 300 characters wide,
  779.     you could break it up like this:
  780.  
  781.         CHOP 1 250, 251 300
  782.  
  783.     By using CHOP, Parse-O-Matic can handle input records up to 32767
  784.     characters wide.  You can use the $SPLIT variable to manage your use of
  785.     CHOP.  See the example in the section describing the SPLIT command.
  786.  
  787.  
  788.  
  789.                                  ------------------
  790.                                  The LOOKUP Command
  791.                                  ------------------
  792.  
  793.                             FORMAT:  LOOKUP var1 value1
  794.  
  795.     The LOOKUP command will search for value1 in a text file (the name of which
  796.     is specified either by the LOOKFILE command or the /L startup parameter).
  797.     When POM finds it, it sets var1 to another value found on the same line.
  798.  
  799.     Let us suppose you created a text file, named NAMES.TBL, which looks like
  800.     this:
  801.                     
  802.         R. REAGAN        Ronald Reagan
  803.         D. EISENHOWER    Dwight Eisenhower
  804.         G. BUSH          George Bush
  805.         :                :
  806.         Column 1         Column 18
  807.  
  808.     This file can be used to look up a name, as in this POM file:
  809.  
  810.         LOOKFILE "NAMES.TBL"
  811.         LOOKCOLS "1" "17" "18" "34"
  812.         SET      oldname = $FLINE[21 37]
  813.         TRIM     oldname "R" " "
  814.         LOOKUP   newname = oldname
  815.         OUTEND   |{oldname} {newname}
  816.  
  817.     The LOOKFILE command specifies the name of the look-up file.  The LOOKCOLS
  818.     command specifies the starting and end columns for both the "text-to-look-
  819.     for" field (known as the key field) and the "text-to-replace-with" field
  820.     (known as the data field).
  821.  
  822.     The LOOKUP command will look for oldname in NAMES.TBL.  If oldname was set
  823.     to "G. BUSH", LOOKUP set newname to "George Bush".  If, however, oldname
  824.     was set to "G. WASHINGTON", which doesn't appear in NAMES.TBL, newname
  825.     would be set to "" (that is to say, an empty string).
  826.  
  827.     There is no limit to the number of lines that you can put in a look-up
  828.     file.  However, the more line there are, the longer it will take to process
  829.     (because there is more to search).  The maximum length of a line in a
  830.     look-up file is 255 characters.
  831.  
  832.     In the look-up file, null (empty) lines are ignored.  You can also include
  833.     comments in the file by starting the line with a semi-colon:
  834.  
  835.         ; Some of the Presidents of the United States
  836.         R. REAGAN        Ronald Reagan
  837.         D. EISENHOWER    Dwight Eisenhower
  838.         G. BUSH          George Bush
  839.  
  840.     The LOOKUP command can be used for more than just names, of course.  You
  841.     could use it to look up prices, phone numbers, addresses and so on.
  842.  
  843.  
  844.  
  845.                                 --------------------
  846.                                 The LOOKFILE Command
  847.                                 --------------------
  848.  
  849.                               FORMAT:  LOOKFILE value1
  850.  
  851.     The LOOKFILE command specifies the name of the look-up file for the next
  852.     LOOKUP command.  This lets you use several look-up files in one POM file.
  853.     For example:
  854.  
  855.         SET name = $FLINE[1 20]
  856.         ; Look up full name
  857.         LOOKFILE "NAMES.TBL"
  858.         LOOKCOLS "1" "25" "30" "50"
  859.         LOOKUP   fullname = name
  860.         ; Look up phone number
  861.         LOOKFILE "PHONE.TBL"
  862.         LOOKCOLS "1" "25" "30" "40"
  863.         LOOKUP   phone = name
  864.         ; Output result
  865.         OUTEND   |{name} {fullname} {newname}
  866.  
  867.     If you only have one look-up file, you may omit the LOOKFILE command and
  868.     specify the file name on the command line, using the /L parameter.  For
  869.     example, you could write a POM file like this:
  870.  
  871.         SET name = $FLINE[1 20]
  872.         ; Look up full name
  873.         LOOKCOLS "1" "25" "30" "50"
  874.         LOOKUP   fullname = name
  875.         ; Output result
  876.         OUTEND   |{name} {fullname}
  877.  
  878.     Your POM command could then look like this:
  879.  
  880.         POM MYPOM.POM INPUT.TXT OUTPUT.TXT /LC:\MYFILES\NAMES.TBL
  881.  
  882.     This technique allows you to use several different look-up files with the
  883.     same POM file, simply by changing the command line.
  884.  
  885.  
  886.  
  887.                                 --------------------
  888.                                 The LOOKCOLS Command
  889.                                 --------------------
  890.  
  891.                    FORMAT:  LOOKCOLS value1 value2 value3 value4
  892.  
  893.     The LOOKCOLS command specifies the starting and ending columns for the
  894.     key and data fields in a look-up file (see the explanation of the LOOKUP
  895.     command for an overview of look-up files).
  896.  
  897.         value1 specifies the starting column for the key  field
  898.         value2 specified the  ending  column for the key  field
  899.         value3 specifies the starting column for the data field
  900.         value4 specified the  ending  column for the data field
  901.  
  902.     You can specify a null value to indicate "same as last time".  For example:
  903.  
  904.         SET name = $FLINE[1 20]
  905.         LOOKFILE "NAMES.TBL"
  906.         LOOKCOLS "1" "25" "30" "50"
  907.         LOOKUP   fullname = name
  908.         LOOKFILE "PHONE.TBL"
  909.         LOOKCOLS "" "" "" "40"
  910.         LOOKUP   phonenum = name
  911.         OUTEND   |{name} {fullname} {phonenum}
  912.  
  913.     The second LOOKCOLS command uses the same numbers for the first three
  914.     values that the first LOOKCOLS command used.
  915.  
  916.     If you do not specify a LOOKCOLS command, the default values are:
  917.  
  918.        Key Field:   Starting column  =   1
  919.                     Ending column    =  10
  920.        Data Field:  Starting column  =  12
  921.                     Ending column    = 255
  922.  
  923.     This is equivalent to LOOKCOLS "1" "10" "12" "255".
  924.  
  925.  
  926.  
  927.                                 --------------------
  928.                                 The LOOKSPEC Command
  929.                                 --------------------
  930.  
  931.                        FORMAT:  LOOKSPEC value1 value2 value3
  932.  
  933.     The LOOKSPEC command configures the way the next LOOKUP command will work.
  934.                                                 
  935.         value1 = Trim             ("Y" or "N" -- default "Y")
  936.         value2 = Sorted           ("Y" or "N" -- default "N")
  937.         value3 = Case-sensitive   ("Y" or "N" -- default "N")
  938.  
  939.     The Trim setting specifies whether or not the data field should have spaces
  940.     stripped off both ends.
  941.  
  942.     The Sorted setting specifies whether or not the look-up file is sorted by
  943.     key field.  A sorted file is much faster than an unsorted file.
  944.  
  945.     The Case-sensitive setting specifies whether or not LOOKUP should distin-
  946.     guish between upper and lower case when searching.  The default setting is
  947.     "N" (No), so that LOOKUP would find "John Smith", even if it appeared in
  948.     the look-up file as "JOHN SMITH".  It is usually safest to set Case-
  949.     sensitivity to "N", but if you set it to "Y", searching is slightly faster.
  950.  
  951.     You can specify a null value to indicate "same as last time".  For example:
  952.  
  953.         SET name = $FLINE[1 20]
  954.         LOOKFILE "DATA.TBL"
  955.         LOOKCOLS "1" "25" "30" "50"
  956.         LOOKSPEC "Y" "Y" "Y"
  957.         LOOKUP   fullname = name
  958.         LOOKCOLS "" "" "60" "70"
  959.         LOOKSPEC "N" "" ""
  960.         LOOKUP   phonenum = name
  961.         OUTEND   |{name} {fullname} {phonenum}
  962.  
  963.     The second LOOKSPEC command uses the same settings for Sorted and Case-
  964.     sensitivity as the first one, but specifies a different Trim setting.
  965.  
  966.  
  967.  
  968.     ===========================================================================
  969.                                 TERMS AND TECHNIQUES
  970.     ===========================================================================
  971.  
  972.  
  973.                                        ------
  974.                                        VALUES
  975.                                        ------
  976.  
  977.     A value can be specified in the following ways:
  978.  
  979.         "text"              A literal text string
  980.         VARNAME             The name of a variable
  981.         VARNAME[start end]  A substring of a variable
  982.         VARNAME[start]      A single character
  983.         VARNAME+            Incremented variable (see explanation below)
  984.  
  985.     Variable names can be up to 8 characters long.  There is no distinction
  986.     between upper and lower case in the variable name.  You can create up to
  987.     220 variables and literals.
  988.  
  989.     Parse-O-Matic predefines several variables.  They are:
  990.  
  991.         $FLINE = The line just read from the file (max. length 255 characters)
  992.         $FLUPC = The line just read from the file, in uppercase
  993.         $BRL   = The { character (used in OUT)
  994.         $BRR   = The } character (used in OUT)
  995.         $TAB   = The tab character (Hex $09; ASCII 09)
  996.         $SPLIT = The CHOP or SPLIT number you are currently processing
  997.  
  998.     Since $FLINE has a maximum length of 255 characters, you will have to use
  999.     the SPLIT or CHOP command if your input file is wider than that.  The
  1000.     $SPLIT variable reports which segment you are processing.  For example,
  1001.     if you had this command...
  1002.  
  1003.       CHOP 1 255, 256 380
  1004.  
  1005.     then $SPLIT would be set to "1" when it was processing columns 1 to 255,
  1006.     and it would be set to "2" when it was processing columns 256 to 380.
  1007.  
  1008.  
  1009.  
  1010.                                      ----------
  1011.                                      DELIMITERS
  1012.                                      ----------
  1013.  
  1014.     If you need to specify a quotation mark, use "".  For example:
  1015.  
  1016.         IGNORE $FLINE = "He said ""Hello"" to me."
  1017.  
  1018.     This would ignore lines containing:  He said "Hello" to me.
  1019.  
  1020.  
  1021.  
  1022.                                  ------------------
  1023.                                  ILLEGAL CHARACTERS
  1024.                                  ------------------
  1025.  
  1026.     No command can contain these ASCII characters:
  1027.  
  1028.         HEX   DECIMAL   NAME
  1029.         ---   -------   --------------------
  1030.         $00      0      NULL
  1031.         $0A     10      LF (Linefeed)
  1032.         $0D     13      CR (Carriage Return)
  1033.  
  1034.     Of course, LF and CR do appear at the end of each line, in a text file.
  1035.  
  1036.  
  1037.  
  1038.                                     ------------
  1039.                                     INCREMENTING
  1040.                                     ------------
  1041.  
  1042.     Only numeric incrementing is supported.  Attempting to increment another
  1043.     type of variable will result in an error.
  1044.  
  1045.     - Incrementing "1" gives you "2"
  1046.     - Incrementing "9" gives you "10"
  1047.  
  1048.     The first time a variable is referenced, it has a null value.  If you
  1049.     increment this, it will be changed from "" (i.e.  null) to "1".
  1050.  
  1051.  
  1052.  
  1053.                                    -------------
  1054.                                    LINE COUNTERS
  1055.                                    -------------
  1056.  
  1057.     If your input record is divided over several lines (due to its original
  1058.     format or perhaps because you used the SPLIT or CHOP command), it is
  1059.     helpful to set up a line counter.  The following example would extract the
  1060.     first six characters of the second line of input records that span three
  1061.     lines (designated lines 0, 1 & 2):
  1062.  
  1063.         IF     LineCntr = "1" THEN MyField = $FLINE[1 6]
  1064.         OUTEND LineCntr = "1" |{MyField}
  1065.         IF     LineCntr = "2" THEN LineCntr = "" ELSE LineCntr+
  1066.  
  1067.  
  1068.  
  1069.                                       -------
  1070.                                       TRACING
  1071.                                       -------
  1072.  
  1073.     By setting the DOS variable POM to ALL, you can generate a trace file,
  1074.     named POM.TRC.  This is helpful if you have trouble understanding why your
  1075.     file isn't being parsed properly.  But be sure to test it with a SMALL
  1076.     input file; the trace is quite detailed, and it can easily generate a huge
  1077.     output file.
  1078.  
  1079.     To save space, you can specify a particular list of variables to be traced,
  1080.     rather than tracing everything.  For example, to trace only the variable
  1081.     PRICE, enter this DOS command:
  1082.  
  1083.         SET POM=PRICE
  1084.  
  1085.     To trace several variables, separate the variable names by slashes, as in
  1086.     this example:
  1087.  
  1088.         SET POM=PRICE/BONUS/NAME
  1089.  
  1090.  
  1091.                                       --------
  1092.                                       EXAMPLES
  1093.                                       --------
  1094.  
  1095.     Most of these techniques are demonstrated by the examples provided with the
  1096.     standard Parse-O-Matic package.  To see these examples, switch to your
  1097.     Parse-O-Matic directory and type START at the DOS prompt.
  1098.  
  1099.  
  1100.  
  1101.  
  1102.