home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / p / pom232.zip / POM.INF < prev    next >
Text File  |  1993-02-08  |  18KB  |  503 lines

  1. ===============================================================================
  2. ==========================                         ============================
  3. ==========================      PARSE-O-MATIC      ============================
  4. ==========================                         ============================
  5. ===============================================================================
  6.  
  7.  
  8.  
  9.  
  10.                       Parse-O-Matic is Copyright (C) 1992
  11.  
  12.                                       by
  13.  
  14.          Pinnacle Software, CP 386 Mount Royal, Quebec Canada  H3P 3C6
  15.          U.S. Office: Box 714 Airport Road, Swanton, Vermont 05488 USA
  16.  
  17.          Support Line (514) 345-9578  -- Free Files BBS (514) 345-8654
  18.                       
  19.  
  20.          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  21.  
  22.  
  23.          This is a SHAREWARE product.  That means we would like you to
  24.          pass around unregistered copies to other people.  If you have
  25.          a modem,  please upload it to your  favourite  bulletin board
  26.          system,  or give a copy to a friend  who you think might need
  27.          a program like this.   Shareware means sharing!   Pass it on!
  28.     
  29.                       
  30.          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  31.  
  32.                                         
  33.                      Design and coding: Timothy Campbell
  34.  
  35.                              Marketing: James Ludwick
  36.                                         Paul Renault
  37.  
  38.                          Documentation: Natasha Mirage
  39.  
  40.                           Distribution: Kevin Beck
  41.  
  42.                       Support services: L. Wilson
  43.                                         Z. Krome
  44.                                         P. Katt
  45.  
  46.  
  47.  
  48.  
  49. ===============================================================================
  50. INTRODUCTION
  51. ===============================================================================
  52.  
  53.  
  54.  
  55. WHY YOU NEED PARSE-O-MATIC
  56. --------------------------
  57.  
  58. There are  plenty  of programs out there that have  valuable  data locked  away
  59. inside them.  How do you get that data OUT of one program and into another one?
  60.  
  61. Some  programs  provide  a feature which  "exports"  a file into  some  kind of
  62. generic format.   Perhaps the  most popular  of  these  formats  is  known as a
  63. "comma-delimited file",  which is  a  text file  in which each  data  field  is
  64. separated by a  comma.   Literal strings -- which might  contain commas! -- are
  65. represented in double quotes.  So a few lines from a comma-delimited file might
  66. look something like this  (an export from a hypothetical database of people who
  67. owe your company money):
  68.  
  69.       +----------------------------------------------------------------+
  70.       | "JONES","FRED","1234 GREEN AVENUE", "KANSAS CITY", "MO",293.64 |
  71.       | "SMITH","JOHN","2343 OAK STREET","NEW YORK","NY",22.50         |
  72.       | "WILLIAMS","JOSEPH","23 GARDEN CRESCENT","TORONTO","ON",16.99  |
  73.       +----------------------------------------------------------------+
  74.  
  75. Unfortunately,  not  all  programs  export  data  in  this  format, and not all
  76. programs  READ  data in that format.   What's most  annoying of all is when one
  77. program exports data in a format that is ALMOST what you need!
  78.  
  79. If  that's  the case,  you might find that it's worth your while to spend a few
  80. hours in a text editor,  modifying  the export file  so that  the other program
  81. can understand it.   Or you  might  write a program  to do the editing for you.
  82. Both solutions are time-consuming.
  83.  
  84. An even  more  challenging  problem  arises  when a program which has no export
  85. capability DOES have the ability to "print" reports to a file.  You can write a
  86. program to read these files and convert them to something you can use, but this
  87. can be a LOT of work!
  88.  
  89.  
  90.  
  91. PARSE-O-MATIC TO THE RESCUE!
  92. ----------------------------
  93.  
  94. Parse-O-Matic  is a  utility  that  interprets text files  and converts them to
  95. other formats.  It can help you "boil down" reports  into their essential data.
  96. You can also use it to convert NEARLY compatible file formats.
  97.  
  98.  
  99.  
  100. HOW IT WORKS
  101. ------------
  102.  
  103. You need three things:
  104.  
  105.   1)  The Parse-O-Matic program
  106.   2)  A Parse-O-Matic "POM" file (to tell Parse-O-Matic what to do)
  107.   3)  The input file
  108.  
  109. The input file is  usually  a report  from   another  program.   We've provided
  110. several examples of typical input files.   For example,  the file  EXAMPLE2.TXT
  111. comes from the AccPac accounting software.  AccPac is a great program,  but its
  112. export capabilities leave something to be desired.  Parse-O-Matic can help!
  113.  
  114.  
  115.  
  116. ===============================================================================
  117. HOW TO CODE THE POM FILE
  118. ===============================================================================
  119.  
  120.  
  121. This documentation assumes that you are an experienced computer user.  If you
  122. have trouble, you might ask a programmer to help you -- POM file creation is
  123. a little like programming!
  124.  
  125.  
  126.  
  127. THE PARSE-O-MATIC COMMAND
  128. -------------------------
  129.  
  130. The format of the Parse-O-Matic command line is:
  131.  
  132.   POM pom-file input-file output-file
  133.  
  134. Here's an example, as you would type it at the DOS command line:
  135.  
  136.   POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  137.  
  138. For a more formal description of the command line, start up POM by typing this
  139. command at the DOS prompt:
  140.  
  141.   POM
  142.  
  143.  
  144.  
  145. THE POM FILE
  146. ------------
  147.  
  148. The POM file is a text file with a .POM extension.  The following conventions
  149. are used when interpreting the POM file:
  150.  
  151. - Null lines and lines starting with a semi-colon are ignored.
  152.  
  153. - A POM file may contain up to 500 lines of specifications.
  154.   Comment lines do not count in this total.
  155.  
  156. A POM file contains no "loops" (to use the programming term).  Each line of the
  157. input file is processed by the entire POM file.   If you'd like it expressed in
  158. terms of programming languages, here's what POM does:
  159.  
  160.      +----------------------------------------------------------------+
  161.      | START:  If there's nothing left in the input file, go to QUIT. |
  162.      |         Read a line from the input file                        |
  163.      |         Do everything in the POM file                          |
  164.      |         Go to START                                            |
  165.      | QUIT:   Tell the user you're finished!                         |
  166.      +----------------------------------------------------------------+
  167.  
  168.  
  169.  
  170. PADDING FOR CLARITY
  171. -------------------
  172.  
  173. Spaces and tabs between the words and variables in a POM file line are
  174. generally ignored (except in the case of the OUT and OUTEND commands).  You
  175. can use spaces to make the POM file easier to read.
  176.  
  177. Additionally, in any line in the POM file, the following terms are ignored:
  178.  
  179.   =     THEN     ELSE
  180.  
  181. These can be added to make the lines easier to read.  For example, the IF
  182. command can be written in any of the following ways:
  183.  
  184.   Very terse:          IF PRICE "0.00" BONUS "0.00" "1.00"
  185.  
  186.   Padded with spaces:  IF PRICE   "0.00"   BONUS   "0.00"   "1.00"
  187.  
  188.   Fully padded:        IF PRICE = "0.00"  THEN  BONUS = "0.00"  ELSE  "1.00"
  189.  
  190.  
  191.  
  192. COMMAND WORDS
  193. -------------
  194.  
  195. For ease of learning, the commands words are presented in the following order:
  196.  
  197.     MINLEN  SET  IGNORE  ACCEPT  IF  TRIM  PAD  INSERT  CHANGE  OUT  OUTEND
  198.  
  199.  
  200. MINLEN number
  201.  
  202.     Specifies the minimum length a line must be to be considered for parsing.
  203.     (Note that null lines in the input file are always ignored)  If you omit
  204.     the MINLEN command, the minimum length is assumed to be  1.  That is to
  205.     say, all lines longer than 1 character will be processed.
  206.  
  207.     MINLEN is useful for ignoring brief information lines that clutter up a
  208.     report that you are parsing.  For example, in the sample file EXAMPLE2.POM,
  209.     the MINLEN command is set to 85 to ensure that all lines shorter than 85
  210.     characters long will be ignored.  This simplifies the coding considerably.
  211.  
  212.  
  213. SET var1 value1
  214.  
  215.     This assigns a value to a variable.  The usual reason to do this is to
  216.     set a variable from the input line ($FLINE) prior to cleaning it up with
  217.     TRIM.  For example:
  218.  
  219.     SET  NAME = $FLINE[50 59]        (Sets the variable from the input line)
  220.     TRIM NAME "R" " "                (Trims any spaces on the right side)
  221.  
  222.     We might find a blank-padded string between columns 50 and 59.  Thus:
  223.  
  224.     SET assigns this value to the variable NAME:    "FRED      "
  225.     After the TRIM, the variable NAME becomes:      "FRED"
  226.  
  227.     You will also use SET if you plan to include a substring of $FLINE in the
  228.     output, since OUT and OUTEND do not recognize substrings after the "|"
  229.     marker, only complete variables.
  230.  
  231.  
  232. IGNORE value1 value2
  233.  
  234.     When value1 contains value2, the input line is ignored and all further
  235.     processing on the input line stops.  The usual format of this command is
  236.     as in this example:
  237.  
  238.     IGNORE $FLINE[3 9] = "Date"
  239.  
  240.     This would skip any input line that contains the word "Date" between
  241.     columns 3 and 9 ($FLINE is the line just read from the input file).
  242.  
  243.  
  244. ACCEPT value1 value2
  245.  
  246.     Accepts the input line if value1 contains value2.  For example, if the
  247.     entire POM file read as follows:
  248.  
  249.     ACCEPT $FLINE[15 17] "YES"
  250.     OUTEND "X" = "X" |{$FLINE}
  251.  
  252.     then any input line that contains "YES", starting in column 15, would be
  253.     sent to the output file.  All other lines would be ignored.
  254.  
  255.     CLUSTERED ACCEPTS:  Sometimes you have to check more than one value to see
  256.     if the input line is valid.  You do this using "clustered ACCEPTs", which
  257.     are several ACCEPT commands in a row.
  258.  
  259.     Briefly stated, if you have several ACCEPTs in a row ("clustered"), they
  260.     are all processed to determine if the input line is acceptable or not.  If
  261.     even one ACCEPT matches up, the line is accepted.  To express this in more
  262.     detail...
  263.  
  264.     When value1 contains value2, the line is accepted, and processing of the
  265.     POM file continues for that input line, even if the immediately following
  266.     ACCEPTs do NOT produce a match.  After all, we've already got a match!
  267.  
  268.     If value1 does NOT contain value2, Parse-O-Matic looks at the next commmand
  269.     in the POM file.  If it is not another ACCEPT, the input line is ignored.
  270.     If it is another ACCEPT, maybe it will product a match!  So Parse-O-Matic
  271.     moves to that command.
  272.  
  273.     The following POM file uses clustered ACCEPTs to accept any line that
  274.     contains the name "FRED" or "MARY" between columns 5 and 8, or contains
  275.     the word "MEMBER" between columns 20 and 25.
  276.  
  277.     SET    NAME = $FLINE[5 8]             (Set the variable)
  278.     ACCEPT NAME = "FRED"                  (Look for FRED)
  279.     ACCEPT NAME = "MARY"                  (Look for MARY)
  280.     ACCEPT $FLINE[20 25] = "MEMBER"       (Look for MEMBER)
  281.     OUTEND "X" = "X" |{$FLINE}            (Output the line if we get this far)
  282.  
  283.     The following example would NOT work, however:
  284.  
  285.     ACCEPT $FLINE[20 25] = "MEMBER"
  286.     SET    NAME = $FLINE[5 8]
  287.     ACCEPT NAME = "FRED"
  288.     ACCEPT NAME = "MARY"
  289.     OUTEND "X" = "X" |{$FLINE}
  290.  
  291.     It would not work because the ACCEPTs are not clustered;  if the first
  292.     ACCEPT fails, the input line will be rejected as soon as the SET command
  293.     is encountered.  The next two ACCEPTs would not be reached in such case.
  294.  
  295.  
  296. IF value1 value2 var1 value3 [value4]
  297.  
  298.     If value1 contains value2, var1 is set to value3.  Otherwise, it is
  299.     set to value4.  If value4 is missing, nothing is done (i.e. var1
  300.     is not changed).  Here's an example of the IF command...
  301.  
  302.     SET  EARNING = $FLINE[20 26]
  303.     TRIM EARNING "A" " "
  304.     IF   EARNING = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  305.  
  306.     This would obtain the value between columns 20 and 26, remove any spaces,
  307.     then check if it equals "0.00".  If it does, the variable BONUS would be
  308.     set to 0.00.  If not, BONUS would be set to "1.00".
  309.  
  310.  
  311. TRIM var1 spec1 character
  312.  
  313.     Removes characters from var1.  This is usually used to remove blanks.
  314.     spec1 can be:  A=All  B=Both ends  L=Left side only  R = Right side only
  315.     For example:
  316.  
  317.     SET  PRICE = $FLINE[20 26]
  318.     TRIM PRICE "A" ","
  319.     TRIM PRICE "L" "$"
  320.  
  321.     This would remove all commas from the variable "PRICE", and remove the
  322.     leadings dollar sign.  Thus:
  323.          
  324.     If the input contained the string:   "$25,783"
  325.     The first  TRIM would change it to:  "$25783"
  326.     The second TRIM would change it to:  "25783"
  327.  
  328. PAD var1 spec1 character len
  329.  
  330.     Makes var1 a particular length, padded with a particular character.
  331.  
  332.     spec1     is "L", "R", or "C" (Left, Right or Center)
  333.     character is the character used to pad the string
  334.     len       is the desired string length
  335.  
  336.     For example, if the variable ABC is set to "1234" ...
  337.  
  338.     PAD ABC "L" "0" "7"   left-pads it 7 characters wide with zeros ("0001234")
  339.     PAD ABC "R" " " "5"   right-pads it 5 characters wide with spaces ("1234 ")
  340.     PAD ABC "C" "*" "8"   would center it, 8 wide, with asterisks ("**1234**")
  341.  
  342.     If the length is less than the length of the string, it is unchanged.  For
  343.     example, if you set variable XYZ to "PINNACLE", then
  344.  
  345.     PAD XYZ "R" " " "3"
  346.  
  347.     would leave the string as-is ("PINNACLE").
  348.  
  349.     If it was your intention to make XYZ 3 letters long, it would be better to
  350.     use the SET command:
  351.  
  352.     SET XYZ = XYZ[1 3]
  353.  
  354. INSERT var1 spec1 value1
  355.  
  356.     Inserts text on the left or right of var1, or at a "found text" position.
  357.  
  358.     spec1   is "L" or "R" (Left or Right) or a find-string (e.g. "@HELLO")
  359.     value1  is the value to be inserted
  360.  
  361.     For example, if the variable ABC is set to "ParseOMatic", then
  362.  
  363.     INSERT ABC "L" "Register "   would set ABC to "Register ParseOMatic"
  364.     INSERT ABC "R" "is super!"   would set ABC to "ParseOMatic is super!"
  365.  
  366.     You can use a find-string to insert text at the first occurance of the
  367.     text you specify.  For example:
  368.  
  369.     INSERT ABC "@OMatic" "-"     would set ABC to "Parse-OMatic"
  370.  
  371.     If the find-string is not found, nothing is done.
  372.  
  373. CHANGE var1 value1 value2
  374.  
  375.     Replaces ALL occurances of value1 with value2.  This is more powerful than
  376.     TRIM, but is not as efficient.  Here is an example of CHANGE:
  377.  
  378.     SET    DATE = $FLINE[31 38]
  379.     CHANGE DATE "/" "--"
  380.  
  381.     If the input contained the string:   "93/10/15"
  382.     The CHANGE would convert it to:      "93--10--15"
  383.  
  384.  
  385. OUT[END] value1 value2 |output-picture
  386.  
  387.     This is actually two command words:  OUT and OUTEND.  OUT writes to the
  388.     output file without an end-of-line.  OUTEND writes an end-of-line to the
  389.     file.  When value1 matches value2, a line is output to the output file,
  390.     according to the output picture.  Within the output picture, all
  391.     text is taken literally (i.e. " is taken to mean literally that --
  392.     a quotation mark character).
  393.  
  394.     The only exception to this is that variable names are identified by
  395.     the { and } characters.  For example, a POM file that contained the
  396.     following single line:
  397.  
  398.     OUTEND "X" = "X" |{$FLUPC}
  399.  
  400.     would simply output in uppercase every line in the input file.
  401.  
  402.     NOTE:  OUT does not write immediately to the output file; it accumulates
  403.     the output until it reaches 255 characters before writing.  You must do an
  404.     OUTEND to ensure that the data is actually written.  No single OUT or
  405.     OUTEND command can output more than 255 characters.
  406.  
  407.     You can not use substrings after the "|" marker.  Thus, the following line
  408.     is NOT legal:
  409.  
  410.     OUTEND $FLINE[1 3] = "IBM" |{$FLINE[1 15]}
  411.  
  412.     The correct way to code this is as follows:
  413.  
  414.     SET CODE = $FLINE[1 15]
  415.     OUTEND $FLINE[1 3] = "IBM" |{CODE}
  416.  
  417.     This would output the first 15 characters of any line that contains the
  418.     letters IBM in the first three positions.
  419.  
  420.  
  421.  
  422. VALUES
  423. ------
  424.  
  425. A value can be specified in the following ways:
  426.  
  427.   "text"              A literal text string
  428.   VARNAME             The name of a variable
  429.   VARNAME[start end]  A substring of a variable
  430.   VARNAME[start]      A single character
  431.   VARNAME+            Increments variable (see explanation below)
  432.  
  433. Variable names can be up to 8 characters long.  There is no distinction between
  434. upper and lower case.  You can create up to 225 variables and literals (this
  435. number includes the predefined variables).
  436.  
  437. Parse-O-Matic predefines several variables.  They are:
  438.  
  439.   $FLINE = The line just read from the file
  440.   $FLUPC = The line just read from the file, in uppercase
  441.   $BRL   = The { character (used in OUT)
  442.   $BRR   = The } character (used in OUT)
  443.  
  444.  
  445.  
  446. DELIMITERS
  447. ----------
  448.  
  449. If you need to specify a quotation mark, use "".  For example:
  450.  
  451.   IGNORE $FLINE "He said ""Hello"" to me."
  452.  
  453. This would ignore lines containing:  He said "Hello" to me.
  454.  
  455.  
  456.  
  457. ILLEGAL CHARACTERS
  458. ------------------
  459.   
  460. No command can contain these ASCII characters:
  461.  
  462.   HEX  DECIMAL  NAME
  463.   ---  -------  ----
  464.   $00     0     NULL
  465.   $0A    10      LF
  466.   $0D    13      CR
  467.  
  468. Of course, LF and CR do appear at the very end of each line.
  469.  
  470.  
  471.  
  472. INCREMENTING
  473. ------------
  474.  
  475. Only numeric incrementing is supported at this time.  Attempting to increment
  476. another type of variable will result in an error.
  477.  
  478. - Incrementing "1" gives you "2"
  479. - Incrementing "9" gives you "10"
  480.  
  481.  
  482.  
  483. TRACING
  484. -------
  485.  
  486. By setting the DOS variable POM to ALL, you can generate a trace file, named
  487. POM.TRC.  This is helpful if you have trouble understanding why your file isn't
  488. being parsed properly.  But be sure to test it with a SMALL input file.  The
  489. trace is quite detailed, and it can easily generate a HUGE output file.
  490.  
  491. To save space, you can specify a particular list of variables to be traced,
  492. rather than tracing everything.  For example, to trace only the variable PRICE,
  493. you would enter this DOS command:
  494.  
  495.   SET POM=PRICE
  496.  
  497. To trace several variables, separate the variable names by slashes, as in this
  498. example:
  499.  
  500.   SET POM=PRICE/BONUS/NAME
  501.  
  502.  
  503.