home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 25 / CD_ASCQ_25_1095.iso / dos / tools / par330 / pom.doc < prev    next >
Text File  |  1995-09-06  |  119KB  |  2,762 lines

  1.  
  2.     ===========================================================================
  3.     ===========================================================================
  4.     ============================                   ============================
  5.     ============================                   ============================
  6.     ============================   PARSE-O-MATIC   ============================
  7.     ============================                   ============================
  8.     ============================                   ============================
  9.     ===========================================================================
  10.     ===========================================================================
  11.                          
  12.                                                                                
  13.     +-------------------------------------------------------------------------+
  14.     |                                                                         |
  15.     |        HERE ARE A FEW OF THE THINGS PARSE-O-MATIC CAN DO FOR YOU:       |
  16.     |                                                                         |
  17.     |      Importing             Exporting             Automated Editing      |
  18.     |      Text Extraction       Data Conversion       Table Lookup           |
  19.     |      Retabulation          Info Weeding          Selective Copying      |
  20.     |      Binary-File to Text   Report Reformatting   Wide-Text Folding      |
  21.     |      Auto-Batch Creation   Comm-log Trimming     Tab Replacement        |
  22.     |      Character Filtering   Column Switching      DBF Interpretation     |
  23.     |      De-uppercasing        Name Properization    And much more!         |
  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.                    Parse-O-Matic is Copyright (C) 1986, 1995 by:
  33.  
  34.            Pinnacle Software, CP 386 Mount Royal, Quebec, Canada H3P 3C6
  35.            U.S. Office: Box 714 Airport Road, Swanton, Vermont 05488 USA
  36.  
  37.                        Support Line: (514) 345-9578
  38.                      Free Files BBS: (514) 345-8654
  39.                      Internet email: pinnacl@cam.org
  40.                      World Wide Web: http://www.cam.org/~pinnacl
  41.                          CompuServe: 70154,1577
  42.  
  43.  
  44.     +-------------------------------------------------------------------------+
  45.     |                                                                         |
  46.     |           FILE FORMATS CURRENTLY SUPPORTED BY PARSE-O-MATIC:            |
  47.     |                                                                         |
  48.     |   Input: Text (almost any format), Binary, Fixed-Length, DBF            |
  49.     |  Output: Text (flat, comma-delimited, paginated), Binary, Fixed-Length  |
  50.     |                                                                         |
  51.     +-------------------------------------------------------------------------+
  52.  
  53.  
  54.  
  55.     ===========================================================================
  56.                              AN OVERVIEW OF THIS MANUAL
  57.     ===========================================================================
  58.  
  59.  
  60.     Introduction . . . . . . . . What is Parse-O-Matic?
  61.                                  Why you need Parse-O-Matic -- an example
  62.                                  Parse-O-Matic to the rescue!
  63.                                  How it works
  64.  
  65.     Fundamentals . . . . . . . . The Parse-O-Matic command
  66.                                  The POM file
  67.                                  Padding for clarity
  68.                                  A simple example
  69.  
  70.     Quick Reference  . . . . . . Command descriptions
  71.                                  Command formats
  72.  
  73.     Input Parsing Commands . . . Set, If, Parse, Peel
  74.  
  75.     Flow Control Commands  . . . Begin, Else, End, Done, Nextfile, Halt,
  76.                                  Prologue, Epilogue
  77.  
  78.     Output Commands  . . . . . . Out, Outend, Outhdg, Pagelen
  79.  
  80.     Filter Commands  . . . . . . Minlen, Ignore, Accept, Readnext
  81.  
  82.     Variable Modifiers . . . . . Trim, Pad, Change, Proper, Insert, Append
  83.  
  84.     Calcluation Commands . . . . Calc, Calcreal
  85.  
  86.     Input Preprocessors  . . . . Split, Chop
  87.  
  88.     Lookup Commands  . . . . . . Lookup, Lookfile, Lookcols, Lookspec
  89.  
  90.     Miscellaneous Commands . . . Trace, Log, Setlen, Sound
  91.  
  92.     Terms and Techniques . . . . Values
  93.                                  Delimiters
  94.                                  Illegal characters
  95.                                  Comparators
  96.                                  Incrementing
  97.                                  Line counters
  98.                                  Tracing
  99.                                  Logging
  100.                                  Quiet mode
  101.                                  DBF Files
  102.                                  POM and wildcards
  103.  
  104.     Operational Planning . . . . Unattended operation
  105.                                  Examples
  106.  
  107.     Licensing  . . . . . . . . . Trial license
  108.                                  Registered copy
  109.                                  Site and multi-copy licenses
  110.                                  Distribution license
  111.                                  Retail license
  112.  
  113.  
  114.  
  115.     ===========================================================================
  116.                                     INTRODUCTION
  117.     ===========================================================================
  118.  
  119.  
  120.                                ----------------------
  121.                                What is Parse-O-Matic?
  122.                                ----------------------
  123.  
  124.     Parse-O-Matic is a programmable file-parser.  Simple enough for even a non-
  125.     programmer to master, it can help out in countless ways.  Here are some of
  126.     the things Parse-O-Matic can do:  Importing, Exporting, Automated Editing,
  127.     Text Extraction, Data Conversion, Table Lookup, Retabulation, Info Weeding,
  128.     Selective Copying, Binary-File to Text, Tab Replacement, Reformatting,
  129.     Wide-Text Folding, Auto-Batch Creation, Character Filtering, Column
  130.     Switching, DBF Interpretation, Report Generation, and more!
  131.  
  132.     If you have a file you want to edit, manipulate, or change around, you may
  133.     find that Parse-O-Matic is just the tool you need.  Parse-O-Matic is not,
  134.     however, an "automatic file converter".  It will not, for example, convert
  135.     WordPerfect files to MS-Word format, or convert Lotus 1-2-3 Spreadsheets
  136.     DIRECTLY to Excel files (although you CAN use Parse-O-Matic as an
  137.     intermediary, by having it read reports from one program and convert them
  138.     to comma-delimited files which can be imported by the other program.)
  139.  
  140.  
  141.                       ----------------------------------------
  142.                       Why You Need Parse-O-Matic -- An Example
  143.                       ----------------------------------------
  144.  
  145.     There are plenty of programs out there that have valuable data locked away
  146.     inside them.  How do you get that data OUT of one program and into another
  147.     one?
  148.  
  149.     Some programs provide a feature which "exports" a file into some kind of
  150.     generic format.  Perhaps the most popular of these formats is known as a
  151.     "comma-delimited file", which is a text file in which each data field is
  152.     separated by a comma.  Character strings -- which might themselves contain
  153.     commas -- are surrounded by double quotes.  So a few lines from a
  154.     comma-delimited file might look something like this (an export from a
  155.     hypothetical database of people who owe your company money):
  156.  
  157.     +-------------------------------------------------------------------------+
  158.     |      "JONES","FRED","1234 GREEN AVENUE", "KANSAS CITY", "MO",293.64     |
  159.     |      "SMITH","JOHN","2343 OAK STREET","NEW YORK","NY",22.50             |
  160.     |      "WILLIAMS","JOSEPH","23 GARDEN CRESCENT","TORONTO","ON",16.99      |
  161.     +-------------------------------------------------------------------------+
  162.  
  163.     Unfortunately, not all programs export or import data in this format.
  164.     Even more frustrating is a program that exports data in a format that is
  165.     ALMOST what you need!
  166.  
  167.     If that's the case, you might decide to spend a few hours in a text editor,
  168.     modifying the export file so that the other program can understand it.  Or
  169.     you might write a program to do the editing for you.  Both solutions are
  170.     time-consuming.
  171.  
  172.     An even more challenging problem arises when a program which has no export
  173.     capability does have the ability to "print" reports to a file.  You can
  174.     write a program to read these files and convert them to something you can
  175.     use, but this can be a LOT of work!
  176.  
  177.  
  178.                             ----------------------------
  179.                             Parse-O-Matic to the Rescue!
  180.                             ----------------------------
  181.  
  182.     Parse-O-Matic is a utility that reads text, fixed-record-length and DBF
  183.     ("DBase") files, interprets the data, and outputs the result to a text,
  184.     fixed-length or binary file.  It can help you "boil down" reports into
  185.     their essential data.  You can also use it to convert NEARLY compatible
  186.     import files, or generate printable reports.
  187.  
  188.  
  189.                                     ------------
  190.                                     How It Works
  191.                                     ------------
  192.  
  193.     You need three things:
  194.  
  195.     1) The Parse-O-Matic program
  196.     2) A Parse-O-Matic "POM" file (to tell Parse-O-Matic what to do)
  197.     3) The input file
  198.  
  199.     The input file is usually a report from another program, a fixed record
  200.     length data file, or a DBF ("DBase") file.  We've provided several examples
  201.     of typical input files. For example, the file XMPDAT02.TXT comes from the
  202.     AccPac accounting software.  AccPac is a great program, but its export
  203.     capabilities leave something to be desired.  Parse-O-Matic can help!
  204.  
  205.     To see detailed demonstrations of how these files can be parsed, enter
  206.     START at the DOS prompt, then select TUTORIAL.
  207.  
  208.  
  209.  
  210.     ===========================================================================
  211.                                     FUNDAMENTALS
  212.     ===========================================================================
  213.    
  214.  
  215.     This documentation assumes that you are an experienced computer user.  If
  216.     you have trouble, you might ask a programmer to help you -- POM file
  217.     creation is a little like programming!
  218.                           
  219.  
  220.                              -------------------------
  221.                              The Parse-O-Matic Command
  222.                              -------------------------
  223.  
  224.     The basic format of the Parse-O-Matic command line is:
  225.  
  226.         POM pom-file input-file output-file
  227.  
  228.     Here is an example, as you would type it at the DOS command line:
  229.  
  230.         POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  231.  
  232.     For a more formal description of the command line, start up POM by typing
  233.     this command at the DOS prompt:
  234.  
  235.         POM
  236.  
  237.                                     ------------
  238.                                     The POM File
  239.                                     ------------
  240.  
  241.     The POM file is a text file with a .POM extension.  The following
  242.     conventions are used when interpreting the POM file:
  243.  
  244.     - Null lines and lines starting with a semi-colon (comments) are ignored.
  245.  
  246.     - A POM file may contain up to 750 lines of specifications.
  247.       Comment lines do not count in this total.
  248.  
  249.     A POM file contains no "loops" (to use the programming term).  Each line of
  250.     the input file is processed by the entire POM file.  If you'd like this
  251.     expressed in terms of programming languages, here's what POM does:
  252.  
  253.     +-------------------------------------------------------------------------+
  254.     |      START: If there's nothing left in the input file, go to QUIT.      |
  255.     |             Read a line from the input file                             |
  256.     |             Do everything in the POM file                               |
  257.     |             Go to START                                                 |
  258.     |      QUIT:  Tell the user you're finished!                              |
  259.     +-------------------------------------------------------------------------+
  260.  
  261.  
  262.                                 -------------------
  263.                                 Padding for Clarity
  264.                                 -------------------
  265.  
  266.     Spaces and tabs between the words and variables in a POM file line are
  267.     generally ignored (except in the case of the "output picture" of the OUT
  268.     and OUTEND commands).  You can use spaces to make your POM files easier to
  269.     read.
  270.  
  271.     Additionally, in any line in the POM file, the following terms are ignored:
  272.  
  273.         THEN   ELSE
  274.  
  275.     Finally, the equals ("=") character is ignored if it is found in a place
  276.     where no comparison is taking place.  This will be demonstrated below.
  277.  
  278.     You can use these techniques to make your POM files easier to read.  For
  279.     example, the IF command can be written in several ways:
  280.  
  281.         Very terse:          IF PRICE = "0.00" BONUS "0.00" "1.00"
  282.  
  283.         Padded with spaces:  IF PRICE = "0.00"   BONUS   "0.00"   "1.00"
  284.  
  285.         Fully padded:        IF PRICE = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  286.  
  287.     In the last example, the first equals sign ("=") is a "comparator".  (For
  288.     details about comparators, see the section entitled "Comparators".)  The
  289.     second equals sign is not really required, but it does make the line easier
  290.     to understand.
  291.  
  292.  
  293.                                   ----------------
  294.                                   A Simple Example
  295.                                   ----------------
  296.  
  297.     Let's say you have a text file called NAMES.TXT that looks like this:
  298.  
  299.                                   WILLIAMS   JACK
  300.                                   SMITH      JOHNNY
  301.                                   JOHNSON    MARY
  302.                                   :          :
  303.                            Column 1          Column 12
  304.  
  305.     Now let's say you want to switch the columns, so that the first name
  306.     appears first.  Your first step is to create a file using a text editor.
  307.     The file would look like this:
  308.  
  309.         SET    last  = $FLINE[ 1 10]
  310.         SET    first = $FLINE[12 17]
  311.         PAD    first "R" " " "10"
  312.         OUTEND |{first} {last}
  313.  
  314.     The first two lines will tell Parse-O-Matic to extract text from each input
  315.     line.  For the first line of the input file, the variable named 'last'
  316.     will be given the value "WILLIAMS  ".  You will notice there are two spaces
  317.     at the end.  That is because we take every character from position 1 to
  318.     position 10 -- which in this case includes two spaces.
  319.  
  320.     The PAD line adds enough spaces on the right side of the variable named
  321.     'first' to make sure that it is 10 characters long.  The OUTEND command
  322.     sends the two variables to the output file.
  323.  
  324.     Save the file with the name TEST.POM and exit your text editor.  At the DOS
  325.     prompt, enter this command:
  326.  
  327.         POM TEST.POM NAMES.TXT OUTPUT.TXT
  328.  
  329.     This will run the POM file (TEST.POM) on every line of the input file
  330.     (NAMES.TXT) and place the output in the file OUTPUT.TXT, which will then
  331.     look like this:
  332.  
  333.                                   JACK       WILLIAMS
  334.                                   JOHNNY     SMITH
  335.                                   MARY       JOHNSON
  336.                                   :          :
  337.                            Column 1          Column 12
  338.  
  339.     Of course, for such a simple task, it would be easier to switch the columns
  340.     yourself, using a text editor.  But when you are dealing with large amounts
  341.     of data, and want to guard against typing errors, Parse-O-Matic can save
  342.     you a lot of time, effort and risk.  It also lets you automate editing
  343.     operations that you perform frequently.
  344.  
  345.  
  346.  
  347.     ===========================================================================
  348.                                   QUICK REFERENCE
  349.     ===========================================================================
  350.  
  351.  
  352.                                 --------------------
  353.                                 Command Descriptions
  354.                                 --------------------
  355.  
  356.     For ease of learning, this manual's detailed explanations of the commands
  357.     are grouped by related functions, in the following order:
  358.  
  359.     ---------------------------------------------------------------------------
  360.     INPUT PARSING COMMANDS
  361.     ---------------------------------------------------------------------------
  362.     SET      Assigns a value to a variable
  363.     IF       Conditionally assigns a value to a variable
  364.     PARSE    Obtains a variable found between delimiters in free-form data
  365.     PEEL     Works like PARSE, but removes the "found" text from the data
  366.  
  367.     ---------------------------------------------------------------------------
  368.     FLOW CONTROL COMMANDS
  369.     ---------------------------------------------------------------------------
  370.     BEGIN    Defines the conditions for processing the code block
  371.     ELSE     Defines the start of code to be processed if the BEGIN fails
  372.     END      Marks the end of a BEGIN/END or BEGIN/ELSE/END code block
  373.     DONE     Reads the next input line and starts at the top of the POM file
  374.     NEXTFILE Skips the current input file and proceeds to the next one
  375.     HALT     Terminates all processing if a given condition exists
  376.     PROLOGUE Defines code block to run before input lines are processed
  377.     EPILOGUE Defines code block to run after  input lines are processed
  378.  
  379.     ---------------------------------------------------------------------------
  380.     OUTPUT COMMANDS
  381.     ---------------------------------------------------------------------------
  382.     OUT      Sends text and variables to the output file
  383.     OUTEND   Like OUT but adds a new line at the end (Carriage Return/Linefeed)
  384.     OUTHDG   Sets up title lines to appear at the top of a report or each page
  385.     PAGELEN  Sets the page length for a report
  386.  
  387.     ---------------------------------------------------------------------------
  388.     FILTER COMMANDS
  389.     ---------------------------------------------------------------------------
  390.     MINLEN   Sets the minimum length required for an input line to be processed
  391.     IGNORE   Ignores an input line that meets the specified condition
  392.     ACCEPT   Accepts an input line that meets the specified condition
  393.     READNEXT Moves to next input line but retains your place in the POM file
  394.  
  395.     ---------------------------------------------------------------------------
  396.     VARIABLE MODIFIERS
  397.     ---------------------------------------------------------------------------
  398.     TRIM     Removes a character from the left, right or all of a variable
  399.     PAD      Centers, or left/right-justifies variable to a specified width
  400.     CHANGE   Replaces all occurances of a string in a variable
  401.     PROPER   Properizes a variable (e.g. "JOHN SMITH" becomes "John Smith")
  402.     INSERT   Inserts a string on the left or right, or at a "found" position
  403.     APPEND   Concatenates several variables into one variable
  404.  
  405.     ---------------------------------------------------------------------------
  406.     CALCULATION COMMANDS
  407.     ---------------------------------------------------------------------------
  408.     CALC     Performs arithmetic functions on integer values
  409.     CALCREAL Performs arithmetic functions on decimal values
  410.  
  411.     ---------------------------------------------------------------------------
  412.     INPUT PREPROCESSORS
  413.     ---------------------------------------------------------------------------
  414.     SPLIT    Breaks up a wide text file (more than 255 characters)
  415.     CHOP     Breaks up a fixed-record-length file
  416.  
  417.     ---------------------------------------------------------------------------
  418.     LOOKUP COMMANDS
  419.     ---------------------------------------------------------------------------
  420.     LOOKUP   Looks up a word in another file and returns a corresponding value
  421.     LOOKFILE Specifies the file that the LOOKUP command will use (see also /L)
  422.     LOOKCOLS Specifies the format of the look-up file
  423.     LOOKSPEC Controls the behaviour of the LOOKUP command
  424.  
  425.     ---------------------------------------------------------------------------
  426.     MISCELLANEOUS COMMANDS
  427.     ---------------------------------------------------------------------------
  428.     TRACE    Traces a variable (results saved in the text file POM.TRC)
  429.     LOG      Adds a line to the processing log
  430.     SETLEN   Sets a variable according to the length of a value
  431.     SOUND    Makes a noise or sets the noise generated by error messages
  432.                                          
  433.  
  434.                                   ---------------
  435.                                   Command Formats
  436.                                   ---------------
  437.  
  438.     The following conventions are used in the table:
  439.  
  440.     "var"   means a variable that is being set.
  441.     "c"     means a comparator (if omitted, defaults to "equals")
  442.     "value" means a variable whose value is being read.
  443.     Square brackets [like this] indicate optional items.
  444.                   
  445.     -------------------------------------------  ------------------------------
  446.     COMMAND FORMATS                              EXAMPLE
  447.     -------------------------------------------  ------------------------------
  448.     ACCEPT   value c value                       ACCEPT   $FLINE[1 3] = "YES"
  449.     APPEND   var value value [value [value]]     APPEND   name first last
  450.     BEGIN    value c value                       BEGIN    linecntr < "3"
  451.     CALCREAL var value operation value           CALCREAL salary hours "*" rate
  452.     CALC     var value oepration value           CALC     total total "+" sold
  453.     CHANGE   var value value                     CHANGE   date "/" "-"
  454.     CHOP     from to [,from to] [...]            CHOP     1 250, 251 300
  455.     DONE     [value c value]                     DONE     $FLINE = "End Data"
  456.     ELSE                                         ELSE
  457.     EPILOGUE                                     EPILOGUE
  458.     END                                          END 
  459.     HALT     value c value value [value]         HALT     x = y "Item repeated"
  460.     IF       value c value var value [value]     IF       x = "Y" THEN z = "N"
  461.     IGNORE   value c value                       IGNORE   price = "0.00"
  462.     INSERT   var spec value                      INSERT   price "L" "$"
  463.     LOG      value c value value                 LOG      x = y "Item repeated"
  464.     LOOKCOLS value value value value             LOOKCOLS "1" "3" "8" "255"
  465.     LOOKFILE value                               LOOKFILE "C:\TABLES\DATA.TBL"
  466.     LOOKSPEC value value value                   LOOKSPEC "Y" "N" "N"
  467.     LOOKUP   var value                           LOOKUP   phonenum "FRED JONES"
  468.     MINLEN   value [value]                       MINLEN   "15"
  469.     NEXTFILE [value c value]                     NEXTFILE $FLINE = "End File"
  470.     OUT      [value c value] |output-picture     OUT      z = "X" |{price}
  471.     OUTEND   [value c value] |output-picture     OUTEND   z = "X" |{$FLINE}
  472.     OUTHDG   value                               OUTHDG   "LIST OF EMPLOYEES"
  473.     PAD      var spec character len              PAD      sernum "L" "0" "10"
  474.     PAGELEN  value [value]                       PAGELEN  "66" "N"
  475.     PARSE    var value from to [control]         PARSE    x $FLINE "2*(" "3*)"
  476.     PEEL     var var from to [control]           PEEL     x $FLINE "2*(" "3*)"
  477.     PROPER   var [methods [exceptions-file]]     PROPER   custname "I" "XY.PEF"
  478.     PROLOGUE                                     PROLOGUE
  479.     READNEXT [value c value]                     READNEXT $FLINE[1 5] = "NOTE:"
  480.     SET      var value                           SET      name $FLINE[20 26]
  481.     SETLEN   var value                           SETLEN   length custname
  482.     SOUND    value                               SOUND    "BUZZ"
  483.     SPLIT    from to [,from to] [...]            SPLIT    1 250, 251 300
  484.     TRACE    var                                 TRACE    price
  485.     TRIM     var spec character                  TRIM     price "R" "$"
  486.     -------------------------------------------  ------------------------------
  487.  
  488.     The commands are explained in detail in the following section.  A summary
  489.     of the commands and default settings appear in the comments at the
  490.     beginning of the file EXAMPL04.POM.  You can copy these comments into your
  491.     own POM file as a convenient quick reference.
  492.  
  493.  
  494.  
  495.     ===========================================================================
  496.                                INPUT PARSING COMMANDS
  497.     ===========================================================================
  498.  
  499.  
  500.                                   ---------------
  501.                                   The SET Command
  502.                                   ---------------
  503.  
  504.     FORMAT:  SET var1 value1
  505.  
  506.     SET assigns a value to a variable.  The usual reason to do this is to set a
  507.     variable from the input line (represented by the variable $FLINE) prior to
  508.     cleaning it up with TRIM. For example, if the input line looked like this:
  509.  
  510.         JOHN       SMITH     555-1234   322 Westchester Lane    Architect
  511.         |          |         |          |                       |
  512.         Column 1   Col 12    Col 22     Col 33                  Col 57
  513.  
  514.     then we could extract the last name from the input line with these two POM
  515.     commands:
  516.  
  517.         SET  NAME = $FLINE[12 21]      (Sets the variable from the input line)
  518.         TRIM NAME  "R"  " "            (Trims any spaces on the right side)
  519.  
  520.     SET would first set the variable NAME to this value:     "SMITH     "
  521.     After the TRIM, the variable NAME would have the value:  "SMITH"
  522.  
  523.     You will also use SET if you plan to include a substring of $FLINE in the
  524.     output, since the OUT and OUTEND commands do not recognize substrings after
  525.     the "|" marker, only complete variables.
  526.  
  527.  
  528.                                    --------------
  529.                                    The IF Command
  530.                                    --------------
  531.  
  532.     FORMAT:  IF value1 [comparator] value2 var1 value3 [value4]
  533.  
  534.     NOTE:    For an explanation of comparators, see the section "Comparators".
  535.              In the following explanation, we will demonstrate the command
  536.              using only the "equals" ("=") comparator.
  537.  
  538.     If value1 equals value2, var1 is set to value3.  Otherwise, it is set to
  539.     value4 (if value4 is missing, nothing is done, and var1 is not changed).
  540.     Here's an example of the IF command...
  541.  
  542.         SET  EARNING = $FLINE[20 23]
  543.         IF   EARNING = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  544.  
  545.     This obtains the value between columns 20 and 26, then checks if it equals
  546.     "0.00".  If it does, the variable BONUS is set to 0.00.  If not, BONUS is
  547.     set to "1.00". The "THEN" and "ELSE" are "padding" and can be omitted.
  548.  
  549.  
  550.                             ---------------------------
  551.                             The PARSE and PEEL Commands
  552.                             ---------------------------
  553.  
  554.     FORMAT:  PARSE var1 value1 from to [control]
  555.              PEEL  var1 var2   from to [control]
  556.  
  557.     NOTE:    PARSE is a very powerful command.  As a result, the explanation
  558.              is somewhat complex.  If you are reading this manual for the
  559.              first time, you may wish to skip this part for now, and come
  560.              back to it later.
  561.  
  562.     The PARSE command is used for extracting information from an input line
  563.     that does not have its data in precise columns.  Consider the following
  564.     input file:
  565.  
  566.                       Mouse     Gazelle   Mouse     Elephant
  567.                       Dog       Giraffe   Elk       Mongoose
  568.                       Monkey    Snake     Caribou   Trout
  569.                       |         |         |         |
  570.                       Column 1  Col 11    Col 21    Col 31
  571.  
  572.     Extracting data that is arranged in tidy columns is simple -- all you need
  573.     is the SET command.  However, you will need a more powerful command if the
  574.     data is in "free-form", like this:
  575.  
  576.                             Mouse,Gazelle,Mouse,Elephant
  577.                             Dog,Giraffe,Elk,Mongoose
  578.                             Monkey,Snake,Caribou,Trout
  579.  
  580.     The PARSE command lets you extract the "Nth" item.  For example, to extract
  581.     the third item in each line in the free-form example above, you could use
  582.     this command:
  583.  
  584.         PARSE  xyz  $FLINE  "2*,"  "3*,"
  585.  
  586.     This means "set the variable xyz by looking in $FLINE (the line just read
  587.     from the input file) and taking everything between the second comma and the
  588.     third comma".  For the three lines in the sample input file, the variable
  589.     xyz is set to Mouse, then Elk, then Caribou.
  590.  
  591.     In the "From" specification (i.e. the "2*," part of the command):
  592.  
  593.        2    means "the second occurance"
  594.        *    is a delimiter to mark the end of the occurance number
  595.        ,    is the text you are looking for
  596.  
  597.     Both the "From" and "To" specifications use this format.
  598.  
  599.     Incidentally, the text you are looking for can be more than a single
  600.     character -- it can be up to 80 characters long.  Let's say the input file
  601.     looks like this:
  602.  
  603.                          Mouse:::Gazelle:::Mouse:::Elephant
  604.                          Dog:::Giraffe:::Elk:::Mongoose
  605.                          Monkey:::Snake:::Caribou:::Trout
  606.  
  607.     You can extract the third item in each line with this command:
  608.  
  609.  
  610.            PARSE  xyz  $FLINE  "2*:::"  "3*:::"
  611.                   ___  ______   _ ___    _ ___
  612.                    |     |      |  |     |  |
  613.      Variable to set     |      |  |     |  |
  614.         The value to parse      |  |     |  "To" text being sought
  615.           "From" occurance number  |     "To" occurance number
  616.             "From" text being sought
  617.  
  618.     This command sets the variable xyz to Mouse, then Elk, then Caribou.
  619.  
  620.     The PARSE command is particularly useful for extracting information from
  621.     comma-delimited files.  Here is an example of a comma-delimited file:
  622.  
  623.                         "Mouse","Gazelle","Mouse","Elephant"
  624.                         "Dog","Giraffe","Elk","Mongoose"
  625.                         "Monkey","Snake","Caribou","Trout"
  626.  
  627.     You can extract all the fields with this series of commands (note the use
  628.     of doubled-up quotes to represent a single quotation mark -- see the
  629.     section "Delimiters" for details):
  630.  
  631.         PARSE  field1  $FLINE  "1*"""  "2*"""
  632.         PARSE  field2  $FLINE  "3*"""  "4*"""
  633.         PARSE  field3  $FLINE  "5*"""  "6*"""
  634.         PARSE  field4  $FLINE  "7*"""  "8*"""
  635.  
  636.     For the first line of the sample input file, field1 is set to Mouse, field2
  637.     is set to Gazelle, and so on.
  638.  
  639.     The occurance number is not always needed.  Here are some variations of
  640.     the "From" specification that you might find helpful:
  641.             
  642.         ""      = Start from the first character in the value being parsed
  643.         "XYZ"   = Start from the first "XYZ" found in the value being parsed
  644.  
  645.     Similar variations can be used with the "To" specification:
  646.             
  647.         ""      = End with the last character in the value being parsed
  648.         "XYZ"   = End with the first "XYZ" found in the value being parsed
  649.  
  650.     The occurance number must be between 1 and 255.  The following lines are
  651.     not valid PARSE commands:
  652.  
  653.         PARSE  xyz  $FLINE  "0*,"  "1*,"      (uses 0)
  654.         PARSE  xyz  $FLINE  "1*,"  "256*,"    (uses 256)
  655.  
  656.     The occurance number is always be followed by a "*" so you can search for a
  657.     number.  Consider the following example (the meaning of which would be
  658.     unclear without the "*" delimiter):
  659.  
  660.         PARSE  xyz  "XXX2YYY2ZZZ2"  "1*2"  "2*2"
  661.  
  662.     This sets xyz to the text occuring between the first "2" and the second
  663.     "2".  In other words, xyz is set to "YYY".
  664.  
  665.     If PARSE does not find the search text, or if the "To" text occurs before
  666.     the "From" text, the variable will be set to a null ("").  Here are several
  667.     examples:
  668.  
  669.         PARSE  abc  "ABCDEFGHIJ"  "1*K"  "1*J"     (There is no "K")
  670.         PARSE  abc  "ABCDEFGHIJ"  "1*A"  "1*X"     (There is no "X")
  671.         PARSE  abc  "ABCDEFGHIJ"  "1*J"  "1*A"     ("J" comes after "A")
  672.  
  673.     The PARSE command has an optional "control" parameter, which tells PARSE
  674.     whether to include or exclude the text that was found.  By default (as
  675.     shown in all of the preceding examples), the found text is excluded.
  676.     However, if you want to include the found text, you can add "I" at the end
  677.     of the PARSE command, as in this example:
  678.  
  679.         PARSE  xyz  "aXcaYcaZc"  "2*a"  "2*c"  "I"
  680.  
  681.     This sets the variable xyz to "aYc".  You can also set the control
  682.     specification to "X" (meaning "exclude"), although since this is the
  683.     default setting for PARSE, it really isn't necessary.  Here is an example:
  684.  
  685.         PARSE  xyz  "a1ca2ca3c"  "2*a"  "2*c"  "X"
  686.  
  687.     This sets the variable xyz to "2".
  688.  
  689.     There is one exception to the behaviour of the control setting.  If you
  690.     use the null ("") specification for "From" or "To", the "found" value
  691.     (the first character for "From", or the last character for "To") will
  692.     always be included.  Here is an example:
  693.  
  694.         PARSE  xyz  "ABCABCABC"  ""  "2*C"
  695.  
  696.     This sets the variable xyz to "ABCAB".  The "From" value (i.e. the first
  697.     character) is not excluded.  However, when PARSE finds the "To" value (i.e.
  698.     the second occurance of the letter C) it is excluded.  If you want to
  699.     include the second "C", you should write the command this way:
  700.  
  701.         PARSE  xyz  "ABCABCABC"  ""  "2*C"  "I"
  702.  
  703.     The following two commands accomplish the same thing:
  704.  
  705.         PARSE  xyz  "ABCD"  ""  ""
  706.         SET    xyz  "ABCD"
  707.  
  708.     They are equivalent because the PARSE command means "Set the variable xyz
  709.     with everything between (and including) the first and last character".
  710.  
  711.     The reason that PARSE treats the null ("") specification differently may
  712.     not be immediately obvious, since the examples given here are very simple,
  713.     and not representative of "real world" applications. However, in day-to-day
  714.     usage, you will frequently find it helpful to be able to specify a command
  715.     that says, "Give me everything from the beginning of the line to just
  716.     before such-and-such".
  717.  
  718.     Here is a command that means "Give me everything from just after the dollar
  719.     sign, to the end of the line":
  720.  
  721.         PARSE  xyz  "I'd like to have $250.00"  "1*$"  ""
  722.  
  723.     This sets xyz to "250.00".  If you want to include the dollar sign, write
  724.     the command this way:
  725.  
  726.         PARSE  xyz  "I'd like to have $250.00"  "1*$"  ""  "I"
  727.  
  728.     For more examples of the PARSE command, see the demonstrations provided
  729.     with Parse-O-Matic (type START at the DOS prompt, then select TUTORIAL).
  730.  
  731.     The PEEL command works just like PARSE, but after setting var1, it REMOVES
  732.     the parsed value (including the delimiters) from var2.  When you are
  733.     breaking up a complex line into fields, this can simplify matters
  734.     considerably, because the line gradually becomes less complex.
  735.  
  736.     Here is a simple example.  Let's say you have an input file containing a
  737.     single line:
  738.  
  739.         AA/BB/CC/DD
  740.  
  741.     If you run this POM file against the input file:
  742.  
  743.         PEEL   x $FLINE "" "/"       <--- Strips out the AA, removes the /
  744.         OUTEND |{x}
  745.         PEEL   x $FLINE "" "/"       <--- Strips out the BB, removes the /
  746.         OUTEND |{x}
  747.         PEEL   x $FLINE "" "/"       <--- Strips out the CC, removes the /
  748.         OUTEND |{x}
  749.         OUTEND |{$FLINE}
  750.  
  751.     then the output file will look like this:
  752.  
  753.         AA
  754.         BB
  755.         CC
  756.         DD
  757.  
  758.     What is happening is that $FLINE is gradually being stripped of the text
  759.     that is being found.  After the first PEEL, $FLINE contains "BB/CC/DD",
  760.     and so on.  After the final PEEL, $FLINE only contains "DD".
  761.  
  762.     The "I" and "X" control parameters behave the same way as they do in the
  763.     PARSE command.  Take note, however, that the starting and ending characters
  764.     are always removed, along with the "found" text, regardless of the control
  765.     parameter.  The control parameter only affects the first variable (x in the
  766.     example above), not the second ($FLINE in the example).
  767.                           
  768.  
  769.  
  770.     ===========================================================================
  771.                                FLOW CONTROL COMMANDS
  772.     ===========================================================================
  773.   
  774.  
  775.                           --------------------------------
  776.                           The BEGIN, ELSE and END Commands
  777.                           --------------------------------
  778.  
  779.     The format for the BEGIN and END commands is as follows:
  780.  
  781.     BEGIN value1 [comparator] value2
  782.     :
  783.     Dependant code
  784.     :
  785.     END
  786.  
  787.     NOTE:    For an explanation of comparators, see the section "Comparators".
  788.              In the following explanation, we will demonstrate the command
  789.              using only the "equals" ("=") comparator.
  790.  
  791.     If value1 equals value2, then the dependant code (the POM lines between
  792.     the BEGIN and the END) are executed.  If value1 does not equal value2,
  793.     then the dependant code is skipped.
  794.  
  795.     It is traditional in programming to indent code that appears in blocks
  796.     such as Parse-O-Matic's BEGIN/END technique.  This makes the logic of
  797.     the program easier to understand.  For example:
  798.  
  799.     BEGIN datatype = "Employee"
  800.       SET phone    = $FLINE[ 1 10]
  801.       SET address  = $FLINE[12 31]
  802.     END
  803.  
  804.     BEGIN/END blocks can be nested.  That is to say, you can have BEGIN/END
  805.     blocks inside other BEGIN/END blocks.  Here is an example, with arrows
  806.     to indicate the levels of each BEGIN/END block...
  807.  
  808.     BEGIN datatype = "Employee"      <---------------------
  809.       SET phone    = $FLINE[ 1 10]                        |
  810.       SET address  = $FLINE[12 31]                        |
  811.       SET areacode = phone[1 3]                           | First
  812.       BEGIN areacode = "514"         <------- Second      | Level
  813.         SET local = "Y"                     | Level       | Block
  814.         SET tax   = "Y"              <------- Block       |
  815.       END                                                 |
  816.     END                              <---------------------
  817.  
  818.     In this case, the "inner" block (starting with BEGIN areacode = "514") is
  819.     reached only if the "outer" block (BEGIN datatype = "Employee") is true.
  820.     If the outer block is false, the inner block is ignored.
  821.  
  822.     A nested BEGIN/END block must always be completely inside the outer block.
  823.     Study the following (incorrect) example:
  824.  
  825.     BEGIN datatype = "Employee"             <----
  826.       SET phone    = $FLINE[ 1 10]              |  First
  827.       SET areacode = phone[1 3]                 |  Level
  828.       BEGIN areacode = "514"         <---       |  Block?
  829.         SET local = "Y"                 |       |
  830.     END                                 |   <----
  831.       SET tax = "Y"                     |
  832.       END                            <---  Second Level Block?
  833.  
  834.     Parse-O-Matic does not pay attention to the indenting -- it is only a
  835.     tradition we use to make the file easier to read.  The code will be
  836.     understood this way:
  837.  
  838.     BEGIN datatype = "Employee"      <---------------------
  839.       SET phone    = $FLINE[ 1 10]                        | First
  840.       SET areacode = phone[1 3]                           | Level
  841.       BEGIN areacode = "514"         <--- Second          | Block
  842.         SET local = "Y"                 | Level           |
  843.       END                            <--- Block           |
  844.       SET tax = "Y"                                       |
  845.     END                              <---------------------
  846.  
  847.     You can nest BEGIN/END blocks up to 25 deep -- although it is unlikely you
  848.     will ever need that much nesting.  Here is an example of code that uses
  849.     nesting up to three deep:
  850.  
  851.     BEGIN datatype = "Dog"           <----------------------------------
  852.       SET breed = $FLINE[1 10]                                         | First
  853.       BEGIN breed = "Collie"         <-----------------------          | Level
  854.         SET noise = "Woof"                                  | Second   | Block
  855.         BEGIN name = "Spot"          <------ Third          | Level    |
  856.           SET attitude = "Friendly"        | Level          | Block    |
  857.         END                          <------ Block          |          |
  858.       END                            <-----------------------          |
  859.       BEGIN breed = "Other"          <----------------------- Another  |
  860.         SET noise = "Arf"                                   | Second   |
  861.         SET attitude = "Unknown"                            | Level    |
  862.       END                            <----------------------- Block    |
  863.     END                              <----------------------------------
  864.  
  865.     Once again, the indentation is for clarity only and does not affect the
  866.     way the POM file runs.  However, you will find that it makes your POM
  867.     file much easier to understand.
  868.  
  869.     The ELSE command tells Parse-O-Matic to execute the following block of code
  870.     (up until the END command) if the corresponding BEGIN comparison is NOT
  871.     true.
  872.  
  873.     NOTE:  The ELSE command should not be confused with the ELSE used to pad
  874.            the IF statement (e.g. IF $FLINE[1] = "3" THEN x = "Y" ELSE "N"). In
  875.            the IF command, the ELSE is included to make the statement easier to
  876.            understand, and can be omitted (e.g. IF $FLINE[1] "3" x "Y" "N").
  877.  
  878.     The format of a BEGIN/ELSE/END block is as follows:
  879.  
  880.     BEGIN value1 [comparator] value2
  881.     :
  882.     Code that is run if the comparison is true
  883.     :
  884.     ELSE
  885.     :
  886.     Code that is run if the comparison is false
  887.     :
  888.     END
  889.  
  890.     Here is an example:
  891.  
  892.     BEGIN $FLINE[1 10] = "JOHN SMITH"
  893.       SET x = "This is John"
  894.     ELSE
  895.       SET x = "This is not John"
  896.     END
  897.  
  898.     If you are using several levels of nesting, you should indent your code to
  899.     show the relationship of the various BEGIN, ELSE and END statements.  Here
  900.     is an example:
  901.  
  902.     BEGIN datatype = "Dog"           <----------------------------------
  903.       SET breed = $FLINE[1 10]                                         | First
  904.       BEGIN breed = "Collie"         <-----------------------          | Level
  905.         SET noise = "Woof"                                  | Second   | Block
  906.         BEGIN name = "Spot"          <------ Third          | Level    |
  907.           SET attitude = "Friendly"        | Level          | Block    |
  908.         END                          <------ Block          |          |
  909.       ELSE                                                  |          |
  910.         SET noise = "Arf"                                   |          |
  911.         SET attitude = "Unknown"                            |          |
  912.       END                            <-----------------------          |
  913.     END                              <----------------------------------
  914.  
  915.     The ELSE is at "Level 2".  This is because there are three BEGINs ahead of
  916.     it, but only one END (3 - 1 = 2).  Here are two helpful rule to remember:
  917.  
  918.     - A POM file will always contain the same number of BEGINs and ENDs
  919.     - The number of ELSEs can never exceed the number of BEGINs
  920.  
  921.  
  922.                                   ----------------
  923.                                   The DONE Command
  924.                                   ----------------
  925.  
  926.     FORMAT:  DONE [value comparator value]
  927.  
  928.     NOTE:    For an explanation of comparators, see the section "Comparators".
  929.              In the following explanation, we will demonstrate the command
  930.              using only the "equals" ("=") comparator.
  931.  
  932.     The DONE command will discontinue processing the POM file and proceed to
  933.     the next input line, whereupon the POM file will restart at the top.
  934.  
  935.     The DONE command is most useful when you have a long series of BEGIN/END
  936.     blocks which make a related comparison.  For example:
  937.  
  938.         SET   salesrep = $FLINE[11 50]
  939.         SET   region   = $FLINE[ 1  2]
  940.         BEGIN region = "US"
  941.           OUTEND |Sales representative for U.S.A.: {salesrep}
  942.           DONE
  943.         END
  944.         BEGIN region = "CN"
  945.           OUTEND |Sales representative for Canada: {salesrep}
  946.           DONE
  947.         END
  948.         BEGIN region = "EU"
  949.           OUTEND |Sales representative for Europe: {salesrep}
  950.           DONE
  951.         END
  952.         :
  953.         etc.
  954.  
  955.     As you can see, if one of the BEGIN comparisons is true, all of the
  956.     following ones will inevitably be false.  Rather than processing all the
  957.     others, you can use the DONE command to bail out and get ready for the
  958.     next input line.
  959.  
  960.     The DONE command provides two benefits:
  961.  
  962.     - It can speed up processing slightly
  963.     - It makes full traces easier to understand
  964.  
  965.     For an explanation of traces, see the section entitled "Tracing".
  966.  
  967.     Unless you use a comparison (explained later), the DONE command is useful
  968.     only inside BEGIN/ELSE/END blocks.  If you write a POM file like this:
  969.  
  970.         SET custnum  = $FLINE[ 1 10]
  971.         SET custname = $FLINE[11 50]
  972.         DONE
  973.         OUTEND |{custname} {custnum}
  974.  
  975.     the OUTEND statement will NEVER be reached.
  976.  
  977.     Here is how you specify a comparison for the DONE command:
  978.  
  979.         DONE $FLINE = "End of Data"
  980.  
  981.     This discontinues the POM file, and proceeds to the next input line, if the
  982.     current input line ($FLINE) is "End of Data".
  983.  
  984.  
  985.                                 --------------------
  986.                                 The NEXTFILE Command
  987.                                 --------------------
  988.  
  989.     FORMAT:  NEXTFILE [value comparator value]
  990.  
  991.     NOTE:    For an explanation of comparators, see the section "Comparators".
  992.              In the following explanation, we will demonstrate the command
  993.              using only the "equals" ("=") comparator.
  994.  
  995.     The NEXTFILE command is useful when you process multiple input files (see
  996.     "POM and Wildcards").  It discontinues processing the current input file
  997.     and proceeds to the next one.  The POM file restarts from the top.
  998.  
  999.     Here is an example, which we will call TEST.POM:
  1000.  
  1001.         BEGIN $FLINE = "End of Data"
  1002.           OUTEND |{numlines} lines of data printed
  1003.           SET    numlines = ""
  1004.           NEXTFILE
  1005.         END
  1006.         SET    numlines = numlines+
  1007.         OUTEND |{$FLINE}
  1008.  
  1009.     Let's say you have three text files: DATA1.XYZ, DATA2.XYZ and DATA3.XYZ.
  1010.     The last line of each file says "End of Data".  You could copy all three
  1011.     files to the file OUTPUT.TXT with this command:
  1012.  
  1013.         POM TEST.POM DATA?.XYZ OUTPUT.TXT
  1014.  
  1015.     This would copy the data from each file, but when it gets to the line
  1016.     reading "End of Data", it records the number of lines of data that were
  1017.     printed.  Any lines after the "End of Data" line are skipped, because of
  1018.     the NEXTFILE command.
  1019.  
  1020.     The NEXTFILE command can specify a comparison.  Here is an example:
  1021.  
  1022.         NEXTFILE $FLINE = "End of Data"
  1023.         OUTEND |{$FLINE}
  1024.         
  1025.     Assuming the same input files (DATA1.XYZ etc.), and using the same POM
  1026.     command as last time, this POM file would simply copy up to (but not
  1027.     including" the line that reads "End of Data" in each input file.
  1028.  
  1029.     
  1030.                                   ----------------
  1031.                                   The HALT Command
  1032.                                   ----------------
  1033.  
  1034.     FORMAT:  HALT value1 comparison value2 value3 [value4]
  1035.  
  1036.     The HALT command will terminate Parse-O-Matic processing if the comparison
  1037.     is true.  For example:
  1038.  
  1039.         HALT sales = "0" "Zero sales!"
  1040.  
  1041.     If the variable named sales is "0", Parse-O-Matic will display an error
  1042.     box reading "Zero sales!" and terminate after you've pressed a key (or
  1043.     sixty seconds goes by).  A copy of the message is also placed in the
  1044.     processing log POMLOG.TXT (see "Logging").
  1045.  
  1046.     When a HALT condition occurs, Parse-O-Matic terminates with a DOS error
  1047.     level of 100.  You can specify a different value, using value4.  This is
  1048.     useful if you are calling Parse-O-Matic from a batch file and want to
  1049.     handle different errors in different ways.
  1050.  
  1051.     You can set value4 to any number between 100 and 199.  Consider these
  1052.     examples:
  1053.  
  1054.         HALT sales    = "0" "Zero sales"     "150"
  1055.         HALT sales[1] = "-" "Negative sales" "160"
  1056.  
  1057.     This terminates the program with an error level of 150 if sales are zero.
  1058.     If the first character of sales is a minus sign, Parse-O-Matic terminates
  1059.     with an error level of 160.
  1060.  
  1061.     When coding batch files, remember that the IF ERRORLEVEL command is
  1062.     considered "True" if the error is the specified value or higher.  This
  1063.     means you should always test the higher value first.  See your DOS manual
  1064.     for details.
  1065.  
  1066.  
  1067.                                 --------------------
  1068.                                 The PROLOGUE Command
  1069.                                 --------------------
  1070.  
  1071.     The format for PROLOGUE (used in conjunction with the END command) is as
  1072.     follows:
  1073.  
  1074.     PROLOGUE
  1075.     :
  1076.     Dependant code
  1077.     :
  1078.     END
  1079.  
  1080.     The dependant code is run before the first line of the input file is read.
  1081.     You can use this to set up some useful variables, or set up a heading --
  1082.     anything you only want to do once per file, at the very start.
  1083.  
  1084.     Here is an example of the PROLOGUE command:
  1085.  
  1086.         PROLOGUE
  1087.           SET both  = "B"
  1088.           SET space = " "
  1089.         END
  1090.         SET    firstname = $FLINE[ 1 10]
  1091.         SET    lastname  = $FLINE[15 25]
  1092.         TRIM   firstname both space
  1093.         TRIM   lastname  both space
  1094.         OUTEND |{firstname} {lastname}
  1095.  
  1096.     When the input file is first opened, the PROLOGUE section sets the
  1097.     variables "both" and "space".  Once they're set, you don't have to change
  1098.     them (since you're just using them to make the code easier to read).  Thus,
  1099.     it makes sense to set them only at the beginning of processing and not
  1100.     bother setting them each time the POM file is executed (i.e. each time an
  1101.     input line is read).
  1102.  
  1103.     If you are working with multiple files (see "POM and Wildcards"), the
  1104.     PROLOGUE is run for each input file.  If you want to run some code for
  1105.     the first file only, you can set a "flag", as in this example:
  1106.  
  1107.         BEGIN firstfile = ""
  1108.           SET firstfile = "N"
  1109.           OUTEND |First file only
  1110.         ELSE
  1111.           OUTEND |Subsequent files
  1112.         END
  1113.         NEXTFILE
  1114.  
  1115.     If you run this POM file on several files at once, using wildcards, the
  1116.     first line of the output file will contain the words "First file only",
  1117.     since the variable "firstfile" has not yet been assigned a value.  On
  1118.     subsequent files, the variable will have the value "N", so the following
  1119.     lines of the output file will read "Subsequent files".
  1120.  
  1121.  
  1122.                                 --------------------
  1123.                                 The EPILOGUE Command
  1124.                                 --------------------
  1125.  
  1126.     The format for EPILOGUE (used in conjunction with the END command) is as
  1127.     follows:
  1128.  
  1129.     EPILOGUE
  1130.     :
  1131.     Dependant code
  1132.     :
  1133.     END
  1134.  
  1135.     The dependant code is run after the last line of the input file is read
  1136.     and the POM file is executed to process it.  In other words, once all the
  1137.     input data is finished, the POM file runs one last time -- but only the
  1138.     code in the EPILOGUE section.
  1139.  
  1140.     You can use this to output final results.  Let's say your input file looks
  1141.     like this:
  1142.  
  1143.         DESCRIPTION      UNITS SOLD    UNIT PRICE
  1144.         Wildebeest food         325    $     9.99
  1145.         Horse cologne            13    $     3.25
  1146.         Moose alarm             210    $     5.95
  1147.         :                :        :     :       :    (Column positions)
  1148.         1               18       27    33      41    
  1149.  
  1150.     You can find out the total number of units sold (of all types) with the
  1151.     following POM file:
  1152.  
  1153.         IGNORE $FLINE[1 7] = "DESCRIP"
  1154.         CALC   units = units "+" $FLINE[18 27]
  1155.         EPILOGUE
  1156.           OUTEND |Total units sold = {units}
  1157.         END
  1158.  
  1159.     This POM file adds up the number of units sold.  The only output is the
  1160.     single line generated by the OUTEND in the EPILOGUE.
  1161.  
  1162.     If you are processing multiple files (see "POM and Wildcards"), the
  1163.     EPILOGUE is run after each input file is finished.
  1164.  
  1165.  
  1166.  
  1167.     ===========================================================================
  1168.                                   OUTPUT COMMANDS
  1169.     ===========================================================================
  1170.     
  1171.  
  1172.                             ---------------------------
  1173.                             The OUT and OUTEND Commands
  1174.                             ---------------------------
  1175.  
  1176.     FORMAT:  OUT[END] [value1 [comparator] value2] |output-picture
  1177.  
  1178.     NOTE:    For an explanation of comparators, see the section "Comparators".
  1179.              In the following explanation, we will demonstrate the command
  1180.              using only the "equals" ("=") comparator.
  1181.  
  1182.     The OUT command generates output without an end-of-line (i.e. carriage
  1183.     return and linefeed characters).  The OUTEND command generates output and
  1184.     also adds an end-of-line.
  1185.  
  1186.     When value1 equals value2, a line is sent to the output file, according to
  1187.     the output picture.  Within the output picture, all text is taken literally
  1188.     (i.e. " is taken to mean literally that -- a quotation mark character).
  1189.  
  1190.     The only exception to this is variable names, which are identified by the
  1191.     { and } characters.  For example, a POM file that contained the following
  1192.     single line:
  1193.  
  1194.         OUTEND "X" = "X" |{$FLINE}
  1195.  
  1196.     would simply output every line from the input file (not very useful!).
  1197.  
  1198.     The "X" = "X" part of the command is the comparison which controls when
  1199.     output occurs.  In the example above, both values being compared are the
  1200.     same, so output will always occur.
  1201.  
  1202.     You can not use substrings after the "|" marker.  Thus, the following line
  1203.     is NOT legal:  OUTEND $FLINE[1 3] = "IBM" |{$FLINE[1 15]}
  1204.  
  1205.     The correct way to code this is as follows:
  1206.  
  1207.         SET CODE = $FLINE[1 15]
  1208.         OUTEND $FLINE[1 3] = "IBM" |{CODE}
  1209.  
  1210.     This outputs the first 15 characters of any line that contains the letters
  1211.     "IBM" in the first three positions.
  1212.  
  1213.  
  1214.                           -------------------------------
  1215.                           The OUTHDG and PAGELEN Commands
  1216.                           -------------------------------
  1217.  
  1218.     FORMAT:  OUTHDG value1
  1219.     FORMAT:  PAGELEN value1 [value2]
  1220.  
  1221.     OUTHDG is used to place text headers in your output.  For example, if you
  1222.     were parsing data to create an employee report, you might use OUTHDG like
  1223.     this:
  1224.  
  1225.         SET EMPNUM = $FLINE[ 1  5]
  1226.         SET NAME   = $FLINE[10 28]
  1227.         SET PHONE  = $FLINE[30 45]
  1228.         OUTHDG "EMPL#  NAME                PHONE NUMBER"
  1229.         OUTHDG "-----  ------------------- ------------"
  1230.         OUTEND |{EMPNUM} {NAME} {PHONE}
  1231.  
  1232.     The value following the OUTHDG command is sent to the output file only
  1233.     once.  That is to say, after an OUTHDG sends a value to the output file,
  1234.     subsequent encounters with that OUTHDG command are ignored -- unless the
  1235.     PAGELEN command is used.
  1236.  
  1237.     The PAGELEN command specifies the length of the output page.  Lines from
  1238.     both OUTHDG and OUTEND are counted.  The default value for page length is
  1239.     zero, which means that the output is a single page of infinite length.  As
  1240.     such, OUTHDG headings appear only the first time they are encountered.
  1241.  
  1242.     If you specify a page length greater than zero, OUTHDG headings become
  1243.     re-enabled once the specified number of output lines have been generated.
  1244.     A typical value is as follows:
  1245.  
  1246.         PAGELEN "55"
  1247.  
  1248.     This is an ideal page length for most laser printers.  Dot matrix printers
  1249.     typically use a page length of 66.
  1250.  
  1251.     Parse-O-Matic inserts a "form feed" (ASCII 12) character between pages.
  1252.     You can turn this off, however, by specifying the page length this way:
  1253.  
  1254.         PAGELEN "66" "N"
  1255.  
  1256.     The "N" specification means, "No, don't use form feeds".  Another
  1257.     acceptable value is "Y", meaning "Yes, use form feeds", but since this is
  1258.     the default, you do not have to specify it.
  1259.  
  1260.  
  1261.     ===========================================================================
  1262.                                   FILTER COMMANDS
  1263.     ===========================================================================
  1264.  
  1265.  
  1266.                                  ------------------
  1267.                                  The MINLEN Command
  1268.                                  ------------------
  1269.  
  1270.     FORMAT:  MINLEN value1 [value2]
  1271.  
  1272.     DEFAULTS:  value2 = "0"
  1273.  
  1274.     MINLEN specifies the minimum length a line must be to be considered for
  1275.     parsing.  If you omit the MINLEN command, the minimum length is assumed to
  1276.     be 1.  That is to say, all lines 1 character or longer will be processed
  1277.     and shorter lines (null lines in other words) will be ignored.
  1278.  
  1279.     MINLEN is useful for ignoring brief information lines that clutter up a
  1280.     report that you are parsing.  For example, in the sample file EXAMPL02.POM,
  1281.     the MINLEN command is set to 85 to ensure that all lines shorter than 85
  1282.     characters long will be ignored.  This simplifies the coding considerably.
  1283.  
  1284.     The longest allowable input line is 255 characters, unless you use the
  1285.     SPLIT or CHOP command (described later).
  1286.  
  1287.     The optional setting value2 specifies the minimum length for a READNEXT
  1288.     command.  If omitted, this value is assumed to be "0", meaning that
  1289.     READNEXT will, by default, read null lines.  If you set value2 to "1",
  1290.     READNEXT will keep reading until it finds an input line of 1 or more
  1291.     characters, or hits the end of file.
  1292.                               
  1293.  
  1294.                                  ------------------
  1295.                                  The IGNORE Command
  1296.                                  ------------------
  1297.  
  1298.     FORMAT:  IGNORE value1 [comparator] value2
  1299.  
  1300.     NOTE:    For an explanation of comparators, see the section "Comparators".
  1301.              In the following explanation, we will demonstrate the command
  1302.              using only the "equals" ("=") comparator.
  1303.  
  1304.     When value1 contains value2, the input line is ignored and all further
  1305.     processing on the input line stops.  The usual format of this command is as
  1306.     in this example:
  1307.  
  1308.         IGNORE $FLINE[3 9] = "Date"
  1309.  
  1310.     This skips any input line that contains the word "Date" between columns 3
  1311.     and 9 ($FLINE is the line just read from the input file).
  1312.                               
  1313.  
  1314.                                  ------------------
  1315.                                  The ACCEPT Command
  1316.                                  ------------------
  1317.  
  1318.     FORMAT:  ACCEPT value1 [comparator] value2
  1319.  
  1320.     NOTE:    For an explanation of comparators, see the section "Comparators".
  1321.              In the following explanation, we will demonstrate the command
  1322.              using only the "equals" ("=") comparator.
  1323.  
  1324.     The ACCEPT command accepts the input line if value1 contains value2.  For
  1325.     example, if the entire POM file read as follows:
  1326.  
  1327.         ACCEPT $FLINE[15 17] = "YES"
  1328.         OUTEND "X" = "X" |{$FLINE}
  1329.  
  1330.     then any input line that contains "YES" starting in column 15 is sent to
  1331.     the output file.  All other lines are ignored.
  1332.  
  1333.     CLUSTERED ACCEPTS: Sometimes you have to check more than one value to see
  1334.     if the input line is valid.  You do this by using "clustered ACCEPTs",
  1335.     which are several ACCEPT commands in a row.
  1336.  
  1337.     Briefly stated, if you have several ACCEPTs in a row ("clustered"), they
  1338.     are all processed to determine if the input line is acceptable or not.  If
  1339.     even one ACCEPT matches up, the line is accepted.  To express this in more
  1340.     detail...
  1341.  
  1342.     When value1 contains value2, the line is accepted, and processing of the
  1343.     POM file continues for that input line, even if the immediately following
  1344.     ACCEPTs do NOT produce a match.  After all, we've already got a match!
  1345.  
  1346.     If value1 does NOT contain value2, Parse-O-Matic looks at the next commmand
  1347.     in the POM file.  If it is not another ACCEPT, the input line is ignored.
  1348.     If it is another ACCEPT, maybe it will product a match -- so Parse-O-Matic
  1349.     moves to that command.
  1350.  
  1351.     The following POM file uses clustered ACCEPTs to accept any line that
  1352.     contains the name "FRED" or "MARY" between columns 5 and 8, or contains the
  1353.     word "MEMBER" between columns 20 and 25.
  1354.  
  1355.         SET    NAME = $FLINE[5 8]         (Set the variable)
  1356.         ACCEPT NAME = "FRED"              (Look for FRED)
  1357.         ACCEPT NAME = "MARY"              (Look for MARY)
  1358.         ACCEPT $FLINE[20 25] = "MEMBER"   (Look for MEMBER)
  1359.         OUTEND "X" = "X" |{$FLINE}        (Output the line if we get this far)
  1360.  
  1361.     The following example will NOT work, however:
  1362.  
  1363.         ACCEPT $FLINE[20 25] = "MEMBER"
  1364.         SET    NAME = $FLINE[5 8]
  1365.         ACCEPT NAME = "FRED"
  1366.         ACCEPT NAME = "MARY"
  1367.         OUTEND "X" = "X" |{$FLINE}
  1368.  
  1369.     It will not work because the ACCEPTs are not clustered; if the first ACCEPT
  1370.     fails, the input line is rejected as soon as the SET command is
  1371.     encountered.  The next two ACCEPTs are not reached in such case.
  1372.  
  1373.  
  1374.                                 --------------------
  1375.                                 The READNEXT Command
  1376.                                 --------------------
  1377.  
  1378.     FORMAT:  READNEXT [value comparator value]
  1379.  
  1380.     NOTE:    For an explanation of comparators, see the section "Comparators".
  1381.              In the following explanation, we will demonstrate the command
  1382.              using only the "equals" ("=") comparator.
  1383.  
  1384.     The READNEXT command gets the next line of the input file (in other words,
  1385.     it replaces the current $FLINE), while maintaining your place in the POM
  1386.     file.  This is helpful if you know for certain what the next line will
  1387.     contain.  Here is an example:
  1388.  
  1389.         SET note = ""
  1390.         SET customer = $FLINE[1 20]
  1391.         BEGIN $FLINE ^ "See note below"
  1392.           READNEXT
  1393.           SET note = $FLINE[1 20]
  1394.         END
  1395.         OUTEND |{customer} {note}
  1396.  
  1397.     If the input line contains the words "See note below", Parse-O-Matic will
  1398.     read the next line of the input file (replacing the current $FLINE), thus
  1399.     obtaining the comment about the customer.
  1400.  
  1401.     By default, READNEXT can read null lines from the input file.  If you want
  1402.     to ignore null lines, you can use an optional parameter of the MINLEN
  1403.     command to specify a minimum length for the READNEXT command.  For details,
  1404.     see "The MINLEN Command".
  1405.  
  1406.     When you do a READNEXT, there is no way to return to the previous line of
  1407.     the input file.  If you need it for other work, you should save a copy:
  1408.  
  1409.         SET note = ""
  1410.         SET customer = $FLINE[1 20]
  1411.         SET saveline = $FLINE
  1412.         BEGIN $FLINE ^ "See note below"
  1413.           READNEXT
  1414.           SET note = $FLINE[1 20]
  1415.         END
  1416.         SET    custnum = saveline[22 25]
  1417.         OUTEND |{custnum} {customer} {note}
  1418.  
  1419.     The example above is not very efficient; it would make more sense to
  1420.     extract custnum BEFORE you use READNEXT. However, in some instances you may
  1421.     find it more convenient to save $FLINE before doing a READNEXT.
  1422.  
  1423.     READNEXT can make a comparison.  This is useful for skipping extraneous
  1424.     lines of input.  For example:
  1425.  
  1426.         READNEXT $FLINE[1 5] = "NOTE:"
  1427.  
  1428.     This obtains the next input line if the current input line starts with
  1429.     "NOTE:".
  1430.  
  1431.  
  1432.  
  1433.     ===========================================================================
  1434.                                  VARIABLE MODIFIERS
  1435.     ===========================================================================
  1436.   
  1437.  
  1438.                                   ----------------
  1439.                                   The TRIM Command
  1440.                                   ----------------
  1441.  
  1442.     FORMAT:  TRIM var1 spec1 character
  1443.  
  1444.     TRIM removes characters from var1.  This is usually used to remove blanks.
  1445.  
  1446.     spec1 can be:  A=All   B=Both ends   L=Left side only   R = Right side only
  1447.  
  1448.     For example:
  1449.  
  1450.         SET  PRICE = $FLINE[20 26]
  1451.         TRIM PRICE "A" ","
  1452.         TRIM PRICE "L" "$"
  1453.  
  1454.     This removes all commas from the variable "PRICE", and removes the leading
  1455.     dollar sign.  Thus:
  1456.  
  1457.         If the input contains the string:   "$25,783"
  1458.         The first TRIM changes it to:       "$25783"
  1459.         The second TRIM changes it to:      "25783"
  1460.  
  1461.  
  1462.                                   ---------------
  1463.                                   The PAD Command
  1464.                                   ---------------  
  1465.  
  1466.     FORMAT:  PAD var1 spec1 character len
  1467.  
  1468.     PAD makes var1 a specified length, padded with a specified character.
  1469.  
  1470.         spec1      is "L", "R", or "C" (Left, Right or Center)
  1471.         character  is the character used to pad the string
  1472.         len        is the desired string length
  1473.  
  1474.     For example, if the variable ABC is set to "1234" ...
  1475.  
  1476.     PAD ABC "L" "0" "7"   left-pads it 7 characters wide with zeros ("0001234")
  1477.     PAD ABC "R" " " "5"   right-pads it 5 characters wide with spaces ("1234 ")
  1478.     PAD ABC "C" "*" "8"   centers it, 8 wide, with asterisks ("**1234**")
  1479.  
  1480.     If the length is less than the length of the string, it is unchanged.  For
  1481.     example, if you set variable XYZ to "PINNACLE", then
  1482.  
  1483.         PAD XYZ "R" " " "3"
  1484.  
  1485.     leaves the string as-is ("PINNACLE").
  1486.  
  1487.     Thus, PAD can not be used to shorten a string.  If it is your intention to
  1488.     make XYZ 3 letters long, you can use the SET command:
  1489.  
  1490.         SET XYZ = XYZ[1 3]
  1491.  
  1492.  
  1493.                                  ------------------
  1494.                                  The CHANGE Command
  1495.                                  ------------------
  1496.  
  1497.     FORMAT:  CHANGE var1 value1 value2
  1498.  
  1499.     The CHANGE command replaces ALL occurances of value1 with value2.  This is
  1500.     more powerful than TRIM, but is not as efficient.  Here is an example of
  1501.     the CHANGE command in action:
  1502.  
  1503.         SET    DATE = $FLINE[31 38]
  1504.         CHANGE DATE "/" "--"
  1505.  
  1506.     If the SET command assigns DATE the value:    "93/10/15"
  1507.     Then the CHANGE command converts it to:       "93--10--15"
  1508.  
  1509.  
  1510.                                  ------------------
  1511.                                  The PROPER Command
  1512.                                  ------------------
  1513.  
  1514.     FORMAT:  PROPER var1 [methods [exceptions-file]]
  1515.  
  1516.     The PROPER command converts uppercase text (LIKE THIS) to mixed-case text
  1517.     (Like This).  This is useful when you have a list of names of people and
  1518.     addresses.  You can also use PROPER to change text that has been typed
  1519.     in uppercase into normal text, with capital letters at the beginning of
  1520.     sentences.
  1521.  
  1522.     The simplest way to convert a variable is as follows:
  1523.  
  1524.         PROPER CustName
  1525.  
  1526.     If CustName contains "JOHN SMITH", it will be changed to "John Smith".
  1527.  
  1528.     The conversion routine is fairly intelligent.  For example, if it is
  1529.     converting the words "JAGUAR XJS", it can tell that XJS is not a word
  1530.     (since it does not contain any vowels) and so the the end result will
  1531.     be "Jaguar XJS".  Other "strange-looking" items such as serial numbers
  1532.     can often be recognized by the PROPER command, and left untouched.
  1533.  
  1534.     Nevertheless, it is impossible to handle all situations, so the PROPER
  1535.     command supports a "Properization Exceptions File" (known as a PEF file).
  1536.     A PEF file lists unusual combinations of letters (typically abbreviations,
  1537.     such as Dr.).  The Parse-O-Matic package includes a file named GENERIC.PEF,
  1538.     which you may find helpful.  You can view it with the SEE program provided
  1539.     with Parse-O-Matic.
  1540.  
  1541.     A PEF file is prepared with a text editor and contains one "exception" per
  1542.     line.  Null or blank lines, or lines that start with a semicolon, are
  1543.     ignored.  The longest word that can be specified is 255 characters.
  1544.     Spaces are permitted, but leading and trailing spaces and tabs are ignored.
  1545.  
  1546.     To use the PEF file in your PROPER command, place the file name after the
  1547.     variable name and method setting.  For example:
  1548.  
  1549.         PROPER CustName "W" "GENERIC.PEF"
  1550.  
  1551.     The "W" is the method setting (explained later).  "GENERIC.PEF" is the name
  1552.     of the PEF file.  When Parse-O-Matic looks for the PEF file, it looks first
  1553.     in the current directory.  If it can not find it there, it looks in the
  1554.     directory where POM.EXE is located.  You can, if you wish, specify a
  1555.     complete path to the file, as in this example:
  1556.  
  1557.         PROPER Address "W" "C:\MYFILES\MYPEF.XYZ"
  1558.  
  1559.     If you don't need an exceptions file, you should not use it, since it slows
  1560.     down processing somewhat.  Needless to say, the more items you have in the
  1561.     PEF file, the more it slows down processing.
  1562.  
  1563.     The method setting allows you to specify what PROPER does.  There are
  1564.     several kinds of controls, as follows:
  1565.  
  1566.     METHOD   DESCRIPTION
  1567.     ------   -----------
  1568.       I      Intelligent determination of non-words
  1569.       S      Upcase the first character of each sentence
  1570.       U      Upcase the first alphanumeric character of the line
  1571.       W      Upcase the first letter of each word
  1572.  
  1573.     The default method setting is "IW", so if you omit the method setting, or
  1574.     specify a null setting (e.g. PROPER CustName "" "XYZ.PEF"), PROPER will
  1575.     upcase non-words, and the first letter of each word.
  1576.  
  1577.     NOTE:  If you specify a PEF file, you must also specify a method setting,
  1578.     even if it is null.  The line PROPER "GENERIC.PEF" would not be understood
  1579.     by Parse-O-Matic.  The correct format would be:  PROPER "" "GENERIC.PEF"
  1580.  
  1581.     The examples provided with Parse-O-Matic demonstrate some ways you can use
  1582.     the PROPER command.  To see the examples, enter START at the DOS prompt,
  1583.     then select TUTORIAL.
  1584.  
  1585.  
  1586.                                  ------------------
  1587.                                  The INSERT Command
  1588.                                  ------------------
  1589.  
  1590.     FORMAT:  INSERT var1 spec1 value1
  1591.  
  1592.     The INSERT command inserts text on the left or right of var1, or at a
  1593.     "found text" position.
  1594.  
  1595.         spec1  is "L" or "R" (Left or Right) or a find-string (e.g.  "@HELLO")
  1596.         value1 is the value to be inserted
  1597.  
  1598.     For example, if the variable ABC is set to "Parse-O-Matic", then
  1599.  
  1600.         INSERT ABC "L" "Register "    sets ABC to "Register Parse-O-Matic"
  1601.         INSERT ABC "R" " is super"    sets set ABC to "Parse-O-Matic is super"
  1602.  
  1603.     You can use a find-string to insert text at the first occurance of the text
  1604.     you specify.  For example:
  1605.  
  1606.         INSERT ABC "@-O-Matic" "!"    sets ABC to "Parse!-O-Matic"
  1607.  
  1608.     If the find-string is not found, nothing is done.
  1609.  
  1610.     For an alternative to INSERT, see the APPEND command.
  1611.  
  1612.  
  1613.                                  ------------------
  1614.                                  The APPEND Command
  1615.                                  ------------------
  1616.  
  1617.     FORMAT:  APPEND var1 value1 value2 [value3 [value4]]
  1618.  
  1619.     The APPEND command concatenates (adds together) two or more values and
  1620.     places the result in var1.  For example:
  1621.  
  1622.         APPEND xyz "AB" "CD" "EF" "GHIJ"
  1623.  
  1624.     This command sets the variable xyz to "ABCDEFGHIJ".
  1625.  
  1626.     The third and fourth values (value3 and value4 in the FORMAT shown above)
  1627.     are optional.  Thus, you can use APPEND with only two values.  For example:
  1628.  
  1629.         SET    x1 = "AB"
  1630.         SET    x2 = "CD"
  1631.         APPEND x3 x1 x2
  1632.  
  1633.     This sets the variable x3 to "ABCD".  You can concatenate a maximum of four
  1634.     values with a single APPEND command.  If you require additional concaten-
  1635.     ations, you can use more APPEND commands:
  1636.  
  1637.         APPEND myvar "ABC" "DEF" "GHI" "JKL"
  1638.         APPEND myvar myvar "MNO" "PQR"
  1639.  
  1640.     The first line sets the variable myvar to "ABCDEFGHIJKL".  The second line
  1641.     set myvar to its previous value, plus "MNOPQR", so that its final value is
  1642.     "ABCDEFGHIJKLMNOPQR".
  1643.  
  1644.     NOTE:  No variable can hold more than 255 characters.
  1645.  
  1646.  
  1647.  
  1648.     ===========================================================================
  1649.                                 CALCULATION COMMANDS
  1650.     ===========================================================================
  1651.   
  1652.  
  1653.                                   ----------------
  1654.                                   The CALC Command
  1655.                                   ----------------
  1656.                                              
  1657.     FORMAT:  CALC var1 value1 operation value2
  1658.  
  1659.     The CALC command performs an integer arithmetic operation on the two values
  1660.     and assigns the answer to var1.
  1661.  
  1662.     Integer arithmetic refers to whole numbers.  1, 10 and 10000 are integers,
  1663.     while 2.0, 3.14159 and 98.5 are not.
  1664.  
  1665.     Let's say your input file looks like this:
  1666.  
  1667.         DESCRIPTION      UNITS SOLD    UNIT PRICE
  1668.         -----------------------------------------
  1669.         Dog collar               15    $     3.00
  1670.         Cat collar               25    $     2.50
  1671.         Cat caller                3    $     7.25
  1672.         Birdie num-nums       1,305    $     6.25
  1673.         -----------------------------------------
  1674.         End of Data
  1675.         :                :        :     :       :
  1676.         :                :        :     :       :    (Column positions)
  1677.         1               18       27    33      41    
  1678.  
  1679.     You can find out the total number of units sold (of all types) with the
  1680.     following POM file:
  1681.  
  1682.         IGNORE $FLINE[1 7] = "DESCRIP"
  1683.         IGNORE $FLINE[1 7] = "-------"
  1684.         BEGIN $FLINE = "End of Data"
  1685.           OUTEND |Total units sold = {units}
  1686.         ELSE
  1687.           CALC units = units "+" $FLINE[18 27]
  1688.         END
  1689.  
  1690.     As you can see from the example, all spaces and commas are stripped from
  1691.     the number.  Tab characters (ASCII 09) are also stripped.
  1692.  
  1693.     You will also notice that CALC can not be used for the prices, since they
  1694.     are not integer data.  To add up the prices, you must use the CALCREAL
  1695.     command (described later).
  1696.  
  1697.     Note in particular that the operation ("+" in this case) is in quotes.  If
  1698.     you omit the quotes, Parse-O-Matic will report an error.
  1699.  
  1700.     The following operations can be performed with CALC:
  1701.  
  1702.         SYMBOL     DESCRIPTION
  1703.         ---------  -----------
  1704.         "+"        value1 plus value2
  1705.         "-"        value1 minus value2
  1706.         "*"        value1 times value2
  1707.         "/"        value1 divided by value2 (remainder ignored)
  1708.         "HIGHEST"  the larger number (value1 or value2)
  1709.         "LOWEST"   the smaller number (value1 or value2)
  1710.  
  1711.     CALC can handle numbers between -2,147,483,648 and 2,147,483,647.
  1712.  
  1713.  
  1714.                                 --------------------
  1715.                                 The CALCREAL Command
  1716.                                 --------------------
  1717.  
  1718.     FORMAT:  CALCREAL var1 value1 operation value2 [fixed-decimals]
  1719.  
  1720.     CALCREAL works the same way as CALC, except that it handles decimal
  1721.     numbers.  Using the sample data given in the previous section, you could
  1722.     write the following POM file:
  1723.  
  1724.         IGNORE $FLINE[1 7] = "DESCRIP"
  1725.         IGNORE $FLINE[1 7] = "-------"
  1726.         BEGIN $FLINE = "End of Data"
  1727.           OUTEND |Total units sold = {units}
  1728.           OUTEND |Total value sold = {value}
  1729.         ELSE
  1730.           CALC     units = units "+" $FLINE[18 27]
  1731.           CALCREAL value = value "+" $FLINE[33 41]
  1732.         END
  1733.  
  1734.     CALCREAL can handle values +/- 99,999,999,999, but its accuracy decreases
  1735.     when you are dealing with large numbers, as follows:
  1736.                                     
  1737.         Accurate to 1 decimal place  between +/- 9,999,999,999
  1738.         Accurate to 2 decimal places between +/-   999,999,999
  1739.         Accurate to 3 decimal places between +/-    99,999,999
  1740.         Accurate to 4 decimal places between +/-     9,999,999
  1741.         Accurate to 5 decimal places between +/-       999,999
  1742.  
  1743.     You can specify a fixed number of decimal positions in the answer by using
  1744.     the optional "fixed-decimals" value.  For example:
  1745.  
  1746.         SET z = "3.14159"
  1747.         CALCREAL x = z "+" "0" "2"      This sets x to "3.14"
  1748.         CALCREAL x = z "+" "0" "4"      This sets x to "3.1415"
  1749.  
  1750.     You will notice, in the second example, that no "rounding" takes place.
  1751.     The number is simply truncated at the requested decimal position.
  1752.  
  1753.     If you do not use the optional fixed-decimal value, calculations are in
  1754.     "floating point".  That is to say, the answer will have as many decimal
  1755.     places as necessary.  (Bear in mind the accuracy restrictions mentioned
  1756.     earlier.)
  1757.  
  1758.  
  1759.  
  1760.     ===========================================================================
  1761.                                 INPUT PREPROCESSORS
  1762.     ===========================================================================
  1763.   
  1764.  
  1765.                                  -----------------
  1766.                                  The SPLIT Command
  1767.                                  -----------------
  1768.  
  1769.     FORMAT:  SPLIT from-position to-position [,from-pos'n to-pos'n] [...]
  1770.  
  1771.     The maximum length of an input line from a text file is 255 characters.  If
  1772.     your input file is wider than that, you must break up the file into
  1773.     manageable chunks, using the SPLIT command.  This command lets you specify
  1774.     the way in which each input line is broken up so that it will look like
  1775.     several SEPARATE lines.
  1776.  
  1777.     For example, if your input lines were up to 300 characters wide, you could
  1778.     specify:
  1779.  
  1780.         SPLIT 1 255, 256 300
  1781.  
  1782.     This breaks up each line as if it was two lines.  (If some of the lines are
  1783.     less than 256 characters, they will still be treated as two lines, although
  1784.     the second line will be null (i.e. empty).)
  1785.  
  1786.     You can specify up to 100 splits (use multiple SPLIT commands if
  1787.     necessary).  With SPLIT, Parse-O-Matic can handle input records of up to
  1788.     32767 characters.
  1789.  
  1790.     The best way of handling SPLIT or CHOPped files is to use a combination of
  1791.     $SPLIT (explained in more detail later) and BEGIN/END.  For example:
  1792.  
  1793.         SPLIT 1 250, 251 300
  1794.         BEGIN $SPLIT = "1"
  1795.           SET a = $FLINE[ 1 10]
  1796.           SET b = $FLINE[11 20]
  1797.         END
  1798.         BEGIN $SPLIT = "2"
  1799.           SET x = $FLINE[ 1 10]
  1800.           SET y = $FLINE[11 20]
  1801.           OUTEND |{a} {b} {x} {y}
  1802.         END
  1803.  
  1804.     This outputs the data which appears (in the input file) in columns 1-10,
  1805.     11-20, 251-260 and 261-280.
  1806.  
  1807.  
  1808.                                   ----------------
  1809.                                   The CHOP Command
  1810.                                   ----------------
  1811.  
  1812.     FORMAT:  CHOP from-position to-position [,from-pos'n to-pos'n] [...]
  1813.  
  1814.     The CHOP command works the same way as the SPLIT command, with one
  1815.     exception:  it informs Parse-O-Matic that the input is a fixed-record-
  1816.     length file. In other words, it means that the input records are
  1817.     distinguished by having a particular (and exact) length, rather than being
  1818.     separated by end-of-line characters (Carriage Return, Linefeed) as is the
  1819.     case for a standard text file.
  1820.  
  1821.     Thus, if you have an input file containing fixed-length records, each of
  1822.     which is 200 characters wide, you could specify it like this:
  1823.  
  1824.         CHOP 1 200
  1825.  
  1826.     If the input record is more than 255 characters, you must break it up into
  1827.     smaller chunks.  For example, if the input record was 300 characters wide,
  1828.     you could break it up like this:
  1829.  
  1830.         CHOP 1 250, 251 300
  1831.  
  1832.     By using CHOP, Parse-O-Matic can handle input records up to 32767
  1833.     characters wide.  You can use the $SPLIT variable to manage your use of
  1834.     CHOP.  See the example in the section describing the SPLIT command.
  1835.  
  1836.  
  1837.  
  1838.     ===========================================================================
  1839.                                   LOOKUP COMMANDS
  1840.     ===========================================================================
  1841.   
  1842.  
  1843.                                  ------------------
  1844.                                  The LOOKUP Command
  1845.                                  ------------------
  1846.  
  1847.     FORMAT:  LOOKUP var1 value1
  1848.  
  1849.     The LOOKUP command will search for value1 in a text file (the name of which
  1850.     is specified either by the LOOKFILE command or the /L startup parameter).
  1851.     When POM finds it, it sets var1 to another value found on the same line.
  1852.  
  1853.     Let us suppose you created a text file, named NAMES.TBL, like this:
  1854.                     
  1855.         R. REAGAN        Ronald Reagan
  1856.         D. EISENHOWER    Dwight Eisenhower
  1857.         G. BUSH          George Bush
  1858.         :                :
  1859.         Column 1         Column 18
  1860.  
  1861.     This file can be used to look up a name, as in this POM file:
  1862.  
  1863.         LOOKFILE "NAMES.TBL"
  1864.         LOOKCOLS "1" "17" "18" "34"
  1865.         SET      oldname = $FLINE[21 37]
  1866.         TRIM     oldname "R" " "
  1867.         LOOKUP   newname = oldname
  1868.         OUTEND   |{oldname} {newname}
  1869.  
  1870.     The LOOKFILE command specifies the name of the look-up file.  The LOOKCOLS
  1871.     command specifies the starting and end columns for both the "text-to-look-
  1872.     for" field (known as the key field) and the "text-to-replace-with" field
  1873.     (known as the data field).
  1874.  
  1875.     The LOOKUP command will look for oldname in NAMES.TBL.  If oldname is set
  1876.     to "G. BUSH", LOOKUP sets newname to "George Bush".  If, however, oldname
  1877.     is set to "G. WASHINGTON", which doesn't appear in NAMES.TBL, newname
  1878.     is set to "" (that is to say, an empty string).
  1879.  
  1880.     There is no limit to the number of lines that you can put in a look-up
  1881.     file.  However, the more lines there are, the longer it will take to
  1882.     process (because there is more to search).  The maximum length of a line
  1883.     in a look-up file is 255 characters.
  1884.  
  1885.     In the look-up file, null (empty) lines are ignored.  You can also include
  1886.     comments in the file by starting the line with a semi-colon:
  1887.  
  1888.         ; Some of the Presidents of the United States
  1889.         R. REAGAN        Ronald Reagan
  1890.         D. EISENHOWER    Dwight Eisenhower
  1891.         G. BUSH          George Bush
  1892.  
  1893.     The LOOKUP command can be used for more than just names, of course.  You
  1894.     could use it to look up prices, phone numbers, addresses and so on.
  1895.  
  1896.  
  1897.                                 --------------------
  1898.                                 The LOOKFILE Command
  1899.                                 --------------------
  1900.  
  1901.     FORMAT:  LOOKFILE value1
  1902.  
  1903.     The LOOKFILE command specifies the name of the look-up file for the next
  1904.     LOOKUP command.  This lets you use several look-up files in one POM file.
  1905.     For example:
  1906.  
  1907.         SET name = $FLINE[1 20]
  1908.         ; Look up full name
  1909.         LOOKFILE "NAMES.TBL"
  1910.         LOOKCOLS "1" "25" "30" "50"
  1911.         LOOKUP   fullname = name
  1912.         ; Look up phone number
  1913.         LOOKFILE "PHONE.TBL"
  1914.         LOOKCOLS "1" "25" "30" "40"
  1915.         LOOKUP   phone = name
  1916.         ; Output result
  1917.         OUTEND   |{name} {fullname} {newname}
  1918.  
  1919.     If you only have one look-up file, you may omit the LOOKFILE command and
  1920.     specify the file name on the command line, using the /L parameter.  For
  1921.     example, you could write a POM file like this:
  1922.  
  1923.         SET name = $FLINE[1 20]
  1924.         ; Look up full name
  1925.         LOOKCOLS "1" "25" "30" "50"
  1926.         LOOKUP   fullname = name
  1927.         ; Output result
  1928.         OUTEND   |{name} {fullname}
  1929.  
  1930.     Your POM command could then look like this:
  1931.  
  1932.         POM MYPOM.POM INPUT.TXT OUTPUT.TXT /LC:\MYFILES\NAMES.TBL
  1933.  
  1934.     This technique allows you to use several different look-up files with the
  1935.     same POM file, simply by changing the command line.
  1936.  
  1937.     When Parse-O-Matic looks for a look-up file, it first checks to see if you
  1938.     have specified an explicit directory (e.g. C:\MYDIR\NAME.TBL).  In such
  1939.     case, Parse-O-Matic will try to open that file, and fail if it is not able
  1940.     to do so (usually because the file is missing).  If you have not specified
  1941.     an explicit directory (e.g. NAME.TBL), Parse-O-Matic looks first in the
  1942.     current (logged) directory.  If the file is not there, it looks in Parse-
  1943.     O-Matic's home directory (i.e. the directory where POM.EXE is located).
  1944.     If the file is not there, Parse-O-Matic searches the directories specified
  1945.     by the DOS PATH (consult your DOS manual's explanation of the PATH command
  1946.     for details).
  1947.  
  1948.     The longest line allowed in a look-up file is 255 characters long.
  1949.  
  1950.  
  1951.                                 --------------------
  1952.                                 The LOOKCOLS Command
  1953.                                 --------------------
  1954.  
  1955.     FORMAT:  LOOKCOLS value1 value2 value3 value4
  1956.  
  1957.     The LOOKCOLS command specifies the starting and ending columns for the
  1958.     key and data fields in a look-up file (see the explanation of the LOOKUP
  1959.     command for an overview of look-up files).
  1960.  
  1961.         value1 specifies the starting column for the key  field
  1962.         value2 specified the  ending  column for the key  field
  1963.         value3 specifies the starting column for the data field
  1964.         value4 specified the  ending  column for the data field
  1965.  
  1966.     You can specify a null value to indicate "same as last time".  For example:
  1967.  
  1968.         SET name = $FLINE[1 20]
  1969.         LOOKFILE "NAMES.TBL"
  1970.         LOOKCOLS "1" "25" "30" "50"
  1971.         LOOKUP   fullname = name
  1972.         LOOKFILE "PHONE.TBL"
  1973.         LOOKCOLS "" "" "" "40"
  1974.         LOOKUP   phonenum = name
  1975.         OUTEND   |{name} {fullname} {phonenum}
  1976.  
  1977.     The second LOOKCOLS command uses the same numbers for the first three
  1978.     values that the first LOOKCOLS command used.
  1979.  
  1980.     If you do not specify a LOOKCOLS command, the default values are:
  1981.  
  1982.        Key Field:   Starting column  =   1
  1983.                     Ending column    =  10
  1984.        Data Field:  Starting column  =  12
  1985.                     Ending column    = 255
  1986.  
  1987.     This is equivalent to LOOKCOLS "1" "10" "12" "255".
  1988.  
  1989.  
  1990.                                 --------------------
  1991.                                 The LOOKSPEC Command
  1992.                                 --------------------
  1993.  
  1994.     FORMAT:  LOOKSPEC value1 value2 value3
  1995.  
  1996.     The LOOKSPEC command configures the way the next LOOKUP command will work.
  1997.                                                 
  1998.         value1 = Trim             ("Y" or "N" -- default "Y")
  1999.         value2 = Sorted           ("Y" or "N" -- default "N")
  2000.         value3 = Case-sensitive   ("Y" or "N" -- default "N")
  2001.  
  2002.     The Trim setting specifies whether or not the data field should have spaces
  2003.     stripped off both ends.
  2004.  
  2005.     The Sorted setting specifies whether or not the look-up file is sorted by
  2006.     the key field.  A sorted file is much faster than an unsorted file.  This
  2007.     is especially noticeable if you have a large look-up file and a lot of
  2008.     input to process.
  2009.  
  2010.     The Case-sensitive setting specifies whether or not LOOKUP should distin-
  2011.     guish between upper and lower case when searching.  The default setting is
  2012.     "N" (No), so that LOOKUP would find "John Smith", even if it appeared in
  2013.     the look-up file as "JOHN SMITH".  It is usually safest to set Case-
  2014.     sensitivity to "N", but if you set it to "Y", searching is slightly faster.
  2015.  
  2016.     You can specify a null value to indicate "same as last time".  For example:
  2017.  
  2018.         SET name = $FLINE[1 20]
  2019.         LOOKFILE "DATA.TBL"
  2020.         LOOKCOLS "1" "25" "30" "50"
  2021.         LOOKSPEC "Y" "Y" "Y"
  2022.         LOOKUP   fullname = name
  2023.         LOOKCOLS "" "" "60" "70"
  2024.         LOOKSPEC "N" "" ""
  2025.         LOOKUP   phonenum = name
  2026.         OUTEND   |{name} {fullname} {phonenum}
  2027.  
  2028.     The second LOOKSPEC command uses the same settings for Sorted and Case-
  2029.     sensitivity as the first one, but specifies a different Trim setting.
  2030.  
  2031.  
  2032.  
  2033.     ===========================================================================
  2034.                                MISCELLANEOUS COMMANDS
  2035.     ===========================================================================
  2036.   
  2037.  
  2038.                                  -----------------
  2039.                                  The TRACE Command
  2040.                                  -----------------
  2041.  
  2042.     FORMAT:  TRACE var1
  2043.  
  2044.     The TRACE command is an alternative to standard tracing (see "Tracing", in
  2045.     the "Terms and Techniques" section).
  2046.  
  2047.     When you include a TRACE command in your POM file, Parse-O-Matic will
  2048.     create a text file, named POM.TRC, and use it to keep a detailed record of
  2049.     POM's processing.  Here is an example of the TRACE command:
  2050.  
  2051.     TRACE PRICE
  2052.  
  2053.     This traces the variable named "PRICE".  After processing, the file POM.TRC
  2054.     will show everything that happened, and give the value of PRICE at the
  2055.     TRACE line.
  2056.  
  2057.     NOTE:  Since trace files are so detailed, they can be very large.  If you
  2058.     are trying to debug a POM file using TRACE, it is a good idea to use a
  2059.     small input file.
  2060.  
  2061.  
  2062.                                   ---------------
  2063.                                   The LOG Command
  2064.                                   ---------------
  2065.  
  2066.     FORMAT:  LOG value1 [comparator] value2 message
  2067.  
  2068.     If the comparison is true, adds the message to the processing log
  2069.     (POMLOG.TXT).  For details about the processing log, see the section
  2070.     "Logging".
  2071.  
  2072.     Here is an example of the LOG command:
  2073.  
  2074.         SET   emplnumb = $FLINE[ 1  9]
  2075.         SET   sales    = $FLINE[10 20]
  2076.         TRIM  sales "B" " "
  2077.         LOG   sales = "0" "WARNING!  Zero sales for employee number:"
  2078.         LOG   sales = "0" emplnumb
  2079.  
  2080.     This adds two warning lines to the processing log if the sales figures is
  2081.     zero.
  2082.  
  2083.     The logging feature lets you run Parse-O-Matic unattended, then come back
  2084.     later to review (via the processing log) any exceptional conditions.  For
  2085.     some additional comments on logging, see "Unattended Operation".
  2086.  
  2087.  
  2088.                                  ------------------
  2089.                                  The SETLEN Command
  2090.                                  ------------------
  2091.  
  2092.     FORMAT:  SETLEN var1 value1
  2093.  
  2094.     SETLEN sets var1 to the length of value1.  For example:
  2095.  
  2096.         SET    x = "ABCD"
  2097.         SETLEN y x
  2098.  
  2099.     This sets variable y to "4".
  2100.  
  2101.     One handy application for SETLEN is to underline text.  For example:
  2102.  
  2103.         SET     name = $FLINE[1 15]
  2104.         TRIM    name "B" " "
  2105.         SETLEN  nlen name
  2106.         SET     uline = ""
  2107.         PAD     uline "L" "-" nlen
  2108.         OUTEND  |{name}
  2109.         OUTEND  |{uline}
  2110.  
  2111.     If the input line contains the name "JOHN SMITH", the output would be:
  2112.  
  2113.         JOHN SMITH
  2114.         ----------
  2115.  
  2116.     For another example of underlining, see "POM and Wildcards".
  2117.  
  2118.  
  2119.                                  -----------------
  2120.                                  The SOUND Command
  2121.                                  -----------------
  2122.  
  2123.     FORMAT:  SOUND value
  2124.  
  2125.     The SOUND command performs two functions:
  2126.  
  2127.         1)  It makes a noise, or ...
  2128.         2)  It sets the noise made when an error occurs
  2129.  
  2130.     The SOUND command has a repetoire of nine distinctive noises:
  2131.  
  2132.         BEEP BIP BUZZ EDGE ERROR HUH PIP TRILL WHOOP
  2133.  
  2134.     These sounds are useful for alerting you to unusual situations.  Let's say
  2135.     you wanted to be warned if one of the fields in a file comes up blank.  You
  2136.     could write the code this way:
  2137.  
  2138.         BEGIN lastname = ""
  2139.           SOUND "WHOOP"
  2140.           SET   lastname = "?"
  2141.         END
  2142.  
  2143.     Case is not important; the following commands are all equivalent:
  2144.  
  2145.         SOUND "WHOOP"
  2146.         SOUND "Whoop"
  2147.         SOUND "whoop"
  2148.  
  2149.     You can listen to any given sound by using the LISTEN command at the DOS
  2150.     prompt.  To hear what TRILL sounds like, enter this command:
  2151.  
  2152.         LISTEN trill
  2153.  
  2154.     By default, Parse-O-Matic error messages will alert you by playing the
  2155.     ERROR sound.  To hear this sound, enter the following command at the DOS
  2156.     prompt:
  2157.  
  2158.         LISTEN error
  2159.  
  2160.     If you find this noise annoying, you can replace it with one of the other
  2161.     sounds by using the special ERRMSG specification of the SOUND command.  For
  2162.     example, to replace the ERROR sound with the BUZZ sound, place this line
  2163.     at the top of your POM file:
  2164.  
  2165.         SOUND "ERRMSG BUZZ"
  2166.  
  2167.     If you don't want any sound made when an error occurs, use this command:
  2168.  
  2169.         SOUND "ERRMSG QUIET"
  2170.  
  2171.     The ERRMSG specification will only affect errors generated during the
  2172.     actual running of the POM file.  If an error is encountered while
  2173.     Parse-O-Matic is compiling, it will use the ERROR sound when it reports the
  2174.     problem.
  2175.  
  2176.         
  2177.  
  2178.     ===========================================================================
  2179.                                 TERMS AND TECHNIQUES
  2180.     ===========================================================================
  2181.  
  2182.  
  2183.                                        ------
  2184.                                        Values
  2185.                                        ------
  2186.  
  2187.     A value can be specified in the following ways:
  2188.  
  2189.         "text"              A literal text string
  2190.         #number             A single ASCII character (e.g. #32 = Space)
  2191.         #number#number...   Several ASCII characters (e.g. #32#32 = 2 Spaces)
  2192.         VARNAME             The name of a variable
  2193.         VARNAME[start end]  A substring of a variable
  2194.         VARNAME[start]      A single character
  2195.         VARNAME+            Incremented variable (see explanation below)
  2196.  
  2197.     Variable names can be up to 12 characters long.  There is no distinction
  2198.     between upper and lower case in the variable name.  A POM file can contain
  2199.     about 1000 variables and literals.
  2200.  
  2201.     The # character is used to specify a literal text string of one or more
  2202.     characters.  Follow each # with the decimal value of the ASCII character
  2203.     you want.  Here are some useful values:
  2204.  
  2205.         #10 = Line Feed   #12 = Form Feed   #13 = Carriage Return
  2206.  
  2207.     Parse-O-Matic predefines several variables.  They are:
  2208.  
  2209.         $FLINE   = The line just read from the file (max. length 255 chars)
  2210.         $FLUPC   = The line just read from the file, in uppercase
  2211.         $BRL     = The { character (used in OUT)
  2212.         $BRR     = The } character (used in OUT)
  2213.         $COMMAND = The current POM command line (see "POM and Wildcards")
  2214.         $SPLIT   = The CHOP or SPLIT number you are currently processing
  2215.         $TAB     = The tab character (Hex $09; ASCII 09)
  2216.  
  2217.     Since $FLINE has a maximum length of 255 characters, you will have to use
  2218.     the SPLIT or CHOP command if your input file is wider than that.  The
  2219.     $SPLIT variable reports which segment you are processing.  For example,
  2220.     if you had this command...
  2221.  
  2222.         CHOP 1 255, 256 380
  2223.  
  2224.     then $SPLIT would be set to "1" when it was processing columns 1 to 255,
  2225.     and it would be set to "2" when it was processing columns 256 to 380.
  2226.  
  2227.  
  2228.                                      ----------
  2229.                                      Delimiters
  2230.                                      ----------
  2231.  
  2232.     If you need to specify a quotation mark, use "".  For example:
  2233.  
  2234.         IGNORE $FLINE = "He said ""Hello"" to me."
  2235.  
  2236.     This ignores any line containing:  He said "Hello" to me.
  2237.  
  2238.  
  2239.                                  ------------------
  2240.                                  Illegal Characters
  2241.                                  ------------------
  2242.  
  2243.     No command can contain these ASCII characters:
  2244.  
  2245.         HEX   DECIMAL   NAME
  2246.         ---   -------   --------------------
  2247.         $00      0      NULL
  2248.         $0A     10      LF (Linefeed)
  2249.         $0D     13      CR (Carriage Return)
  2250.  
  2251.     Of course, LF and CR do appear at the end of each line, in a text file.
  2252.  
  2253.  
  2254.                                     -----------
  2255.                                     Comparators
  2256.                                     -----------
  2257.  
  2258.     Several POM command decide what to do by comparing two values. For example:
  2259.  
  2260.         IF $FLINE[1 3] = "XYZ" THEN x = "3" ELSE "4"
  2261.  
  2262.     In this example, if the first three characters of $FLINE are "XYZ", the
  2263.     variable x is set to "3", otherwise it is set to "4".  The first equals
  2264.     sign ("=") is a "comparator", because it defines how two values will be
  2265.     compared.  The second equals sign is not a comparator; it is simply
  2266.     padding, which makes the line easier to understand (see the section
  2267.     "Padding for Clarity" for details).
  2268.  
  2269.     Parse-O-Matic allows the following comparators:
  2270.  
  2271.     COMPARATOR MEANING            EXAMPLE
  2272.     ---------- ------------------ ---------------------------------------------
  2273.     <>         Does not equal     IF name <> "Fred" THEN z = "This is not Fred"
  2274.     =          Equals             IF numeral = "IV" THEN x = "4"
  2275.     >          More than          IF x >  "4" THEN z = "x is more than four"
  2276.     >=         More than or equal IF x >= "4" THEN z = "x is four or more"
  2277.     <          Less than          IF x <  "4" THEN z = "x is less than four"
  2278.     <=         Less then or equal IF x <= "4" THEN z = "x is four or less"
  2279.     ^          Contains           IF x ^  "4" THEN z = "x contains a four"
  2280.     ~          Does not contain   IF X ~  "4" THEN z = "x doesn't contain four"
  2281.     LONGER     Length is longer   IF x LONGER  y THEN z = "x is longer than y"
  2282.     SHORTER    Length is shorter  IF x SHORTER y THEN z = "x is shorter than y"
  2283.     SAMELEN    Length is the same IF x SAMELEN y THEN z = "Same length as y"
  2284.  
  2285.     Whenever a comparator is required, but is omitted, it is assumed to be
  2286.     "equals".  Thus, the following lines are equivalent:
  2287.  
  2288.         IF x y z "3" "4"                   (This is very terse, but it works)
  2289.         IF x   y THEN z = "3" ELSE "4"     (The "equals" comparator is omitted)
  2290.         IF x = y THEN z = "3" ELSE "4"     (This is a lot easier to read)
  2291.  
  2292.     Comparators work on numeric and alphabetic data.  Here are some samples:
  2293.  
  2294.                    "ABC" <>      "ABCD"      "3" <>      "4"
  2295.                    "ABC" <=      "ABCD"      "3" <=      "4"
  2296.                    "ABC" <       "ABCD"      "3" <       "4"
  2297.                    "ABC" SHORTER "ABCD"      "3" SAMELEN "4"
  2298.  
  2299.                    "ABC" >=      "ABC"       "ABC" <>      "CDE"
  2300.                    "ABC" <=      "ABC"       "ABC" <=      "CDE"
  2301.                    "ABC" =       "ABC"       "ABC" <       "CDE"
  2302.                    "ABC" ^       "ABC"       "ABC" SAMELEN "CDE"
  2303.                    "ABC" SAMELEN "ABC"
  2304.  
  2305.  
  2306.     Comparing Numbers
  2307.     -----------------
  2308.  
  2309.     Comparators perform "literal" comparisons.  That is to say, they compare
  2310.     text (ASCII) values.  This can lead to some confusion if you expect numbers
  2311.     to be compared according to their ordinal value.  For example, this doesn't
  2312.     work as you might expect at first glance:
  2313.  
  2314.         SET count = count+
  2315.         BEGIN Count >= "2"
  2316.           OUTEND x = x |{count}
  2317.         END
  2318.  
  2319.     You might expect this POM file to output any number greater than or equal
  2320.     to "2", but in fact, you will get a different result, because comparisons
  2321.     are literal (text) comparisons.  In the example above, "2" to "9" are
  2322.     greater or equal to "2", but "10" (which starts with "1") is less, as is
  2323.     evident when you sort several numbers alphabetically:
  2324.  
  2325.         1
  2326.         10
  2327.         11
  2328.         15
  2329.         100
  2330.         2
  2331.         20
  2332.         200
  2333.         3
  2334.         30
  2335.  
  2336.     As you can see, the values 1, 10, 11 and 15 come before "2" when sorted
  2337.     alphabetically.
  2338.  
  2339.     If you want to compare numbers, you have to ensure that the numbers are the
  2340.     same length by left-padding them with zeros:
  2341.  
  2342.         SET   count = count+
  2343.         PAD   count "L" "0" "5"    <--- This turns 123 into 00123
  2344.         BEGIN count >= "00002"
  2345.           TRIM   count "L" "0"
  2346.           OUTEND |{count}
  2347.         END
  2348.  
  2349.     This will work successfully with all values from 00001 to 99999.  Taking
  2350.     the same numbers we considered earlier, and sorting them after padding,
  2351.     they appear in this order:
  2352.  
  2353.         00001
  2354.         00002
  2355.         00003
  2356.         00010
  2357.         00011
  2358.         00015
  2359.         00020
  2360.         00030
  2361.         00100
  2362.         00200
  2363.  
  2364.     Thus, with the padding, all numbers greater than or equal to two will be
  2365.     output.
  2366.  
  2367.  
  2368.     Upgrading from Earlier Versions
  2369.     -------------------------------
  2370.  
  2371.     IF YOU USED PARSE-O-MATIC PRIOR TO VERSION 3.00:  Because the comparator
  2372.     defaults to "equals" if it is omitted, POM files created before version
  2373.     3.00 will continue to function normally -- with two notable exceptions.
  2374.     In older versions, the IGNORE and ACCEPT commands defaulted to "contains".
  2375.     If you have POM files that were created for older versions, you should
  2376.     check your IGNORE and ACCEPT commands to ensure that they are doing what
  2377.     you want them to.
  2378.  
  2379.  
  2380.                                     ------------
  2381.                                     Incrementing
  2382.                                     ------------
  2383.  
  2384.     You can add "1" to a variable in a SET statement.  For example:
  2385.  
  2386.     SET x = "3"
  2387.     SET x = x+
  2388.  
  2389.     After the second statement, x would have the value "4".
  2390.  
  2391.     Only numeric incrementing is supported.  Attempting to increment another
  2392.     type of variable will result in an error.
  2393.  
  2394.         - Incrementing "1" gives you "2"
  2395.         - Incrementing "9" gives you "10"
  2396.  
  2397.     The first time a variable is referenced, it has a null value (unless you
  2398.     SET it yourself).  If you increment a null variable, it will be changed
  2399.     from "" (i.e. null) to "1".
  2400.  
  2401.  
  2402.                                    -------------
  2403.                                    Line Counters
  2404.                                    -------------
  2405.  
  2406.     If your input record is divided over several lines (due to its original
  2407.     format or perhaps because you used the SPLIT or CHOP command), it is
  2408.     helpful to set up a line counter.  The following example extracts the first
  2409.     six characters of the second line of input records that span three lines
  2410.     (designated lines 0, 1 & 2):
  2411.  
  2412.         IF     LineCntr = "1" THEN MyField = $FLINE[1 6]
  2413.         OUTEND LineCntr = "1" |{MyField}
  2414.         IF     LineCntr = "2" THEN LineCntr = "" ELSE LineCntr+
  2415.  
  2416.     For an alternative to line counters, see "The READNEXT Command".
  2417.  
  2418.  
  2419.                                       -------
  2420.                                       Tracing
  2421.                                       -------
  2422.  
  2423.     By setting the DOS variable POM to ALL, you can generate a trace file,
  2424.     named POM.TRC.  This is helpful if you have trouble understanding why your
  2425.     file isn't being parsed properly.  But be sure to test it with a SMALL
  2426.     input file; the trace is quite detailed, and it can easily generate a huge
  2427.     output file.
  2428.  
  2429.     To save space, you can specify a particular list of variables to be traced,
  2430.     rather than tracing everything.  For example, to trace only the variable
  2431.     PRICE, enter this DOS command:
  2432.  
  2433.         SET POM=PRICE
  2434.  
  2435.     To trace several variables, separate the variable names by slashes, as in
  2436.     this example:
  2437.  
  2438.         SET POM=PRICE/BONUS/NAME
  2439.  
  2440.     This traces the three variables PRICE, BONUS and NAME.
  2441.  
  2442.  
  2443.                                       -------
  2444.                                       Logging
  2445.                                       -------
  2446.  
  2447.     Every time Parse-O-Matic runs, it creates a "processing log".  This is a
  2448.     text file named POMLOG.TXT, which is placed in Parse-O-Matic's home
  2449.     directory.  (For example, if POM.EXE is located in C:\POM, the file will
  2450.     be C:\POM\POMLOG.TXT even if you run POM from another directory.)  If the
  2451.     file POMLOG.TXT already exists, it is renamed to POMLOG.BAK.
  2452.  
  2453.     The processing log file POMLOG.TXT contains a report of what happened
  2454.     during the last run of Parse-O-Matic.  Usually, the file will be quite
  2455.     short and look something like this:
  2456.  
  2457.         COMMAND: POM TEST.POM TEST.TXT TEMP.TXT
  2458.         DATE:    JAN 01 1995
  2459.         
  2460.         17:50:10 TEST.TXT opened for processing
  2461.         17:50:14 TEST.TXT processing completed
  2462.  
  2463.     The first line gives the DOS command line, while the second gives the
  2464.     date.  Subsequent lines give the time (Hours:Minutes:Seconds) and a
  2465.     progress or error message.
  2466.  
  2467.     If you encounter an error during processing, the text of the warning
  2468.     message is saved in the processing log.  It might look something like this:
  2469.  
  2470.         COMMAND: POM TEST.POM TEST.TXT TEMP.TXT
  2471.         DATE:    JAN 01 1995
  2472.                                                
  2473.         17:50:10 TEST.TXT opened for processing
  2474.         17:50:10 Execution error in line number 3 of POM file TEST.POM
  2475.         17:50:11 Required parameter is missing in OUT
  2476.  
  2477.     If you process multiple input files, POMLOG.TXT might look something
  2478.     like this:
  2479.  
  2480.         COMMAND: POM EXAMPL15.POM DATA*.TXT TEMP.TXT
  2481.         DATE:    JAN 01 1995
  2482.  
  2483.         14:21:27 DATA01.TXT opened for processing
  2484.         14:21:28 DATA01.TXT processing completed
  2485.  
  2486.         14:21:28 DATA02.TXT opened for processing
  2487.         14:21:28 DATA02.TXT processing completed
  2488.  
  2489.         14:21:28 DATA03.TXT opened for processing
  2490.         14:21:28 DATA03.TXT processing completed
  2491.  
  2492.     If for some reason the processing log can not be created, Parse-O-Matic
  2493.     will continue to run; it will not terminate.  For some additional comments
  2494.     on logging, see "Unattended Operation".
  2495.  
  2496.  
  2497.                                      ----------
  2498.                                      Quiet Mode
  2499.                                      ----------
  2500.  
  2501.     Sometimes you don't want the user to see the Parse-O-Matic processing
  2502.     screen.  In such cases, you can use the "Quiet Mode" switch (/Q) on the
  2503.     command line.  For example:
  2504.  
  2505.         POM XYZ.POM MYFILE.TXT TEMP.TXT /Q
  2506.  
  2507.     The /Q switch suppresses the display of the processing screen.  The only
  2508.     time a user will see anything is if there is a problem (for example:  the
  2509.     input file was not found).
  2510.  
  2511.  
  2512.                                      ---------
  2513.                                      DbF Files
  2514.                                      ---------
  2515.  
  2516.     If Parse-O-Matic notices that the input file is a "DBase" file (i.e. it has
  2517.     a DBF extension -- for example:  MYFILE.DBF), it will change the way it
  2518.     processes the data.  For instance, the variable $FLINE is not defined.
  2519.     Rather, each of the fields in the database are pre-parsed.  Thus, if you
  2520.     have a DBF file containing three fields (EMPNUM, NAME, PHONE), your entire
  2521.     POM file might look like this:
  2522.  
  2523.         IGNORE DELETED "Y"
  2524.         OUTEND |{EMPNUM} {NAME} {PHONE}
  2525.  
  2526.     The DELETED variable is created automatically for each record.  If it is
  2527.     set to "Y", it means the record has been deleted from the database and is
  2528.     probably not valid.  In most cases, you will want to ignore such records.
  2529.  
  2530.     If you do not know what the field names are, you can obtain the list with
  2531.     the following POM file:
  2532.  
  2533.         TRACE DELETED
  2534.  
  2535.     Afterwards, when you inspect the trace file (POM.TRC), you will see a
  2536.     summary of all the fields.  Since there are no output commands (e.g. OUTEND
  2537.     and OUTHDG), the output file will be empty.
  2538.  
  2539.     NOTE:  Parse-O-Matic does not currently support DBF "Memo" fields.
  2540.  
  2541.  
  2542.                                  -----------------
  2543.                                  POM and Wildcards
  2544.                                  -----------------
  2545.  
  2546.     You can process multiple input files with the same POM file by specifying a
  2547.     DOS "wildcard" at the DOS command prompt.  All output is then directed to
  2548.     the same output file.  For example:
  2549.  
  2550.         POM XYZ.POM *.TXT OUTPUT.TXT
  2551.  
  2552.     This runs XYZ POM.file on each file in the current directory with a TXT
  2553.     extension and sends all output to the file OUTPUT.TXT.
  2554.  
  2555.     The POM file can determine which file it is reading by using the predefined
  2556.     variable $COMMAND, which contains the current POM command line.
  2557.  
  2558.     Consider the following scenario:
  2559.  
  2560.     - You have installed POM.EXE in the directory path C:\UTILITY\POM
  2561.     - The current directory contains ABC.POM, MARK.TXT, MARY.TXT and JOHN.TXT
  2562.     - You enter the command POM ABC *.DAT OUT.TXT
  2563.  
  2564.     Parse-O-Matic runs ABC.POM against the three TXT files.  On the first input
  2565.     file, $COMMAND will look like this:
  2566.  
  2567.         C:\UTILITY\POM.EXE ABC.POM MARK.TXT OUT.TXT
  2568.  
  2569.     On the next two input files, it looks like this:
  2570.  
  2571.         C:\UTILITY\POM.EXE ABC.POM MARY.TXT OUT.TXT
  2572.         C:\UTILITY\POM.EXE ABC.POM JOHN.TXT OUT.TXT
  2573.  
  2574.     Note that the file OUT.TXT is NOT processed, even though it has a TXT
  2575.     extension.  POM will always avoid processing the output file.
  2576.  
  2577.     Let's say you wanted to concatenate both MARK.TXT and MARY.TXT, and put the
  2578.     file name at the top.  You could do it with this POM file, named ABC.POM:
  2579.  
  2580.         SET cmd = $COMMAND              <--- Get the command line
  2581.         BEGIN cmd <> lastcmd            <--- Has it changed?
  2582.           PARSE  fname cmd "2* " "3* "  <--- Extract the input file name
  2583.           SETLEN flen  fname            <--- Get length of input file name
  2584.           SET    uline = ""             <--- Initialize underline
  2585.           PAD    uline "L" "-" flen     <--- Set underline
  2586.           OUTEND lastcmd <> "" |        <--- Output a linefeed unless this
  2587.           OUTEND lastcmd <> "" |        <--- is the first file
  2588.           OUTEND |{fname}               <--- Output the file name
  2589.           OUTEND |{uline}               <--- Output the underline
  2590.           OUTEND |                      <--- Output a linefeed
  2591.           SET    lastcmd = $COMMAND     <--- Remember this command line
  2592.         END                             <--- End of code block
  2593.         OUTEND |{$FLINE}                <--- Output a line from the input
  2594.  
  2595.     You could then process MARK.TXT and MARY.TXT with this command line:
  2596.  
  2597.         POM ABC M*.TXT OUT.TXT
  2598.  
  2599.     This processes any file starting with an "M" that has a TXT extension.
  2600.  
  2601.     Another way to run the command is as follows:
  2602.  
  2603.         POM ABC M???.TXT OUT.TXT
  2604.  
  2605.     This processes any four-letter TXT file that starts with "M".
  2606.  
  2607.     For more information about DOS wildcards, consult your DOS manual.
  2608.  
  2609.  
  2610.  
  2611.     ===========================================================================
  2612.                               OPERATIONAL PLANNING
  2613.     ===========================================================================
  2614.  
  2615.  
  2616.                                 --------------------
  2617.                                 Unattended Operation
  2618.                                 --------------------
  2619.  
  2620.     Several features have been built in to Parse-O-Matic to enable "unattended
  2621.     operation".  That means that you can design applications that run
  2622.     themselves while you are not there.  There are two reasons why you might
  2623.     want to do this:
  2624.  
  2625.     - You can run long processing jobs just before leaving work at night
  2626.     - Parse-O-Matic is useful, but it isn't very interesting to watch!
  2627.  
  2628.     There are several features which facilitate unattended operation:
  2629.  
  2630.     - The SOUND command can alert you if something unusual happens
  2631.  
  2632.     - All error messages (which say "Press spacebar to continue")
  2633.       will "time-out" (i.e. continue) after about a minute
  2634.  
  2635.     - The processing log (see "Logging") can be used to check processing
  2636.  
  2637.     Let's say you wanted to concatenate (add together) several enormous text
  2638.     files.  You could start with the following POM file (named ADD.POM):
  2639.  
  2640.         SET    cmd = $COMMAND
  2641.         BEGIN  cmd <> lastcmd
  2642.           SOUND  "BEEP"
  2643.           SET     lastcmd = cmd
  2644.         END
  2645.         OUTEND |{$FLINE}
  2646.  
  2647.     You could then enter the command POM ADD.POM *.TXT ALL.TXT and walk away.
  2648.     Whenever a new file is started, you'll hear a beep.  When you come back,
  2649.     you can check the file POMLOG.TXT (which will be located in the same
  2650.     directory as POM.EXE).  It might look something like this:
  2651.  
  2652.         COMMAND: POM ADD.POM *.TXT ALL.TXT
  2653.         DATE:    JAN 01 1995
  2654.  
  2655.         16:39:12 JOHN.TXT opened for processing
  2656.         16:45:28 JOHN.TXT processing completed
  2657.  
  2658.         16:45:29 MARY.TXT opened for processing
  2659.         16:52:10 MARY.TXT processing completed
  2660.  
  2661.         16:52:11 FRED.TXT opened for processing
  2662.         17:03:33 FRED.TXT processing completed
  2663.  
  2664.     If you are processing multiple files, and each one uses a different POM
  2665.     file (and hence requires a separate run of Parse-O-Matic) you can write
  2666.     your batch file so that it renames the log files.  This lets you review
  2667.     each log file later.  For example:
  2668.  
  2669.         @ECHO OFF
  2670.         POM JOHN.POM JOHN.TXT JOHN.LST
  2671.         RENAME C:\POM\POMLOG.TXT JOHN.LOG
  2672.         POM MARY.POM MARY.TXT MARY.LST
  2673.         RENAME C:\POM\POMLOG.TXT MARY.LOG
  2674.         POM FRED.POM FRED.TXT FRED.LST
  2675.         RENAME C:\POM\POMLOG.TXT FRED.LOG
  2676.  
  2677.     When processing is complete, the files JOHN.LOG, MARY.LOG and FRED.LOG
  2678.     will be available in the directory C:\POM for your inspection.
  2679.  
  2680.     Here is a slightly more sophisticated version of the batch file:
  2681.  
  2682.         @ECHO OFF
  2683.         POM JOHN.POM JOHN.TXT JOHN.LST
  2684.         IF ERRORLEVEL 1 GOTO QUIT
  2685.         RENAME C:\POM\POMLOG.TXT JOHN.LOG
  2686.         POM MARY.POM MARY.TXT MARY.LST
  2687.         IF ERRORLEVEL 1 GOTO QUIT
  2688.         RENAME C:\POM\POMLOG.TXT MARY.LOG
  2689.         POM FRED.POM FRED.TXT FRED.LST
  2690.         IF ERRORLEVEL 1 GOTO QUIT
  2691.         RENAME C:\POM\POMLOG.TXT FRED.LOG
  2692.         :QUIT
  2693.  
  2694.     The IF ERRORLEVEL lines jump to the end of the batch file if Parse-O-Matic
  2695.     generates an error of 1 or higher.  When coding batch files, remember that
  2696.     the IF ERRORLEVEL command is considered "True" if the error is the
  2697.     specified value or higher.  This means you should always test the higher
  2698.     value first.  See your DOS manual for details.
  2699.  
  2700.                                               
  2701.                                       --------
  2702.                                       Examples
  2703.                                       --------
  2704.  
  2705.     Most of the techniques described in this manual are demonstrated by the
  2706.     examples provided with the standard Parse-O-Matic package.  To see these
  2707.     examples, switch to your Parse-O-Matic directory, type START at the DOS
  2708.     prompt, then select TUTORIAL.
  2709.  
  2710.  
  2711.  
  2712.     ===========================================================================
  2713.                                      LICENSING
  2714.     ===========================================================================
  2715.  
  2716.  
  2717.     This product is available in several forms:
  2718.  
  2719.     TRIAL LICENSE:  If you have a "test-drive" evaluation copy, you will see a
  2720.     "Registration Reminder Screen" when you start up the program.  You are
  2721.     entitled to evaluate this program at no cost for 3 months.  If you continue
  2722.     to use it after that, you are required to purchase a registered copy (see
  2723.     below).
  2724.  
  2725.     REGISTERED:  When you register an evaluation copy of this product, you will
  2726.     receive the latest version, plus an unlocking code that will let you
  2727.     register any new evaluation versions that we release for a period of two
  2728.     years (six years for deluxe registration). The file OPTIONS.DOC explains
  2729.     the various payment methods available.  A registered copy provides you with
  2730.     a single-user license.
  2731.  
  2732.     SITE/MULTI-COPY LICENSES:  If you plan to run 15 or more copies of this
  2733.     program simultaneously (on a network or on separate computers), you can
  2734.     obtain quantity pricing.  See the order form (file ORDER.FRM) for details.
  2735.  
  2736.     DISTRIBUTION LICENSE:  The distribution license ($750) allows you to use an
  2737.     unlimited number of copies of a specially personalized copy.  You may
  2738.     include it in a commercial package as a utility.  The only restriction is
  2739.     that you may not distribute this document (i.e. the user manual) or its
  2740.     essential content.  With this safeguard, we avoid placing ourselves in
  2741.     competition with you; the program must be used to support a product rather
  2742.     than being a main selling feature.
  2743.  
  2744.     RETAIL LICENSE:  You can sell complete, registered copies of this product,
  2745.     complete with documentation, in return for royalties.  The terms depend on
  2746.     volume and advance payments. The license is $100 plus the following royalty
  2747.     scale:
  2748.                                  
  2749.     Non-exclusive, prepayment for  1,000 copies ------------------- $1.00/copy
  2750.     Non-exclusive, prepayment for  5,000 copies ------------------- $0.50/copy
  2751.     Non-exclusive, prepayment for 10,000 copies ------------------- $0.30/copy
  2752.     Non-exclusive, prepayment for 25,000 copies ------------------- $0.20/copy
  2753.     Non-English exclusive, 10,000 copy prepayment ----------------- $0.50/copy
  2754.     Non-English exclusive, 25,000 copy prepayment ----------------- $0.35/copy
  2755.  
  2756.     In the above rate schedule, packaging, product duplication and support are
  2757.     the responsibility of the retailer.  If you wish to obtain a retail
  2758.     license, please contact us to request the contract appropriate to your
  2759.     requirements.
  2760.  
  2761.  
  2762.