home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / parsomat.zip / manual.txt < prev    next >
Text File  |  2001-07-15  |  440KB  |  11,738 lines

  1.     ===========================================================================
  2.     ===========================================================================
  3.     ============================                   ============================
  4.     ============================                   ============================
  5.     ============================   PARSE-O-MATIC   ============================
  6.     ============================                   ============================
  7.     ============================                   ============================
  8.     ===========================================================================
  9.     ===========================================================================
  10.  
  11.  
  12.               Copyright (C) 1986, 2001 by Pinnacle Software (Toronto)
  13.  
  14.  
  15.     +-------------------------- WIDE APPLICABILITY ---------------------------+
  16.     |                                                                         |
  17.     |                                                                         |
  18.     |          Runs under Windows (3.x, 95, 98, NT, Me, 2000), OS/2,          |
  19.     |          and Novell (DR-DOS).                                           |
  20.     |                                                                         |
  21.     |          Can be invoked by other Windows, DOS or OS/2 programs          |
  22.     |          such as FoxPro, Pascal, Visual Basic, C++, Delphi and          |
  23.     |          so on, with success verification (return code or log)          |
  24.     |                                                                         |
  25.     |          Can be run under DOS emulators (e.g. Macintosh, Unix)          |
  26.     |          for convenient cross-platform conversion.                      |
  27.     |                                                                         |
  28.     |                                                                         |
  29.     +------- HERE ARE A FEW OF THE THINGS PARSE-O-MATIC CAN DO FOR YOU -------+
  30.     |                                                                         |
  31.     |                                                                         |
  32.     |      Importing             Exporting             Automated Editing      |
  33.     |      Text Extraction       Data Conversion       Table Lookup           |
  34.     |      Retabulation          Info Weeding          Selective Copying      |
  35.     |      Binary-File to Text   Report Reformatting   Wide-Text Folding      |
  36.     |      Auto-Batch Creation   Comm-log Trimming     Tab Replacement        |
  37.     |      Character Filtering   Column Switching      DBF Interpretation     |
  38.     |      De-uppercasing        Name Properization    And much more!         |
  39.     |                                                                         |
  40.     |                                                                         |
  41.     +---- INPUT AND OUTPUT METHODS CURRENTLY SUPPORTED BY PARSE-O-MATIC ------+
  42.     |                                                                         |
  43.     |                                                                         |
  44.     |   Input:  Text (any format), Binary, DBF (DBase), Fixed-Record-Length,  |
  45.     |           Variable-Record-Length, EBCDIC                                |
  46.     |                                                                         |
  47.     |  Output:  Text (e.g. flat, comma-delimited, paginated, hex), Binary,    |
  48.     |           Fixed-Record-Length, Variable-Record-Length, EBCDIC,          |
  49.     |           Generic output devices (e.g. COM1: or LPT2:)                  |
  50.     |                                                                         |
  51.     |                                                                         |
  52.     +-------------------------------------------------------------------------+
  53.  
  54.  
  55.  
  56.  
  57.     +------------ UNSOLICITED TESTIMONIALS (USED WITH PERMISSION) ------------+
  58.     |                                                                         |
  59.     |                                                                         |
  60.     |   "Parse-O-Matic is absolutely great.  I use it when I collect data     |
  61.     |   from the McDonald's restaurants in Switzerland.  POM has paid for     |
  62.     |   itself so many times ..." -- Chris Friedli                            |
  63.     |                                                                         |
  64.     |                                                                         |
  65.     +-------------------------------------------------------------------------+
  66.     |                                                                         |
  67.     |                                                                         |
  68.     |   "Parse-O-Matic is a wonderful time saver .... Each report that I      |
  69.     |   can convert from our ... accounting system saves our company about    |
  70.     |   500 man hours per year." -- R. Brooker                                |
  71.     |                                                                         |
  72.     |                                                                         |
  73.     +-------------------------------------------------------------------------+
  74.     |                                                                         |
  75.     |                                                                         |
  76.     |   "In 30 years of working with computers, this is by far the easiest    |
  77.     |   way I have found to extract data from files.  I was very surprised    |
  78.     |   that the program just took a few seconds to chew its way through      |
  79.     |   1MB of data.  You ought to mention it's FAST." -- Koenraad Rutgers    |
  80.     |                                                                         |
  81.     |                                                                         |
  82.     +-------------------------------------------------------------------------+
  83.     |                                                                         |
  84.     |                                                                         |
  85.     |   "Parse-O-Matic is THE greatest parsing package .... I wrote my own    |
  86.     |   software for parsing ... then I was introduced to POM and have been   |
  87.     |   using it ever since.  Good job!" -- Jeff Tallent, Vestax Securities   |
  88.     |                                                                         |
  89.     |                                                                         |
  90.     +-------------------------------------------------------------------------+
  91.  
  92.  
  93.  
  94.  
  95.     +---------------------- PARSE-O-MATIC IS VERSATILE -----------------------+
  96.     |                                                                         |
  97.     |                                                                         |
  98.     |                                                                         |
  99.     |    This manual was formatted by Parse-O-Matic, from plain text files.   |
  100.     |        The table of contents was also generated by Parse-O-Matic.       |
  101.     |                                                                         |
  102.     |                                                                         |
  103.     |                                                                         |
  104.     +-------------------------------------------------------------------------+
  105.  
  106.  
  107.  
  108.  
  109.     +------------------------ WHO USES PARSE-O-MATIC? ------------------------+
  110.     |                                                                         |
  111.     |                                                                         |
  112.     |              Some of our distinguished customers include:               |
  113.     |                                                                         |
  114.     |                                                                         |
  115.     |  Bankers Trust           HBO (Home Box Office)   Philip Morris          |
  116.     |                                                                         |
  117.     |  Berliner Volksbank      Harris Semiconductor    Pitney Bowes           |
  118.     |                                                                         |
  119.     |  Boeing                  Home Box Office         Prentice Hall          |
  120.     |                                                                         |
  121.     |  Bridgestone             Hughes                  Procter and Gamble     |
  122.     |                                                                         |
  123.     |  CIBA Vision             Ingram                  Rank Xerox             |
  124.     |                                                                         |
  125.     |  Calcomp Canada          Carrefour France        Kodak                  |
  126.     |                                                                         |
  127.     |  Royal Bank              Champion Int'l          Lipton Tea             |
  128.     |                                                                         |
  129.     |  Royal Caribbean         CompUSA                 May Department Stores  |
  130.     |                                                                         |
  131.     |  SmithKline Beacham      Degussa                 McCain Foods           |
  132.     |                                                                         |
  133.     |  Southwest Bancorp       Dresdner Bank           McDonald's             |
  134.     |                                                                         |
  135.     |  Sun Life                Eaton                   Monsanto France        |
  136.     |                                                                         |
  137.     |  Sundstrand Aerospace    Eddy                    NEC                    |
  138.     |                                                                         |
  139.     |  Target                  European American Bank  Nestle                 |
  140.     |                                                                         |
  141.     |  Visa International      First Bank System       Nike                   |
  142.     |                                                                         |
  143.     |  Yale University Press   First Federal           Novell                 |
  144.     |                                                                         |
  145.     |  Ziff-Davis              Georgia Gulf            Pacific Gas & Electric |
  146.     |                                                                         |
  147.     |                                                                         |
  148.     +-------------------------------------------------------------------------+
  149.  
  150.     
  151.     +-------------------------------------------------------------------------+
  152.     |                                                                         |
  153.     |                                                                         |
  154.     |       The above list includes our best known customers, but omits       |
  155.     |       city, state or provincial government offices and hospitals.       |
  156.     |                                                                         |
  157.     |                                                                         |
  158.     +-------------------------------------------------------------------------+
  159.  
  160.  
  161.     ============================================================================
  162.                                  TABLE OF CONTENTS
  163.     ============================================================================
  164.  
  165.     INTRODUCTION  1
  166.        What is Parse-O-Matic?  1
  167.        Parse-O-Matic Versus Automatic Converters  1
  168.        Why You Need Parse-O-Matic -- An Example  2
  169.        Parse-O-Matic to the Rescue!  2
  170.        How It Works  3
  171.        How To Contact Us  3
  172.  
  173.     FUNDAMENTALS  4
  174.        The Parse-O-Matic Command  4
  175.        The POM File  4
  176.        Padding for Clarity  5
  177.        A Simple Example  6
  178.  
  179.     QUICK REFERENCE  7
  180.        Command Descriptions  7
  181.           Basic Commands  7
  182.           Output Commands  7
  183.           Input Commands  7
  184.           Input Filters  7
  185.           Flow Control Commands  8
  186.           Variable Modifiers  8
  187.           Free-Form Commands  8
  188.           Positional Commands  8
  189.           Date Commands  8
  190.           Calculation Commands  9
  191.           Input Preprocessors  9
  192.           Lookup Commands  9
  193.           Data Converters  9
  194.           Miscellaneous Commands  9
  195.        Command Formats  10
  196.  
  197.     BASIC COMMANDS  13
  198.        The SET Command  13
  199.           Basic Usage  13
  200.           The Trimming String  14
  201.           Non-Keyable Characters  15
  202.           The Null-Handling String  15
  203.        The IF Command  16
  204.  
  205.     OUTPUT COMMANDS  17
  206.        The KEEP Command  17
  207.        The OFILE Command  18
  208.           Basic Usage  19
  209.           Closing the Output File  19
  210.           Strong Deduction  19
  211.           Weak Deduction  20
  212.           Appended Deductions  21
  213.        The OUT and OUTEND Commands  21
  214.           Generating a Blank Line  22
  215.           Missing Output  22
  216.        The OUTHDG Command  22
  217.        The OUTPAGE Command  23
  218.        The PAGELEN Command  24
  219.  
  220.     INPUT COMMANDS  26
  221.        The GET Command  26
  222.           Variable Length Records  27
  223.           Delimiter-Terminated Data  29
  224.           Handling Long Delimiter-Terminated Data  30
  225.           Using GET with Text Files  30
  226.           End-of-File Considerations  31
  227.        The GETTEXT Command  32
  228.        The READNEXT Command  33
  229.           End of File Conditions  33
  230.           Optional Comparisons  34
  231.           Ignoring Null Lines  34
  232.           Saving the Previous Line  34
  233.        The PEEK Command  35
  234.        The REWIND Command  36
  235.           Why REWIND is Necessary  36
  236.           Using REWIND  37
  237.           Example  37
  238.  
  239.     INPUT FILTERS  38
  240.        The MINLEN Command  38
  241.        The IGNORE Command  39
  242.        The ACCEPT Command  39
  243.           Clustered Accepts  40
  244.  
  245.     FLOW CONTROL COMMANDS  41
  246.        The BEGIN Command  41
  247.        The CALL Command  43
  248.           Variable CALLs  43
  249.           Making Your Technique Obvious  44
  250.           Avoiding Unknown Code Sections  44
  251.        The CODE Command  45
  252.           Performance Considerations  46
  253.           Nested Subroutine Calls  46
  254.           Variable Code Sections  46
  255.           A Note to Experienced Programmers  47
  256.        The ELSE Command  47
  257.        The END Command  48
  258.        The AGAIN Command  49
  259.           Using AGAIN for Variable-Length Data  50
  260.           Pointless Command Combinations  51
  261.           Examples  52
  262.        The DONE Command  53
  263.        The NEXTFILE Command  55
  264.        The HALT Command  56
  265.        The SETERROR Command  57
  266.        The PROLOGUE Command  58
  267.        The EPILOGUE Command  59
  268.  
  269.     VARIABLE MODIFIERS  61
  270.        The TRIM Command  61
  271.        The PAD Command  62
  272.        The CHANGE Command  62
  273.        The CVTCASE Command  63
  274.           Control Settings  64
  275.        The PROPER Command  64
  276.        The INSERT Command  66
  277.        The APPEND Command  67
  278.        The OVERLAY Command  68
  279.           Simple Arrays  69
  280.        The MAPFILE Command  70
  281.           What is a Map File?  70
  282.           Sample Map Files  70
  283.           Map File Format  71
  284.           Search Order  71
  285.           Case Matching  73
  286.           Reverse Mapping  73
  287.           Irreversible Mapping  74
  288.           Memory Limitations  75
  289.           An Example of Remapping  75
  290.        The REMAP Command  76
  291.           REMAP Versus CHANGE  77
  292.           Using REMAP  77
  293.  
  294.     FREE-FORM COMMANDS  78
  295.        What are Free-Form Commands?  78
  296.        The PARSE Command  78
  297.           Decapsulators  79
  298.           Sample Application  80
  299.           The Occurrence Number  80
  300.           Finding the Last Occurrence  81
  301.           Unsuccessful Searches  81
  302.           The Control Setting  82
  303.           The Plain Decapsulator  82
  304.           The Null Decapsulator  83
  305.           Why Null Decapsulators Work Differently  84
  306.           Overlapping Decapsulators  84
  307.           Parsing Empty Fields  85
  308.           Additional Examples  85
  309.        The PEEL Command  85
  310.           The Control Setting  86
  311.           Parsing Empty Fields  87
  312.           The Left-Peeling Technique  88
  313.           The Leftover Technique  88
  314.        The PEELX Command  89
  315.  
  316.     POSITIONAL COMMANDS  91
  317.        General Discussion  91
  318.           What are Positional Commands?  91
  319.           Why Use Positional Commands?  91
  320.           A Cautionary Note  92
  321.           Negative Positional Indices  93
  322.        The SETLEN Command  94
  323.        The DELETE Command  95
  324.        The COPY Command  96
  325.        The EXTRACT Command  97
  326.        The FINDPOSN Command  98
  327.           The Plain String Find  98
  328.           Using a Single Decapsulator  99
  329.           The Encapsulated String Find  99
  330.           Control Settings  101
  331.           Insoluble Searches  102
  332.           Null Decapsulators  102
  333.           Finding The Last Word  103
  334.           Who Needs This?  103
  335.        The SCANPOSN Command  104
  336.           The Scanlist  105
  337.           Accommodating Variation  105
  338.           Handling Prefixes and Suffixes  106
  339.           Controlling the Search  106
  340.           Leftmost, Rightmost, Find-Any  107
  341.           The Best Match Principle  108
  342.  
  343.     DATE COMMANDS  110
  344.        General Discussion  110
  345.           The POMDATE.CFG File  110
  346.           Date Formats  110
  347.        The TODAY Command  112
  348.        The DATE Command  113
  349.        The MONTHNUM Command  114
  350.        The ZERODATE Command  115
  351.  
  352.     CALCULATION COMMANDS  116
  353.        The CALC Command  116
  354.        The CALCREAL Command  118
  355.        The INC and DEC Commands  119
  356.        The ROUNDING Command  120
  357.        The CALCBITS Command  121
  358.  
  359.     INPUT PREPROCESSORS  123
  360.        The SPLIT Command  123
  361.           Indicating Actual Input Length  124
  362.           Non-Contiguous Splits  124
  363.        The CHOP Command  125
  364.           Manual Reading  125
  365.  
  366.     LOOKUP COMMANDS  126
  367.        The LOOKUP Command  126
  368.           Search Method  127
  369.           Limitations  127
  370.           Null Lines and Comments  128
  371.           Multiple Columns  128
  372.           LOOKUP Versus REMAP  129
  373.        The LOOKFILE Command  129
  374.        The LOOKCOLS Command  130
  375.        The LOOKSPEC Command  131
  376.  
  377.     DATA CONVERTERS  132
  378.        The MAKEDATA Command  132
  379.           Creating Binary Data  132
  380.           Converting Dates  133
  381.           Practical Considerations  134
  382.        The MAKETEXT Command  134
  383.           Converting Binary Data  135
  384.           Converting Dates  135
  385.           Practical Considerations  135
  386.  
  387.     MISCELLANEOUS COMMANDS  136
  388.        The ERASE Command  136
  389.        The FILESIZE Command  137
  390.        The GETENV Command  138
  391.           Disappearing Environment Variables  138
  392.           Examples  139
  393.        The LOG Command  139
  394.        The MSGWAIT Command  140
  395.           Standard Behavior  141
  396.           Setting a Time-Out Delay  141
  397.           Color Cues  141
  398.           Key Stacking  141
  399.           Exceptions  142
  400.           A Word of Caution  142
  401.        The PAUSE Command  142
  402.        The RANDOM Command  143
  403.        The SHOWNOTE Command  144
  404.           Other Notes  145
  405.           Slowing Down  145
  406.        The SOUND Command  145
  407.           The LISTEN Utility  146
  408.           Changing the Error Message Sound  146
  409.        The TRACE Command  147
  410.  
  411.     TERMS  148
  412.        Values  148
  413.        Variables  148
  414.        Predefined Values  149
  415.           $FLINE  149
  416.           $FLUPC  150
  417.           $LASTFLINE  150
  418.           $SPLIT  151
  419.           $LINECOUNTER  151
  420.        Running Out of Variables, Literals or Lines  152
  421.        Delimiters  153
  422.        Illegal Characters  153
  423.        Using Comparators  153
  424.           Literal Comparators  154
  425.           Numerical Comparators  155
  426.           Length Comparators  155
  427.           Literal Comparisons and Sort Order  155
  428.           Numeric Comparisons  156
  429.           Upgrading from Earlier Versions  157
  430.        Predefined Data Types  157
  431.           Interpreting Data Formats in a File  158
  432.  
  433.     DEDUCED VARIABLES  159
  434.        Deduced Variables  159
  435.           Definition  159
  436.           The Look-Up Process  160
  437.           Restrictions  160
  438.           Usage Guidelines  161
  439.        Array Variables  162
  440.           Multidimensional Arrays  163
  441.        Eponymous Variables  164
  442.           Drawbacks and Advantages  165
  443.  
  444.     VALUE TECHNIQUES  166
  445.        Uninitialized and Persistent Variables  166
  446.           Example  166
  447.        Inline Incrementing and Decrementing  167
  448.        Line Counters  168
  449.        The SHOWNUM Utility  168
  450.           Quick Reference Screen  168
  451.           Converting a Number  169
  452.           Converting a Character  169
  453.           Windows Considerations  170
  454.  
  455.     PROGRAMMING TECHNIQUES  171
  456.        Tracing  171
  457.        Logging  171
  458.  
  459.     COMMAND-LINE TECHNIQUES  173
  460.        Quiet Mode  173
  461.        User-Specified Command-Line Parameters  173
  462.           Case Considerations  174
  463.           Spaces in Values  174
  464.           Command-Line Switches  175
  465.           Hex and Decimal Code Strings  175
  466.        Summary  176
  467.  
  468.     FILE HANDLING  177
  469.        How Parse-O-Matic Searches for a File  177
  470.        How Parse-O-Matic Opens an Output File  178
  471.        Appending to an Output File  180
  472.        Sending Output to a Device  181
  473.           COM Ports  181
  474.        DbF Files  182
  475.        POM and Wildcards  182
  476.  
  477.     OPERATIONAL TECHNIQUES  184
  478.        Parse-O-Matic Job (POJ) Files  184
  479.           Simple Usage  184
  480.           Commenting a Job File  185
  481.           Prompting for File Names  185
  482.           Suggesting File Names  186
  483.           Optional Parameters  186
  484.           Examples  187
  485.        Encrypted (Scrambled) POM Files  187
  486.           The SCRAMBLE Utility  187
  487.           Why Scramble a POM File?  188
  488.           Support Considerations  188
  489.        Batch Files  189
  490.        Unattended Operation  193
  491.        Examples  195
  492.  
  493.     OPERATIONAL CONSIDERATIONS  196
  494.        Running Parse-O-Matic on 8088 and 8086 Machines  196
  495.        Running Parse-O-Matic from Another Program  196
  496.        Solving Memory Problems  196
  497.  
  498.     RUNNING UNDER WINDOWS  197
  499.        Compatibility  197
  500.        Setting Up for Windows 95  197
  501.           Setting Up an Association for the POM File  197
  502.           Setting Up an Association for a POJ (Job) File  198
  503.           Setting Up an Association for the BAT File (Optional)  199
  504.        Setting Up for Windows 98, Me, 2000  200
  505.           Additional Associations (Optional)  200
  506.        Installing the ShowNum Utility  201
  507.        Long File Names in Windows  201
  508.        The WINUTIL Utility  201
  509.           Limitations  202
  510.           Quick Reference Screen  202
  511.           Sample Batch File  202
  512.           Detecting if Windows is Running  203
  513.           Copying the Clipboard to a Text File  203
  514.           Copying a Text File to the Clipboard  204
  515.        The SEE Utility  204
  516.  
  517.  
  518.     
  519.     ============================================================================
  520.                                     INTRODUCTION
  521.     ============================================================================
  522.     
  523.                                ----------------------
  524.                                What is Parse-O-Matic?
  525.                                ----------------------
  526.     
  527.     Parse-O-Matic is a programmable file-parser.  Simple enough for even a non-
  528.     programmer to master, it can help out in countless ways.  If you have a
  529.     file you want to edit, manipulate, or change around, Parse-O-Matic may be
  530.     just the tool you need.  Parse-O-Matic can also speed up or automate long
  531.     or repetitive editing tasks.
  532.     
  533.                      -----------------------------------------
  534.                      Parse-O-Matic Versus Automatic Converters
  535.                      -----------------------------------------
  536.     
  537.     Parse-O-Matic is not an "automatic file converter".  It will not, for
  538.     example, convert WordPerfect files to MS-Word format, or convert Lotus
  539.     1-2-3 Spreadsheets DIRECTLY to Excel files -- although it can read reports
  540.     from one program and convert them to another format (e.g. comma-delimited),
  541.     which can be imported by the other program.
  542.     
  543.     One advantage of this method (as opposed to automatic file conversion) is
  544.     that you can create an "intelligent" importing procedure, which can make
  545.     decisions and modify data.  You could, for example, eliminate certain types
  546.     of records, tidy up names, convert case, unify fields, make calculations,
  547.     and so on.
  548.     
  549.     
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.                                                                               1
  573.                       ----------------------------------------
  574.                       Why You Need Parse-O-Matic -- An Example
  575.                       ----------------------------------------
  576.     
  577.     There are plenty of programs out there that have valuable data locked away
  578.     inside them.  How do you get that data OUT of one program and into another
  579.     one?
  580.     
  581.     Some programs provide a feature which "exports" a file into some kind of
  582.     generic format.  Perhaps the most popular of these formats is known as a
  583.     "comma-delimited file", which is a text file in which each data field is
  584.     separated by a comma.  Character strings -- which might themselves contain
  585.     commas -- are surrounded by double quotes.  So a few lines from a
  586.     comma-delimited file might look something like this (an export from a
  587.     hypothetical database of people who owe your company money):
  588.     
  589.     "JONES","FRED","1234 GREEN AVENUE", "KANSAS CITY", "MO",293.64
  590.     "SMITH","JOHN","2343 OAK STREET","NEW YORK","NY",22.50
  591.     "WILLIAMS","JOSEPH","23 GARDEN CRESCENT","TORONTO","ON",16.99
  592.     
  593.     Unfortunately, not all programs export or import data in this format.
  594.     Even more frustrating is a program that exports data in a format that is
  595.     ALMOST what you need!
  596.     
  597.     If that's the case, you might decide to spend a few hours in a text editor,
  598.     modifying the export file so that the other program can understand it.  Or
  599.     you might write a program to do the editing for you.  Both solutions are
  600.     time-consuming.
  601.     
  602.     An even more challenging problem arises when a program which has no export
  603.     capability does have the ability to "print" reports to a file.  You can
  604.     write a program to read these files and convert them to something you can
  605.     use, but this can be a LOT of work!
  606.     
  607.                             ----------------------------
  608.                             Parse-O-Matic to the Rescue!
  609.                             ----------------------------
  610.     
  611.     Parse-O-Matic is a utility that reads a file, interprets the data, and
  612.     outputs the result to another file.  It can help you "boil down" data to
  613.     its essential information.  You can also use it to convert NEARLY
  614.     compatible import files, or generate printable reports.
  615.     
  616.     
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.                                                                               2
  628.                                     ------------
  629.                                     How It Works
  630.                                     ------------
  631.     
  632.     You need three things:
  633.     
  634.     1) The Parse-O-Matic program
  635.     2) A Parse-O-Matic "POM" file (to tell Parse-O-Matic what to do)
  636.     3) The input file
  637.     
  638.     The input file might be a report or data file from another program, or text
  639.     captured from a communications session.  Parse-O-Matic can handle many
  640.     types of input.  We've provided several sample input files. For example,
  641.     the file XMPDAT02.TXT comes from the AccPac accounting software.  AccPac is
  642.     a great program, but its export capabilities leave something to be desired.
  643.     Parse-O-Matic can help!
  644.     
  645.     To see detailed demonstrations of how various files can be parsed, enter
  646.     INFO at the DOS prompt (or run INFO.BAT from Windows or OS/2), then select
  647.     TUTORIAL from the menu.
  648.     
  649.                                  -----------------
  650.                                  How To Contact Us
  651.                                  -----------------
  652.     
  653.     If you have any questions about Parse-O-Matic, you can write to us at the
  654.     following address:
  655.     
  656.      Pinnacle Software, 80 Mornelle Court #310, Toronto, ON, Canada M1E 4P8
  657.     
  658.     You can also contact us electronically at the following addresses:
  659.     
  660.                         Voice Line: 416-287-8892
  661.                     Internet Email: psoftinfo@aol.com
  662.                           Web Site: http://members.aol.com/psoftinfo
  663.     
  664.     
  665.     
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.                                                                               3
  683.     ============================================================================
  684.                                     FUNDAMENTALS
  685.     ============================================================================
  686.     
  687.     
  688.     This documentation assumes that you are an experienced computer user.  If
  689.     you have trouble, you might ask a programmer to help you -- POM file
  690.     creation is a little like programming!
  691.     
  692.                              -------------------------
  693.                              The Parse-O-Matic Command
  694.                              -------------------------
  695.     
  696.     The basic format of the Parse-O-Matic command line is:
  697.     
  698.     POM pom-file input-file output-file
  699.     
  700.     Here is an example, as you would type it at the DOS command line, or as a
  701.     command in a batch file:  POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  702.     
  703.     For a more formal description of the command line, start up POM by typing
  704.     this command at the DOS prompt:  POM
  705.     
  706.     Another method of calling the POM command is to specify a job (.POJ) file.
  707.     This is explained later, in the "Operational Planning" chapter -- see
  708.     "Parse-O-Matic Job (POJ) Files".  Briefly, a job file lets you save the
  709.     Parse-O-Matic command-line specifications in a text file.
  710.     
  711.                                     ------------
  712.                                     The POM File
  713.                                     ------------
  714.     
  715.     The POM file is a text file with a .POM extension.  The following
  716.     conventions are used when interpreting the POM file:
  717.     
  718.     - Null lines and lines starting with a semi-colon (comments) are ignored.
  719.     
  720.     - A POM file may contain up to 750 lines of specifications.
  721.       Comment lines do not count in this total.
  722.     
  723.     A POM file does not rely on "loops" (to use the programming term).  Each
  724.     line or record of the input file is processed by the entire POM file.  If
  725.     you would like this expressed in terms of programming languages, here is
  726.     what POM does:
  727.     
  728.     
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.                                                                               4
  738.     +-------------------------------------------------------------------------+
  739.     |      START: If there's nothing left in the input file, go to QUIT.      |
  740.     |             Read a line from the input file                             |
  741.     |             Do everything in the POM file                               |
  742.     |             Go to START                                                 |
  743.     |      QUIT:  Tell the user you are finished!                             |
  744.     +-------------------------------------------------------------------------+
  745.     
  746.     The method by which Parse-O-Matic finds the POM file is discussed in the
  747.     section "How Parse-O-Matic Searches for a File".
  748.     
  749.                                 -------------------
  750.                                 Padding for Clarity
  751.                                 -------------------
  752.     
  753.     Spaces and tabs between the words and variables in a POM file line are
  754.     generally ignored (except in the case of the "output picture" of the OUT
  755.     and OUTEND commands).  You can use spaces to make the commands in your POM
  756.     files easier to read.
  757.     
  758.     Additionally, in any line in the POM file, the following terms are ignored:
  759.     
  760.     THEN   ELSE
  761.     
  762.     (There is a POM command named ELSE, but Parse-O-Matic can tell that this is
  763.     not "padding".)
  764.     
  765.     Finally, the equals ("=") character is ignored if it is found in a place
  766.     where no comparison is taking place.  This will be demonstrated below.
  767.     
  768.     You can use these techniques to make your POM files easier to read.  For
  769.     example, the IF command can be written in several ways:
  770.     
  771.     Very terse:          IF PRICE = "0.00" BONUS "0.00" "1.00"
  772.     
  773.     Padded with spaces:  IF PRICE = "0.00"   BONUS   "0.00"   "1.00"
  774.     
  775.     Fully padded:        IF PRICE = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  776.     
  777.     In the last example, the first equals sign ("=") is a "comparator".  (For
  778.     details about comparators, see the section entitled "Using Comparators".)
  779.     The second equals sign is not really required, but it does make the line
  780.     easier to understand.
  781.     
  782.     
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.                                                                               5
  793.                                   ----------------
  794.                                   A Simple Example
  795.                                   ----------------
  796.     
  797.     Let's say you have a text file called NAMES.TXT that looks like this:
  798.     
  799.     WILLIAMS   JACK
  800.     SMITH      JOHNNY
  801.     JOHNSON    MARY
  802.     :          :
  803.     Column 1   Column 12
  804.     
  805.     Now let's say you want to switch the columns, so that the first name
  806.     appears first.  Your first step is to create a file using a text editor.
  807.     The file would look like this:
  808.     
  809.     SET    last  = $FLINE[ 1 10]
  810.     SET    first = $FLINE[12 17]
  811.     PAD    first "R" " " "10"
  812.     OUTEND |{first} {last}
  813.     
  814.     The first two lines tell Parse-O-Matic which text to extract from each
  815.     input line.  For the first line of the input file, the variable named
  816.     'last' will be given the value "WILLIAMS  ".  You will notice there are two
  817.     spaces at the end.  That is because we take every character from position 1
  818.     to position 10 -- which in this case includes two spaces.
  819.     
  820.     The PAD line adds enough spaces on the right side of the variable named
  821.     'first' to make sure that it is 10 characters long.  The OUTEND command
  822.     sends the two variables to the output file.
  823.     
  824.     Save the file with the name TEST.POM and exit your text editor.  At the DOS
  825.     prompt, enter this command:
  826.     
  827.     POM TEST.POM NAMES.TXT OUTPUT.TXT
  828.     
  829.     This will run the POM file (TEST.POM) on every line of the input file
  830.     (NAMES.TXT) and place the output in the file OUTPUT.TXT, which will then
  831.     look like this:
  832.     
  833.     JACK       WILLIAMS
  834.     JOHNNY     SMITH
  835.     MARY       JOHNSON
  836.     :          :
  837.     Column 1   Column 12
  838.     
  839.     Of course, for such a simple task, it would be easier to switch the columns
  840.     yourself, using a text editor.  But when you are dealing with large amounts
  841.     of data, and want to guard against typing errors, Parse-O-Matic can save
  842.     you a lot of time, effort and risk.  It also lets you automate editing
  843.     operations that you perform frequently.
  844.     
  845.     
  846.  
  847.                                                                               6
  848.     ============================================================================
  849.                                   QUICK REFERENCE
  850.     ============================================================================
  851.     
  852.                                 --------------------
  853.                                 Command Descriptions
  854.                                 --------------------
  855.     
  856.     This manual's explanations of the commands are grouped by related functions,
  857.     in the following order:
  858.     
  859.     ---------------------------------------------------------------------------
  860.     Basic Commands
  861.     ---------------------------------------------------------------------------
  862.     SET       Assigns a value to a variable
  863.     IF        Conditionally assigns a value to a variable
  864.     
  865.     ---------------------------------------------------------------------------
  866.     Output Commands
  867.     ---------------------------------------------------------------------------
  868.     KEEP      Do a page eject if less than the specified number of lines remain
  869.     OFILE     Specify output file or device
  870.     OUT       Sends text and variables to the output file
  871.     OUTEND    Like OUT but adds a new line at end (Carriage Return/Linefeed)
  872.     OUTHDG    Sets up title lines to appear at the top of a report or each page
  873.     OUTPAGE   Starts a new page
  874.     PAGELEN   Sets the page length for a report
  875.     
  876.     ---------------------------------------------------------------------------
  877.     Input Commands
  878.     ---------------------------------------------------------------------------
  879.     GET       Manually reads bytes from the input file
  880.     GETTEXT   Manually reads bytes from the input file, converts them to text
  881.     READNEXT  Moves to next input line but retains your place in the POM file
  882.     REWIND    Backs up a specified number of bytes in an input file
  883.     PEEK      Looks at the next line in a text input file
  884.     
  885.     ---------------------------------------------------------------------------
  886.     Input Filters
  887.     ---------------------------------------------------------------------------
  888.     MINLEN    Sets minimum length required for an input line to be processed
  889.     IGNORE    Ignores an input line that meets the specified condition
  890.     ACCEPT    Accepts an input line that meets the specified condition
  891.     
  892.     
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.                                                                               7
  903.     ---------------------------------------------------------------------------
  904.     Flow Control Commands
  905.     ---------------------------------------------------------------------------
  906.     BEGIN     Defines the conditions for processing the code block
  907.     CALL      Calls a subroutine code block
  908.     CODE      Marks the start of a subroutine code block
  909.     ELSE      Defines the start of code to be processed if the BEGIN fails
  910.     END       Ends a code block (BEGIN/END, CODE/END, PROLOGUE/END etc.)
  911.     AGAIN     Conditionally returns to the corresponding BEGIN command
  912.     DONE      Reads the next input line and starts at the top of the POM file
  913.     NEXTFILE  Skips the current input file and proceeds to the next (if any)
  914.     HALT      Terminates all processing if a given condition exists
  915.     SETERROR  Sets the program return code
  916.     PROLOGUE  Defines code block to run before any input lines are processed
  917.     EPILOGUE  Defines code block to run after  all input lines are processed
  918.     
  919.     ---------------------------------------------------------------------------
  920.     Variable Modifiers
  921.     ---------------------------------------------------------------------------
  922.     TRIM      Removes a character from the left, right or all of a variable
  923.     PAD       Centers, or left/right-justifies variable to a specified width
  924.     CHANGE    Replaces all occurrences of a string in a variable
  925.     PROPER    Properizes a variable (e.g. "JOHN SMITH" becomes "John Smith")
  926.     INSERT    Inserts a string on the left or right, or at a "found" position
  927.     APPEND    Concatenates several variables into one variable
  928.     OVERLAY   Extends or overwrites portions of a variable
  929.     CVTCASE   Converts a value to uppercase or lowercase
  930.     MAPFILE   Reads a file containing data transformations for REMAP
  931.     REMAP     Transforms sub-strings into other strings
  932.     
  933.     ---------------------------------------------------------------------------
  934.     Free-Form Commands
  935.     ---------------------------------------------------------------------------
  936.     PARSE     Obtains a variable found between delimiters in free-form data
  937.     PEEL      Works like PARSE, but removes the "found" text from the data
  938.     PEELX     Works like PEEL, but assumes presence of delimiter on last search
  939.     
  940.     ---------------------------------------------------------------------------
  941.     Positional Commands
  942.     ---------------------------------------------------------------------------
  943.     SETLEN    Sets a variable according to the length of a value
  944.     DELETE    Removes a range of characters from a variable
  945.     COPY      Copies a range of characters from a value to a variable
  946.     EXTRACT   Like COPY, but removes the characters from the source variable
  947.     FINDPOSN  Finds the starting or ending position of a value in another
  948.     SCANPOSN  Finds "best match" in list of values, returns start/end positions
  949.     
  950.     ---------------------------------------------------------------------------
  951.     Date Commands
  952.     ---------------------------------------------------------------------------
  953.     TODAY     Sets a variable to today's date, in a variety of formats
  954.     DATE      Sets a given year, month and day, in a variety of formats
  955.     MONTHNUM  Sets the month number of a given month, expressed as text
  956.  
  957.                                                                               8
  958.     ---------------------------------------------------------------------------
  959.     Calculation Commands
  960.     ---------------------------------------------------------------------------
  961.     CALC      Performs arithmetic functions on integer values
  962.     CALCREAL  Performs arithmetic functions on decimal values
  963.     DEC       Subtract a number from another (used for counters)
  964.     INC       Add a number to another (used for counters)
  965.     ROUNDING  Controls rounding in CALCREAL operations
  966.     
  967.     ---------------------------------------------------------------------------
  968.     Input Preprocessors
  969.     ---------------------------------------------------------------------------
  970.     SPLIT     Breaks up a wide text file (more than 255 characters)
  971.     CHOP      Breaks up a fixed-record-length file
  972.     
  973.     ---------------------------------------------------------------------------
  974.     Lookup Commands
  975.     ---------------------------------------------------------------------------
  976.     LOOKUP    Looks up a word in another file and returns a corresponding value
  977.     LOOKFILE  Specifies the file that the LOOKUP command will use (see also /L)
  978.     LOOKCOLS  Specifies the format of the look-up file
  979.     LOOKSPEC  Controls the behavior of the LOOKUP command
  980.     
  981.     ---------------------------------------------------------------------------
  982.     Data Converters
  983.     ---------------------------------------------------------------------------
  984.     MAKEDATA  Converts text into binary format
  985.     MAKETEXT  Converts binary format into text
  986.     
  987.     ---------------------------------------------------------------------------
  988.     Miscellaneous Commands
  989.     ---------------------------------------------------------------------------
  990.     ERASE     Deletes a file
  991.     FILESIZE  Obtains the size of a file (in bytes)
  992.     GETENV    Obtains a system environment variable (e.g. PATH)
  993.     LOG       Adds a line to the processing log
  994.     MSGWAIT   Controls the behavior of error messages
  995.     PAUSE     Delays the specified number of milliseconds
  996.     RANDOM    Generates a random number
  997.     SHOWNOTE  Displays a message on the processing screen
  998.     SOUND     Makes a noise or sets the noise generated by error messages
  999.     TRACE     Traces a variable (results saved in the text file POM.TRC)
  1000.     
  1001.     
  1002.     
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.                                                                               9
  1013.                                   ---------------
  1014.                                   Command Formats
  1015.                                   ---------------
  1016.     
  1017.     The following comment lines are for quick-reference.
  1018.     You can copy them into your own POM files to make programming easier.
  1019.     
  1020.     ----------------------------------  ---------------------------------------
  1021.     COMMAND FORMATS                     EXAMPLE
  1022.     ----------------------------------  ---------------------------------------
  1023.     ACCEPT   comp                       ACCEPT   $FLINE[1 3] = "YES"
  1024.     AGAIN    [comp]                     AGAIN    linecntr #< "3"
  1025.     APPEND   var val val [val [val]]    APPEND   name first last
  1026.     BEGIN    [comp]                     BEGIN    linecntr #< "3"
  1027.     CALL     val                        CALL     "Format Price Field"
  1028.     CALC     var num operation num      CALC     total total "+" sold
  1029.     CALCBITS var char operation char    CALCBITS z byte1 "XOR" $80
  1030.     CALCREAL var num operation num      CALCREAL salary hours "*" rate
  1031.     CHANGE   var val val                CHANGE   date "/" "-"
  1032.     CHOP     from to [,from to] [...]   CHOP     1 250, 251 300
  1033.     CODE     val                        CODE     "Format Price Field"
  1034.     COPY     var val ixfrom [ixto]      COPY     x $FLINE "-2" "-1"
  1035.     CVTCASE  var val [ctl]              CVTCASE  x $FLINE "L7"
  1036.     DATE     var num num num [ctl]      DATE     x "98" "12" "31"
  1037.     DEC      var val                    DEC      x "2"
  1038.     DELETE   var ixfrom [ixto]          DELETE   x "3" "5"
  1039.     DONE     [comp]                     DONE     $FLINE = "End Data"
  1040.     ELSE                                ELSE
  1041.     END                                 END
  1042.     EPILOGUE                            EPILOGUE
  1043.     ERASE    file                       ERASE    "C:\MYFILES\OUTPUT.TXT"
  1044.     EXTRACT  var var ixfrom [ixto]      EXTRACT  x $FLINE "15" "30"
  1045.     FILESIZE var file                   FILESIZE x "C:\MYFILES\INPUT.TXT"
  1046.     FINDPOSN var val left [right [ctl]] FINDPOSN x $FLINE "2*/"
  1047.     GET      var ctl [ctl [ctl]]        GET      x #0 "END" "I"
  1048.     GETENV   var val                    GETENV   x "COMSPEC"
  1049.     GETTEXT  var ctl [ctl]              GETTEXT  date "WORD" "DATE"
  1050.     HALT     comp val [ctl]             HALT     x = y "Item repeated"
  1051.     IF       comp var val [val]         IF       x = "Y" THEN z = "N"
  1052.     INC      var val                    INC      x "2"
  1053.     IGNORE   comp                       IGNORE   price = "0.00"
  1054.     INSERT   var ctl val                INSERT   price "L" "$"
  1055.     KEEP     num                        KEEP     "5"
  1056.     LOG      comp val [val [val]]       LOG      x = y "Item repeated"
  1057.     LOOKCOLS num num num num            LOOKCOLS "1" "3" "8" "255"
  1058.     LOOKFILE file                       LOOKFILE "C:\TABLES\DATA.TBL"
  1059.     LOOKSPEC ctl ctl ctl                LOOKSPEC "Y" "N" "N"
  1060.     LOOKUP   var val                    LOOKUP   phonenum "FRED JONES"
  1061.     MAKEDATA var val ctl                MAKEDATA x "255" "BYTE"
  1062.     MAKETEXT var val ctl                MAKETEXT z x "BYTE"
  1063.     MAPFILE  file val [ctl]             MAPFILE  "XYZ.MPF" "XYZ" "ANYCASE"
  1064.     MINLEN   num [num]                  MINLEN   "15" "1"
  1065.     MONTHNUM var val                    MONTHNUM x "February"
  1066.  
  1067.                                                                              10
  1068.     MSGWAIT  num                        MSGWAIT  "60"
  1069.     NEXTFILE [comp]                     NEXTFILE $FLINE = "End File"
  1070.     OFILE    file [val [ctl]]           OFILE    "C:\MYFILES\OUT.TXT"
  1071.     OUT      [comp] |pic                OUT      z = "X" |{price}
  1072.     OUTEND   [comp] |pic                OUTEND   z = "X" |{$FLINE}
  1073.     OUTHDG   val                        OUTHDG   "LIST OF EMPLOYEES"
  1074.     OUTPAGE  [comp]                     OUTPAGE  partnum <> oldpartnum
  1075.     OVERLAY  var val from               OVERLAY  x "***" "15"
  1076.     PAD      var ctl char num           PAD      sernum "L" "0" "10"
  1077.     PAGELEN  num [ctl]                  PAGELEN  "66" "N"
  1078.     PARSE    var val left right [ctl]   PARSE    x $FLINE "2*(" "3*)" "I"
  1079.     PAUSE    num                        PAUSE    "1000"
  1080.     PEEK     var                        PEEK     nextline
  1081.     PEEL     var var left right [ctl]   PEEL     x $FLINE "2*(" "3*)" "I"
  1082.     PEELX    var var left right [ctl]   PEELX    word wordlist "" " "
  1083.     PROLOGUE                            PROLOGUE
  1084.     PROPER   var [ctl [file]]           PROPER   custname "I" "XY.PEF"
  1085.     RANDOM   var val val                RANDOM   roll "1" "6"
  1086.     READNEXT [comp]                     READNEXT $FLINE[1 5] = "NOTE:"
  1087.     REMAP    var [val]                  REMAP    $FLINE "BIN2CODE"
  1088.     REWIND   [num]                      REWIND   "15"
  1089.     ROUNDING val                        ROUNDING "N"
  1090.     SCANPOSN var var val val [ctl]      SCANPOSN from to $FLINE "/MR/MISS/MRS"
  1091.     SET      var val [val [val]]        SET      price $FLINE[20 26] "L$" "0"
  1092.     SETERROR [comp] val                 SETERROR custname = "NONE" "123"
  1093.     SETLEN   var val                    SETLEN   length custname
  1094.     SHOWNOTE val [val] [val] [...]      SHOWNOTE "Processing record #" recnum
  1095.     SOUND    ctl                        SOUND    "BUZZ"
  1096.     SPLIT    from to [,from to] [...]   SPLIT    1 250, 251 300
  1097.     TODAY    var [ctl]                  TODAY    x "?y/?n/?d"
  1098.     TRACE    var                        TRACE    price
  1099.     TRIM     var ctl char               TRIM     price "R" "$"
  1100.     ZERODATE num num num                ZERODATE "1753" "12" "31"
  1101.     ----------------------------------  ---------------------------------------
  1102.     
  1103.     The following conventions are used in the preceding table:
  1104.     
  1105.     comp   A comparison (Example: Name = "John")
  1106.     ctl    Variable or literal: command control specifications
  1107.     file   File name (see "How Parse-O-Matic Searches for a File")
  1108.     from   Variable or literal: a starting character position (see Note #1)
  1109.     ixfrom Variable or literal: character position (beginning from...)
  1110.     ixto   Variable or literal: character position (ending at...)
  1111.     left   Variable or literal: a delimiter-search parameter (decapsulator)
  1112.     num    Variable or literal: must contain a number (see Note #1)
  1113.     pic    Output picture used by OUT and OUTEND
  1114.     right  Variable or literal: a delimiter-search parameter (decapsulator)
  1115.     to     Variable or literal: an ending position (see Note #1)
  1116.     val    Variable or literal whose value is being read
  1117.     var    Variable that is being set
  1118.     [xxx]  Square brackets indicate optional items
  1119.     
  1120.     
  1121.  
  1122.                                                                              11
  1123.     Note #1:  Tabs, spaces and commas are stripped from numeric values
  1124.     
  1125.     The commands are explained in detail in the following sections.  A summary
  1126.     of the commands and default settings appear, as comments, in the file
  1127.     QUICKREF.POM.  You can copy these comments into your own POM file as
  1128.     a convenient quick reference.
  1129.     
  1130.     
  1131.     
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.                                                                              12
  1178.     ============================================================================
  1179.                                    BASIC COMMANDS
  1180.     ============================================================================
  1181.     
  1182.                                   ---------------
  1183.                                   The SET Command
  1184.                                   ---------------
  1185.     
  1186.     FORMAT:        SET var1 value1 [value2 [value3]]
  1187.     
  1188.     PURPOSE:       SET assigns value1 to the variable var1.
  1189.     
  1190.     PARAMETERS:    var1   is the variable being set
  1191.                    value1 is the value being read
  1192.                    value2 is the optional trimming string
  1193.                    value3 is the optional null-handling string
  1194.     
  1195.     ALTERNATIVES:  The COPY command, or just about any command that sets
  1196.                    a variable.
  1197.     
  1198.     SEE ALSO:      The TRIM Command
  1199.     
  1200.     -----------
  1201.     Basic Usage
  1202.     -----------
  1203.     
  1204.     The usual reason to use the SET command is to set a variable from the input
  1205.     line (represented by the variable $FLINE) prior to cleaning it up with TRIM.
  1206.     
  1207.     For example, if the input line looked like this:
  1208.     
  1209.     JOHN       SMITH     555-1234   322 Westchester Lane    Architect
  1210.     |          |         |          |                       |
  1211.     Column 1   Col 12    Col 22     Col 33                  Col 57
  1212.     
  1213.     then we could extract the last name from the input line with these two POM
  1214.     commands:
  1215.     
  1216.     SET  name1 = $FLINE[12 21]   <-- Sets the variable name1 from the input line
  1217.     TRIM name1  "R"  " "         <-- Trims any spaces on the right side
  1218.     
  1219.     SET would first assign the variable name1 this value:     "SMITH     "
  1220.     After the TRIM, the variable name1 would have the value:  "SMITH"
  1221.     
  1222.     You will also use SET if you plan to include a portion of text string in
  1223.     the output, since the OUT and OUTEND commands do not recognize substrings
  1224.     (e.g. myvar[10 20]) after the "|" marker; they only recognize plain text
  1225.     and complete variables.
  1226.     
  1227.     
  1228.  
  1229.  
  1230.  
  1231.  
  1232.                                                                              13
  1233.     -------------------
  1234.     The Trimming String
  1235.     -------------------
  1236.     
  1237.     After SETting a variable, you may wish to use one or more TRIM commands to
  1238.     "tidy up" the variable by removing leading and trailing spaces, extraneous
  1239.     commas, and so on.  However, you can do this at the same time as you do the
  1240.     SET command, using the optional "trimming string".
  1241.     
  1242.     The trimming string is a list of pairs of characters.  The first character
  1243.     in the pair is the TRIM specification, while the second is the character
  1244.     being trimmed.
  1245.     
  1246.     Consider the following POM code:
  1247.     
  1248.     SET   xyz    = "xx$3.00xx"
  1249.     SET   price1 = xyz            <-- Sets price1 to "XX$3.00XX"
  1250.     TRIM  price1 "B" "x"          <-- Sets price1 to "$3.00"
  1251.     TRIM  price1 "L" "$"          <-- Sets price1 to "3.00"
  1252.     
  1253.     This achieves the desired result (i.e. it gets rid of the "x" characters and
  1254.     the dollar sign), but it takes up four lines of code.  You can use SET's
  1255.     trimming string to accomplish the same thing:
  1256.     
  1257.     SET   xyz    = "xx$3.00xx"
  1258.     SET   price1 = xyz "BxL$"     <-- Sets price1 to "3.00"
  1259.     
  1260.     The "BxL$" trimming string (made up of the character pairs "Bx" and "L$")
  1261.     instructs Parse-O-Matic as follows:
  1262.     
  1263.     CHAR  TRIMMING
  1264.     PAIR  OPERATION
  1265.     ----  ---------
  1266.      Bx   Strip away "x" on Both sides of the value, yielding "$3.00", then...
  1267.      L$   Strip the dollar sign on the Left side, yielding "3.00"
  1268.     
  1269.     The trimming string is interpreted from left to right.  Thus, the following
  1270.     commands would NOT produce the same result as the previous example:
  1271.     
  1272.     SET   xyz    = "xx$3.00xx"
  1273.     SET   price1 = xyz "L$Bx"
  1274.     
  1275.     Parse-O-Matic will try to strip the dollar signs on the left, but since
  1276.     there are none there, it will move on to the next step without changing
  1277.     anything.  It will then remove the "x" characters.  The final result will
  1278.     be "$3.00", not "3.00".
  1279.     
  1280.     
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.                                                                              14
  1288.     ----------------------
  1289.     Non-Keyable Characters
  1290.     ----------------------
  1291.     
  1292.     In the trimming string, the second character in each character-pair must be
  1293.     a keyable character (i.e. something you can type on your keyboard and see on
  1294.     your screen).  You can not use the $hex or #decimal representations (see
  1295.     "Values" in the "Terms" chapter).
  1296.     
  1297.     The following command is valid:
  1298.     
  1299.     SET   num1 = $FLINE[10 20] "B A,"
  1300.     
  1301.     This will remove the spaces on both sides and eliminate any commas.
  1302.     
  1303.     The following command is NOT valid:
  1304.     
  1305.     SET   hex1 = $FLINE[10 20] "B$00R#13"
  1306.     
  1307.     The SET command can not translate the $00 code into "hex character zero".
  1308.     Similarly, it does not recognize the #13 as "decimal character 13" (which
  1309.     is, by the way, the ASCII "carriage return" character).
  1310.     
  1311.     To strip non-keyable characters, use the TRIM command.
  1312.     
  1313.     ------------------------
  1314.     The Null-Handling String
  1315.     ------------------------
  1316.     
  1317.     Sometimes you want to assign a "default" value to a variable if it turns out
  1318.     to be null (i.e. empty).  Here is one way to do this:
  1319.     
  1320.     SET   xyz = ""                       <-- This is a null string
  1321.     SET   price1 = xyz                   <-- Sets price1 to ""
  1322.     IF    price1 = "" THEN price1 = "0"  <-- Sets price1 to "0"
  1323.     
  1324.     It is easier to do this by using the null-handling string, as in this
  1325.     example:
  1326.     
  1327.     SET   xyz    = "$3.00"               <-- This is a normal price
  1328.     SET   price1 = xyz "L$" "0.00"       <-- Sets price1 to "3.00"
  1329.     SET   xyz    = "$"                   <-- This is just a dollar sign!
  1330.     SET   price2 = xyz "L$" "0.00"       <-- Sets price2 to "0.00"
  1331.     
  1332.     In the first case (xyz = "$3.00"), all we had to do was strip away the
  1333.     dollar sign to obtain the price.  In the second case (xyz = "$"), we
  1334.     ended up with a null value after stripping away the dollar sign.  In such
  1335.     case, the null-handling string ("0.00") specified the default value.
  1336.     
  1337.     
  1338.  
  1339.  
  1340.  
  1341.  
  1342.                                                                              15
  1343.     Sometimes you don't want to do any triming, but you do want to check for a
  1344.     default value. Nevertheless, the trimming string must be included in the
  1345.     command, as a "place holder".  For example:
  1346.     
  1347.     SET   xyz    = "Fred Smith"          <-- This is a normal name
  1348.     SET   name1  = xyz "" "Unknown"      <-- Sets name1 to "Fred Smith"
  1349.     SET   xyz    = ""                    <-- This is a null string
  1350.     SET   name2  = xyz "" "Unknown"      <-- Sets name2 to "Unknown"
  1351.     
  1352.     As you can see, no trimming was necessary, but we nevertheless had to
  1353.     include the trimming string, even though it was null (meaning, "Don't
  1354.     do any trimming").
  1355.     
  1356.                                    --------------
  1357.                                    The IF Command
  1358.                                    --------------
  1359.     
  1360.     FORMAT:        IF value1 [comparator] value2 var1 value3 [value4]
  1361.     
  1362.     PURPOSE:       If value1 equals value2, var1 is set to value3.  Otherwise,
  1363.                    it is set to value4 (if value4 is missing, nothing is done,
  1364.                    and var1 is not changed).
  1365.     
  1366.     NOTES:         For an explanation of comparators, see "Using Comparators".
  1367.                    In the following explanation, we will demonstrate the
  1368.                    command using only the "literally identical" ("=")
  1369.                    comparator.
  1370.     
  1371.     ALTERNATIVES:  The BEGIN command
  1372.     
  1373.     Here is an example of the IF command...
  1374.     
  1375.     SET  EARNING = $FLINE[20 23]
  1376.     IF   EARNING = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  1377.     
  1378.     This obtains the value between columns 20 and 26, then checks if it equals
  1379.     "0.00".  If it does, the variable BONUS is set to 0.00.  If not, BONUS is
  1380.     set to "1.00".  The "THEN" and "ELSE" are "padding" and can be omitted.
  1381.     
  1382.     
  1383.     
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.                                                                              16
  1398.     ============================================================================
  1399.                                   OUTPUT COMMANDS
  1400.     ============================================================================
  1401.     
  1402.                                   ----------------
  1403.                                   The KEEP Command
  1404.                                   ----------------
  1405.     
  1406.     FORMAT:        KEEP value1
  1407.     
  1408.     PURPOSE:       KEEP does a page eject if less than the specified number of
  1409.                    lines remain on the page.
  1410.     
  1411.     PARAMETERS:    value1 is the minimum number of lines required to avoid doing
  1412.                    a page eject.
  1413.     
  1414.     ALTERNATIVES:  The OUTPAGE command, used with $LINECOUNTER
  1415.     
  1416.     NOTES:         KEEP has no effect unless the page length is set, using the
  1417.                    PAGELEN command.
  1418.     
  1419.     SEE ALSO:      "The OutHdg Command"
  1420.     
  1421.     When you are sending output to a file that will be printed (or sending
  1422.     output directly to a printer -- see "How Parse-O-Matic Opens an Output
  1423.     File"), you sometimes want to ensure that certain lines of data are kept
  1424.     together on the same page.  The most common situation involves a heading
  1425.     that precedes some associated data; you do not want to have the heading by
  1426.     itself at the bottom of one page, with the data on the next. Consider this
  1427.     POM file:
  1428.     
  1429.     PAGELEN  "55"                        <-- Set the output page length
  1430.     SET      part     = $FLINE[ 1 10]    <-+
  1431.     SET      type     = $FLINE[12 20]      | Extract the fields
  1432.     SET      quantity = $FLINE[22 30]    <-+
  1433.     BEGIN    lasttype <> type            <-- Detect a change in part type
  1434.       SET      lasttype = part           <-- Remember this part type
  1435.       KEEP     "4"                       <-- Make sure we have 4 lines left
  1436.       OUTEND   |                         <-- Output a blank line
  1437.       OUTEND   |PART TYPE:  {type}       <-- Output a header
  1438.     END                                  <-- End of code block
  1439.     OUTEND   {part} {quantity}           <-- Output part data
  1440.     
  1441.     This POM file will always make sure that at least two part numbers follow
  1442.     the heading; a heading will never be "stranded" by itself at the end of a
  1443.     page.
  1444.     
  1445.     
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.                                                                              17
  1453.                                  -----------------
  1454.                                  The OFILE Command
  1455.                                  -----------------
  1456.     
  1457.     FORMAT:        OFILE value1
  1458.                    OFILE value1 [value2 [value3]]
  1459.     
  1460.     PURPOSE:       OFILE specifies a new output file or device.
  1461.     
  1462.     PARAMETERS:    value1 is the name of the output file or device
  1463.                    value1 can also be a subcommand (i.e. a command for OFILE)
  1464.                    value2 is the default extension for the DEDUCE subcommand
  1465.                    value3 is the control value for the DEDUCE subcommand
  1466.     
  1467.     DEFAULTS:      value2 defaults to "" for the DEDUCE subcommand
  1468.                    value3 defaults to "WEAK" for the DEDUCE subcommand
  1469.     
  1470.     ALTERNATIVES:  Specify the name of the output file on the POM command line
  1471.     
  1472.     SEE ALSO:      "How Parse-O-Matic Opens an Output File"
  1473.                    "Sending Output to a Device"
  1474.     
  1475.     When you start up Parse-O-Matic, you can specify the name of the output
  1476.     file on the command line.  For example:
  1477.     
  1478.     POM MYPOM.POM INPUT.TXT OUTPUT.TXT
  1479.     
  1480.     In this case, the output file is named OUTPUT.TXT.  All data from the
  1481.     output commands (OUT, OUTEND etc.) are sent to this file.  If you omit the
  1482.     output file name from the POM command, like this:
  1483.     
  1484.     POM MYPOM.POM INPUT.TXT
  1485.     
  1486.     then Parse-O-Matic assumes the output file is named POMOUT.TXT (in the
  1487.     current directory).
  1488.     
  1489.     
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.                                                                              18
  1508.     -----------
  1509.     Basic Usage
  1510.     -----------
  1511.     
  1512.     Once the name of the output file has been determined, Parse-O-Matic will
  1513.     use that file until it is changed, using the OFILE command.  For example:
  1514.     
  1515.     OFILE "C:\XYZ.TXT"
  1516.     
  1517.     This will change the output file to C:\XYZ.TXT.  If the file already
  1518.     exists, it will be renamed with a BAK extension.  However, you can tell
  1519.     Parse-O-Matic to append to the end of an existing file by placing a plus
  1520.     sign in front of the file name:
  1521.     
  1522.     OFILE "+C:\XYZ.TXT"
  1523.     
  1524.     (See "Appending to Output Files" and "POM and Wildcards" for additional
  1525.     details on appending to output files).
  1526.     
  1527.     -----------------------
  1528.     Closing the Output File
  1529.     -----------------------
  1530.     
  1531.     Sometimes you want your POM file to explicitly close the output file before
  1532.     doing additional processing.  By closing the file explicitly, you ensure
  1533.     that all output has been written to the disk.
  1534.     
  1535.     To explicitly close the output file, use OFILE's CLOSE subcommand:
  1536.     
  1537.     OFILE "(CLOSE)"
  1538.     
  1539.     It is rarely necessary to explicitly close the output file, since this is
  1540.     done automatically when Parse-O-Matic finishes processing.  You only need to
  1541.     do this if you suspect that a failure may occur between an OUT[END] command
  1542.     and the next OFILE command (or the completion of processing).
  1543.     
  1544.     ----------------
  1545.     Strong Deduction
  1546.     ----------------
  1547.     
  1548.     Sometimes you want to relate the name of the output file to the input file.
  1549.     For example, if the input file is XYZ.TXT, you might want to name the output
  1550.     file XYZ.OUT -- in other words, the same root name (XYZ) but a different
  1551.     extension (OUT).
  1552.     
  1553.     The OFILE command can do this with the DEDUCE subcommand, as follows:
  1554.     
  1555.     OFILE "(DEDUCE)" "OUT" "STRONG"
  1556.     
  1557.     The (DEDUCE) subcommand tells OFILE that you want it to use the same root
  1558.     name as the input file.  The "OUT" part of this example is the extension you
  1559.     want to use.  "STRONG" means that you want to override the existing output
  1560.     file, even if the user specified one on the command line.
  1561.  
  1562.                                                                              19
  1563.     Here is another example:
  1564.     
  1565.     OFILE "(DEDUCE)" "CSV" "STRONG"
  1566.     
  1567.     This uses the same root name as the input file, but uses the CSV extension
  1568.     (CSV usually signifies a comma-separated-value file).  Once again, the
  1569.     "STRONG" parameter means that the new output file will be opened even if the
  1570.     user specified an output file on the POM command line.
  1571.     
  1572.     --------------
  1573.     Weak Deduction
  1574.     --------------
  1575.     
  1576.     Sometimes you want to set the output file name only if the user has not
  1577.     specified one on the POM command line.  You can do this with OFILE's DEDUCE
  1578.     subcommand:
  1579.     
  1580.     OFILE "(DEDUCE)" "CSV" "WEAK"
  1581.     
  1582.     If the user ran POM with this command:
  1583.     
  1584.     POM MYFILE.POM ACCOUNT.DAT
  1585.     
  1586.     then the output file would be set to ACCOUNT.CSV.  However, if the user
  1587.     explicitly specified an output file:
  1588.     
  1589.     POM MYFILE.POM ACCOUNT.DAT MYOUTPUT.TXT
  1590.     
  1591.     then the weak OFILE command would be ignored and output would continue to
  1592.     be directed to the MYOUTPUT.TXT file.
  1593.     
  1594.     Weak deduction is generally used in the PROLOGUE section of a POM file.  It
  1595.     is particularly useful when wildcards are used (See "POM and Wildcards").
  1596.     Consider this POM command:
  1597.     
  1598.     POM MYFILE.POM *.DAT
  1599.     
  1600.     You could put the following OFILE command in the PROLOGUE:
  1601.     
  1602.     OFILE "(DEDUCE)" "TXT"        <-- "WEAK" is the default deduction
  1603.     
  1604.     This would create a separate output file for each file that is processed.
  1605.     So if you had three DAT files, named A.DAT, B.DAT and C.DAT, you would
  1606.     create three output files, named A.TXT, B.TXT and C.TXT.
  1607.     
  1608.     Because this is a weak deduction, the user is not forced to use your output
  1609.     method.  If the user typed the POM command this way:
  1610.     
  1611.     POM MYFILE.POM *.DAT MYOUTPUT.TXT
  1612.     
  1613.     then all the output (from all of the input files) would go to MYOUTPUT.TXT.
  1614.     
  1615.     
  1616.  
  1617.                                                                              20
  1618.     NOTE:  When a user does not specify an output file, Parse-O-Matic
  1619.            temporarily assumes that the output file is named POMOUT.TXT. If the
  1620.            user actually types POMOUT.TXT on the command line, Parse-O-Matic
  1621.            treats it as if no output file name had been typed.
  1622.     
  1623.     -------------------
  1624.     Appended Deductions
  1625.     -------------------
  1626.     
  1627.     An alternative to the DEDUCE subcommand is the +DEDUCE subcommand.  This
  1628.     will figure out the output file name as before, but all output will be
  1629.     appended to the end.  This is useful for daily processing when you want to
  1630.     accumulate data in your output file or files.  For example:
  1631.     
  1632.     OFILE "(+deduce)" "txt" "strong"     <-- Note that case does not matter
  1633.     
  1634.     If the user started POM with this command:
  1635.     
  1636.     POM MYFILE.POM ACCOUNT.DAT
  1637.     
  1638.     then the output file would be set to ACCOUNT.TXT, and all output would be
  1639.     placed at the end of the existing file of that name.
  1640.     
  1641.                             ---------------------------
  1642.                             The OUT and OUTEND Commands
  1643.                             ---------------------------
  1644.     
  1645.     FORMAT:        OUT[END] [value1 [comparator] value2] |output-picture
  1646.     
  1647.     PURPOSE:       The OUT command generates output without an end-of-line
  1648.                    (i.e. carriage return and linefeed characters).
  1649.                    The OUTEND command generates output and also adds an
  1650.                    end-of-line.
  1651.     
  1652.     NOTES:         For an explanation of comparators, see "Using Comparators".
  1653.                    In the following explanation, we will demonstrate the
  1654.                    command using only the "literally identical" ("=")
  1655.                    comparator.
  1656.     
  1657.     When value1 equals value2, a line is sent to the output file, according to
  1658.     the output picture.  Within the output picture, all text is taken literally
  1659.     (i.e. " is taken to mean literally that -- a quotation mark character).
  1660.     
  1661.     The only exception to this is variable names, which are identified by the
  1662.     { and } characters.  For example, a POM file that contained the following
  1663.     single line:
  1664.     
  1665.     OUTEND "X" = "X" |{$FLINE}
  1666.     
  1667.     would simply output every line from the input file (not very useful!).
  1668.     
  1669.     
  1670.  
  1671.  
  1672.                                                                              21
  1673.     The "X" = "X" part of the command is the comparison which controls when
  1674.     output occurs.  In the example above, both values being compared are the
  1675.     same, so output will always occur.
  1676.     
  1677.     You can not use substrings after the "|" marker.  Thus, the following line
  1678.     is NOT legal:  OUTEND $FLINE[1 3] = "IBM" |{$FLINE[1 15]}
  1679.     
  1680.     The correct way to code this is as follows:
  1681.     
  1682.     SET CODE = $FLINE[1 15]
  1683.     OUTEND $FLINE[1 3] = "IBM" |{CODE}
  1684.     
  1685.     This outputs the first 15 characters of any line that contains the letters
  1686.     "IBM" in the first three positions.
  1687.     
  1688.     -----------------------
  1689.     Generating a Blank Line
  1690.     -----------------------
  1691.     
  1692.     To send a blank line to a text output file, specify OUTEND without any data
  1693.     following the | marker, as follows:
  1694.     
  1695.     OUTEND |
  1696.     
  1697.     --------------
  1698.     Missing Output
  1699.     --------------
  1700.     
  1701.     If you find that an OUT or OUTEND command is not displaying a variable, but
  1702.     puts "nothing" in its place, check the spelling of the variable name in each
  1703.     place it is used.  Consider this example:
  1704.     
  1705.     SET     varablex = $FLINE[1 12]
  1706.     OUTEND  |XX{variablex}ZZ
  1707.     
  1708.     The SET command spelled "variablex" incorrectly -- it left out the "i". When
  1709.     OUTEND encounters the variable named "variablex", it sees that it does not
  1710.     have a value, so it replaces it with "nothing", yielding the result "XXZZ".
  1711.     
  1712.                                  ------------------
  1713.                                  The OUTHDG Command
  1714.                                  ------------------
  1715.     
  1716.     FORMAT:        OUTHDG value1
  1717.     
  1718.     PURPOSE:       OUTHDG is used to place text headers in your output.
  1719.     
  1720.     ALTERNATIVES:  The OUTEND command, used with PROLOGUE
  1721.     
  1722.     SEE ALSO:      "The PageLen Command" and "The OutPage Command"
  1723.     
  1724.     
  1725.  
  1726.  
  1727.                                                                              22
  1728.     If you were parsing data to create an employee report, you might use OUTHDG
  1729.     like this:
  1730.     
  1731.     SET EMPNUM = $FLINE[ 1  5]
  1732.     SET NAME   = $FLINE[10 28]
  1733.     SET PHONE  = $FLINE[30 45]
  1734.     OUTHDG "EMPL#  NAME                PHONE NUMBER"
  1735.     OUTHDG "-----  ------------------- ------------"
  1736.     OUTEND |{EMPNUM} {NAME} {PHONE}
  1737.     
  1738.     The value following the OUTHDG command is sent to the output file only
  1739.     once.  That is to say, after an OUTHDG sends a value to the output file,
  1740.     subsequent encounters with that OUTHDG command are ignored -- unless the
  1741.     PAGELEN command is used.
  1742.     
  1743.     To specify a blank line in a heading, use the following command:  OUTHDG ""
  1744.     
  1745.     If your output is bound for a continuous-paper printer (e.g. a dot-matrix
  1746.     printer with tractor feed), you may find it useful to use one or more blank
  1747.     lines at the beginning of the header, in order to skip over the perforation
  1748.     in the paper.
  1749.     
  1750.                                 -------------------
  1751.                                 The OUTPAGE Command
  1752.                                 -------------------
  1753.     
  1754.     FORMAT:        OUTPAGE  [value1 [comparison] value2]
  1755.     
  1756.     PURPOSE:       Sends a page eject to the output file (or device).
  1757.     
  1758.     NOTES:         For an explanation of comparators, see "Using Comparators".
  1759.     
  1760.     SEE ALSO:      "The Pagelen Command", "The OutHdg Command", "$LINECOUNTER"
  1761.     
  1762.     If the comparison in the OUTPAGE command is true, or if it is omitted,
  1763.     OUTPAGE will send a "page eject" to the output file or device.  (See
  1764.     "Sending Output to a Device")  Some exceptions apply, however.  The page
  1765.     eject is not sent under the following circumstances:
  1766.     
  1767.     - If the comparison is false (e.g. OUTPAGE "Y" = "N")
  1768.     
  1769.     - If the page length is set to "0" (the default).  Use the PAGELEN command
  1770.       to specify a different page length.
  1771.     
  1772.     - If the output file is not yet open.  That is to say, if no output has
  1773.       been sent to the output via one of the other output commands (e.g. OUT,
  1774.       OUTEND, OUTHDG), then OUTPAGE will do nothing. (See "How Parse-O-Matic
  1775.       Opens an Output File")
  1776.     
  1777.     - If the output is already at the top of a page.
  1778.     
  1779.     
  1780.  
  1781.  
  1782.                                                                              23
  1783.     If form feeds are enabled (via the PAGELEN command), OUTPAGE sends a
  1784.     page eject by sending a Form Feed character (ASCII 12) to the output.
  1785.     
  1786.     If form feeds are not enabled, OUTPAGE sends blank lines (i.e. linefeeds)
  1787.     until the requisite number of lines appear on the page.
  1788.     
  1789.     OUTPAGE does NOT automatically place OUTHDG text at the top of the page.
  1790.     OUTHDG text is not "stored"; it is executed in the POM file at the place
  1791.     it occurs.  Here is an example of using OUTPAGE and OUTHDG together:
  1792.     
  1793.     PAGELEN "55" "Y"
  1794.     SET partnum = $FLINE[ 1  7]
  1795.     SET descrip = $FLINE[12 60]
  1796.     OUTPAGE partnum <> oldpartnum
  1797.     OUTHDG |PARTNUM  DESCRIPTION
  1798.     OUTHDG |-------  -----------
  1799.     OUTEND |{partnum}  {descrip}
  1800.     SET    oldpartnum = partnum
  1801.     
  1802.     This will generate a new page, complete with headings, when the partnum
  1803.     variable is different from the oldpartnum variable.  Also, because of the
  1804.     interaction between OUTHDG and PAGELEN, they headings will appear on a new
  1805.     page if you run out of room on the current page.
  1806.     
  1807.                                 -------------------
  1808.                                 The PAGELEN Command
  1809.                                 -------------------
  1810.     
  1811.     FORMAT:        PAGELEN value1 [value2]
  1812.     
  1813.     PURPOSE:       The PAGELEN command specifies the length of the output page.
  1814.     
  1815.     PARAMETERS:    value1 is the page length
  1816.                    value2 specifies if form feeds should be used
  1817.     
  1818.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  1819.     
  1820.     DEFAULTS:      value2 = "Y"
  1821.     
  1822.     When text is sent to an output file by OUTHDG and OUTEND, the lines are
  1823.     counted.  The default value for page length is zero, which means that the
  1824.     output is a single page of infinite length.  As such, OUTHDG headings
  1825.     appear only the first time they are encountered, and OUTPAGE commands
  1826.     are ignored.
  1827.     
  1828.     If you specify a page length greater than zero, OUTHDG headings become
  1829.     re-enabled once the specified number of output lines have been generated,
  1830.     or after an OUTPAGE command is performed.  A typical value is as follows:
  1831.     
  1832.     PAGELEN "55"
  1833.     
  1834.     This is an ideal page length for most laser printers.  Dot matrix printers
  1835.     typically use a page length of 66.
  1836.  
  1837.                                                                              24
  1838.     Parse-O-Matic inserts a "form feed" (ASCII 12) character between pages.
  1839.     You can turn this off, however, by specifying the page length this way:
  1840.     
  1841.     PAGELEN "66" "N"
  1842.     
  1843.     The "N" specification means, "No, don't use form feeds".  Another
  1844.     acceptable value is "Y", meaning "Yes, use form feeds", but since this is
  1845.     the default, you do not have to specify it.
  1846.     
  1847.     
  1848.     
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.                                                                              25
  1893.     ============================================================================
  1894.                                    INPUT COMMANDS
  1895.     ============================================================================
  1896.     
  1897.                                   ---------------
  1898.                                   The GET Command
  1899.                                   ---------------
  1900.     
  1901.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  1902.     
  1903.     FORMAT:        GET var1 value1 [value2]         (Variable length records)
  1904.                    GET var1 value1 "END" [value3]   (Delimiter-terminated data)
  1905.                    GET var1 "EOF"                   (Detects end-of-file)
  1906.     
  1907.     PURPOSE:       Manually reads bytes from the input file.
  1908.     
  1909.     RESTRICTIONS:  The input file must be described with CHOP or SPLIT.
  1910.     
  1911.     NOTES:         Data is normally read automatically from the input file.
  1912.                    GET is used only when you want precise control of the
  1913.                    reading process.  GET works only with files whose format
  1914.                    is defined by a CHOP or SPLIT command.  (You can read a
  1915.                    file a byte at a time by using CHOP 1-1 in your POM file.
  1916.                    You can also use CHOP 0 to do all reading manually.)
  1917.     
  1918.     SEE ALSO:      "The Chop Command" and "The Split Command"
  1919.     
  1920.     The GET command is especially helpful for:
  1921.     
  1922.     1) Variable length records
  1923.     2) Delimiter-terminated data (such as zero-terminated text strings)
  1924.     3) Text files with embedded binary data
  1925.     
  1926.     These methods are described in detail below.
  1927.     
  1928.     
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.                                                                              26
  1948.     -----------------------
  1949.     Variable Length Records
  1950.     -----------------------
  1951.     
  1952.     FORMAT:        GET var1 value1 [value2]
  1953.     
  1954.     PURPOSE:       Reads a variable-length record.
  1955.     
  1956.     PARAMETERS:    var1    is the variable being set
  1957.                    value1  specifies how many bytes to read, expressed as:
  1958.                            A value in text format (example:  GET x "10")
  1959.                            A predefined data type (example:  GET x "INTEGER")
  1960.                            A value in byte format (example:  GET x len "BYTE")
  1961.                    value2  specifies the data representation used by value1
  1962.                            This can be "TEXT" (the default) or "BYTE"
  1963.                            May also include "STRICT" (the default) or "LOOSE"
  1964.     
  1965.     NUMERICS:      Tabs, spaces and commas are stripped from value1, if it is
  1966.                    numeric, and in text format
  1967.     
  1968.     DEFAULTS:      value2 = "TEXT"
  1969.     
  1970.     SEE ALSO:      "Predefined Data Types"
  1971.     
  1972.     GET can read up to 255 bytes into a variable, as specified by value1.
  1973.     For example:
  1974.     
  1975.     GET xyz "10"
  1976.     
  1977.     This reads 10 bytes from the input file into the xyz variable, and advances
  1978.     the file pointer.  That is to say, after the GET command shown above is
  1979.     executed, the next data Parse-O-Matic reads will be 10 bytes further along.
  1980.     
  1981.     If the requested number of bytes is not available in the input file,
  1982.     Parse-O-Matic terminates with an error message.
  1983.     
  1984.     In a typical application, variable-length data is preceded in the input
  1985.     file by a byte that gives its length.  You can read the length, then use
  1986.     it directly, as follows:
  1987.     
  1988.     GET len "1" "TEXT"               <-- Get the length byte
  1989.     GET xyz len "BYTE"               <-- Read in the data
  1990.     
  1991.     In the first command, the word "TEXT" means that the length specification
  1992.     (i.e. "1") is plain text.  ("TEXT" is the default, so you can omit it.)
  1993.     
  1994.     In the second command, GET reads len bytes from the input file.  The word
  1995.     "BYTE" means that the length specification is a binary number, not a text
  1996.     string.
  1997.     
  1998.     
  1999.  
  2000.  
  2001.  
  2002.                                                                              27
  2003.     To clarify this, let us assume that the input file contains a length byte
  2004.     (say hex 4F, which equals 79 in decimal).  This is followed by 79 bytes of
  2005.     data.  The first GET command (GET len "1") reads in the length byte (hex 4F
  2006.     or decimal 79).  The second GET command (GET xyz len "BYTE") reads 79 bytes
  2007.     and places the result in the xyz variable.
  2008.     
  2009.     The maximum variable length that a single GET command can handle is 255
  2010.     bytes (i.e. the largest number represented by a single byte).
  2011.     
  2012.     Here are some additional examples of the GET command:
  2013.     
  2014.     SAMPLE COMMAND     EXPLANATION
  2015.     -----------------  -----------
  2016.     GET x "5" "TEXT"   Reads 5 bytes into the x variable
  2017.     GET x "5"          Same as above (since "TEXT" is the default)
  2018.     GET x len          In this case, len must contain a text number (e.g. "7")
  2019.     GET x len "BYTE"   In this case, len must be a byte (i.e. binary format)
  2020.     
  2021.     When the number is in "TEXT" format, spaces and tabs are ignored. Thus, the
  2022.     following command is valid:
  2023.     
  2024.     GET abc " 5 " "TEXT"
  2025.     
  2026.     You can also specify the length of the data as a predefined data type (see
  2027.     "Predefined Data Types" and "The MakeData Command").  Some examples...
  2028.     
  2029.     SAMPLE COMMAND     EXPLANATION
  2030.     -----------------  -----------
  2031.     GET x "INTEGER"    Reads in an integer value (2 bytes long)
  2032.     GET x "SHORTINT"   Reads in a short integer value (1 byte long)
  2033.     GET x "BYTE"       Reads in a byte value (1 byte long)
  2034.     GET x "LONGINT"    Reads in a long integer (4 bytes long)
  2035.     GET x "REAL"       Reads in a real value (6 bytes long)
  2036.     GET x "REAL 2"     Same as above (the decimal precision value 2 is ignored)
  2037.     
  2038.     TECHNICAL NOTE:  In some applications, you will find that a variable-length
  2039.     record may be followed by a "noise" byte. This can occur if the program
  2040.     that created the input file "aligns data to word boundaries" and the record
  2041.     you are reading has an odd number of bytes.  In such case, your POM file
  2042.     must determine (using CALC commands) if the length byte is odd or even, and
  2043.     react accordingly.
  2044.     
  2045.     
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.                                                                              28
  2058.     -------------------------
  2059.     Delimiter-Terminated Data
  2060.     -------------------------
  2061.     
  2062.     FORMAT:        GET var1 value1 "END" [value3]
  2063.     
  2064.     PURPOSE:       Reads delimiter-terminated data from the input file.
  2065.     
  2066.     PARAMETERS:    var1    is the variable being set
  2067.                    value1  is the terminating character you are searching for
  2068.                    "END"   means you are searching for a terminating character
  2069.                    value3  is "I" (for Include) or "X" (for eXclude)
  2070.     
  2071.     DEFAULTS:      value3 = "X"
  2072.     
  2073.     ALTERNATIVES:  The PARSE and PEEL commands
  2074.                    The FINDPOSN command used with the COPY command
  2075.     
  2076.     One common way to represent variable-length text data in a file is to
  2077.     terminate the text string with the null (ASCII 0) character.  You can
  2078.     read in this kind of data with the GET command, as follows:
  2079.     
  2080.     GET abc #0 "END"           <-- #0 means ASCII zero (See "Values")
  2081.     
  2082.     This reads the input file until the null (ASCII 0) character is found, or
  2083.     until 255 characters have been read in (whichever comes first).
  2084.     
  2085.     The terminating character is not included in the string unless you
  2086.     explicitly request it.  There are two forms of GET command that control
  2087.     this behavior:
  2088.     
  2089.     GET abc #0 "END" "X"       <-- Exclude the terminating character (default)
  2090.     GET abc #0 "END" "I"       <-- Include the terminating character
  2091.     
  2092.     Here is a sample POM file that reads a data file that consists entirely of
  2093.     zero-terminated strings:
  2094.     
  2095.     CHOP   0                   <-- This means you will handle all file reading
  2096.     GET    abc #0 "END"        <-- Read in the data
  2097.     OUTEND |{abc}              <-- Send the data to the output file
  2098.     
  2099.     
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.                                                                              29
  2113.     ---------------------------------------
  2114.     Handling Long Delimiter-Terminated Data
  2115.     ---------------------------------------
  2116.     
  2117.     If some of the data is more than 255 characters long, you can handle it as
  2118.     follows:
  2119.     
  2120.     CHOP   0                   <-- Handle all file reading manually
  2121.     GET    data #0 "END" "I"   <-- Include the terminating character
  2122.     SETLEN len data            <-- Get the length of the string
  2123.     COPY   lastchar data len   <-- Get the last character
  2124.     BEGIN  lastchar = #0       <-- Test the last character
  2125.       DELETE data len          <-- Remove the last character (the terminator)
  2126.       OUTEND |{data}           <-- Output the string, and start a new line
  2127.     ELSE
  2128.       OUT    |{data}           <-- Output the string, but stay on the same line
  2129.     END
  2130.     
  2131.     All of the examples given above assume that the terminating character is
  2132.     ASCII 0 (i.e. #0), because this is by far the most common terminator.
  2133.     However, you can use other values, if required:
  2134.     
  2135.     GET data "X" "END"
  2136.     
  2137.     In actual usage, it is not likely that you will find data strings that are
  2138.     terminated by an "X" character, but the capability is there if the need
  2139.     arises.
  2140.     
  2141.     -------------------------
  2142.     Using GET with Text Files
  2143.     -------------------------
  2144.     
  2145.     While the GET command is normally used with a file which is CHOPped (see
  2146.     "The Chop Command"), you may occasionally find it useful with ordinary text
  2147.     files.  For example, an input file may be almost entirely text (i.e. each
  2148.     line ends with a carriage return and a linefeed), but may also contain some
  2149.     binary data.
  2150.     
  2151.     In such cases, you may find it useful to use the GET command to process the
  2152.     binary data.  However, since GET is not available under standard text
  2153.     processing, you must describe the file with the SPLIT command.  Here is an
  2154.     example which detects and extracts binary data until the character $FF is
  2155.     encountered:
  2156.     
  2157.     
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.                                                                              30
  2168.     SPLIT    1-255                      <-- Process this as a SPLIT file
  2169.     BEGIN    $FLINE[1 10] = "Binary:"   <-- Detect the start of binary data
  2170.       BEGIN                             <-- Start of loop
  2171.         GET    x "1"                    <-- Get a byte
  2172.         OUT    |{x}                     <-- Send it to output
  2173.       AGAIN  x <> $FF                   <-- See if we are finished
  2174.     ELSE                                <-- Handle ordinary text
  2175.       OUTEND   |{$FLINE}                <-- Output ordinary text
  2176.     END                                 <-- End of BEGIN/ELSE/END code block
  2177.     
  2178.     Note that SPLIT 1-255 does not mean that each text line is 255 characters
  2179.     long; it means that each line is UP TO 255 characters long.
  2180.     
  2181.     --------------------------
  2182.     End-of-File Considerations
  2183.     --------------------------
  2184.     
  2185.     When you ask the GET command to get something (e.g. a certain number of
  2186.     bytes), it will normally cause Parse-O-Matic to terminate if it reaches the
  2187.     end of the input file before it has fulfilled its mission.  The assumption
  2188.     here is that when you ask for something, you want precisely that -- not
  2189.     something less.
  2190.     
  2191.     However, in some parsing applications you do not know precisely what "lies
  2192.     ahead" in the input file.  In such cases, you may run up against the end of
  2193.     file unexpectedly.  GET provides two ways to handle this.
  2194.     
  2195.     The first method simply checks to see if you are already at the end of the
  2196.     file:
  2197.     
  2198.     GET x "EOF"
  2199.     
  2200.     This sets the x variable to "Y" (for Yes) if you are at the end of the input
  2201.     file.  Otherwise, it sets the x variable to "N" (for No).  Here is an
  2202.     example, which simply copies a file:
  2203.     
  2204.     CHOP     0             <-- Handle all file-reading manually
  2205.     BEGIN
  2206.       GET      x "EOF"     <-- Check if we're at the end of the input file
  2207.       BEGIN    x = "N"
  2208.         GET      byte "1"  <-- Get a byte
  2209.         OUT      |{byte}   <-- Send it to the output file
  2210.       END
  2211.     AGAIN    x = "N"
  2212.     
  2213.     An alternative method is to use a "LOOSE" GET command, as in this example:
  2214.     
  2215.     
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.                                                                              31
  2223.     CHOP     0
  2224.     BEGIN
  2225.       GET      x "1" "TEXT LOOSE"
  2226.       OUT      |{x}
  2227.     AGAIN    x <> ""
  2228.     
  2229.     The LOOSE parameter tells Parse-O-Matic "don't terminate if you have less
  2230.     than the specified number of bytes".  (The default is "STRICT", but since it
  2231.     IS the default, you never actually have to include it in the command.)
  2232.     Thus, all of the following commands are valid:
  2233.     
  2234.     GET x $05 "BYTE LOOSE"    <-- Get from 0 to 5 bytes of data
  2235.     GET x $05 "BYTE STRICT"   <-- Get exactly 5 bytes of data, or terminate
  2236.     GET x "5" "TEXT LOOSE"    <-- Get from 0 to 5 bytes of data
  2237.     GET x "5" "LOOSE"         <-- Same as "TEXT LOOSE"
  2238.     GET x "1"                 <-- Same as "TEXT STRICT"
  2239.     
  2240.                                 -------------------
  2241.                                 The GETTEXT Command
  2242.                                 -------------------
  2243.     
  2244.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  2245.     
  2246.     FORMAT:        GETTEXT var1 value1 [value2]
  2247.     
  2248.     PURPOSE:       Manually reads bytes from the input file, then converts
  2249.                    them into text format.
  2250.     
  2251.     PARAMETERS:    var1   is the variable being set
  2252.                    value1 is the predefined data type in the input file
  2253.                    value2 is the MAKETEXT "convert from" parameter
  2254.     
  2255.     DEFAULTS:      If value2 is omitted, it is assumed to be the same as value1
  2256.     
  2257.     NOTES:         Before studying this command, you should already be familiar
  2258.                    with the GET and MAKETEXT commands.
  2259.     
  2260.     SEE ALSO:      "Predefined Data Types"
  2261.     
  2262.     When reading a binary file, you frequently need to read numeric values then
  2263.     convert them to text.  For example:
  2264.     
  2265.     GET      x "WORD"             <-- Read a two-byte number from the file
  2266.     MAKETEXT y x "WORD"           <-- Convert it into text form
  2267.     
  2268.     You can do both of these operations at once, using the GETTEXT command:
  2269.     
  2270.     GETTEXT  y "WORD"
  2271.     
  2272.     This reads a "WORD" (two binary bytes) from the input file, and then
  2273.     converts it into text (e.g. "1234").
  2274.     
  2275.     
  2276.  
  2277.                                                                              32
  2278.     You only need to use value2 if you are converting a number to a text-based
  2279.     data type such as "DATE".  For example:
  2280.     
  2281.     ZERODATE "1936" "1" "1"                <-- Set "day zero"
  2282.     GETTEXT  date "LONGINT" "DATE Y/M/?d"  <-- Get and convert a date
  2283.     
  2284.     The GETTEXT command is also helpful if you are reading text data from a
  2285.     fixed-length field, but it is padded with spaces or nulls:
  2286.     
  2287.     GETTEXT  x "80" "TRIMMED"
  2288.     
  2289.     This reads in 80 characters, then removes tabs, spaces and nulls from
  2290.     either end of the string.
  2291.     
  2292.                                 --------------------
  2293.                                 The READNEXT Command
  2294.                                 --------------------
  2295.     
  2296.     FORMAT:        READNEXT [value [comparator] value]
  2297.     
  2298.     PURPOSE:       The READNEXT command gets the next line of the input file
  2299.                    (in other words, it replaces the current $FLINE), while
  2300.                    maintaining your place in the POM file.
  2301.     
  2302.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2303.     
  2304.     SEE ALSO:      "The MinLen Command" and "Line Counters"
  2305.     
  2306.     READNEXT is helpful if you know for certain what type of information the
  2307.     next line will contain.  Here is an example:
  2308.     
  2309.     SET note = ""
  2310.     SET customer = $FLINE[1 20]
  2311.     BEGIN $FLINE ^ "See note below"
  2312.       READNEXT
  2313.       SET note = $FLINE[1 20]
  2314.     END
  2315.     OUTEND |{customer} {note}
  2316.     
  2317.     If the input line contains the words "See note below", Parse-O-Matic will
  2318.     read the next line of the input file (replacing the current $FLINE), thus
  2319.     obtaining the comment about the customer.
  2320.     
  2321.     ----------------------
  2322.     End of File Conditions
  2323.     ----------------------
  2324.     
  2325.     If you do a READNEXT at the end of the input file, READNEXT will set $FLINE
  2326.     to null ("").  The POM file will continue processing.
  2327.     
  2328.     
  2329.  
  2330.  
  2331.  
  2332.                                                                              33
  2333.     --------------------
  2334.     Optional Comparisons
  2335.     --------------------
  2336.     
  2337.     READNEXT can make a comparison.  This is useful for skipping extraneous
  2338.     lines of input.  For example:
  2339.     
  2340.     READNEXT $FLINE[1 5] = "NOTE:"
  2341.     
  2342.     This obtains the next input line if the current input line starts with
  2343.     "NOTE:".
  2344.     
  2345.     -------------------
  2346.     Ignoring Null Lines
  2347.     -------------------
  2348.     
  2349.     By default, READNEXT will read null lines from the input file.  If you want
  2350.     it to ignore null lines, you can use an optional parameter of the MINLEN
  2351.     command to specify a minimum length for the READNEXT command.  For details,
  2352.     see "The MinLen Command".
  2353.     
  2354.     If you are reading a DBF (DBase) file, you can not "ignore null lines",
  2355.     because the data is not in line format.  In such case, you must check a
  2356.     particular field to see if it is null.  (See "DBF Files")
  2357.     
  2358.     If you are using the CHOP or SPLIT commands, it may not be particularly
  2359.     useful to "ignore null lines", since by definition you are requesting a
  2360.     particular number of bytes each time the input is read.  Nevertheless,
  2361.     if you do a READNEXT at the end of the input file, READNEXT will set $FLINE
  2362.     to null (""), and continue processing the POM file.
  2363.     
  2364.     ------------------------
  2365.     Saving the Previous Line
  2366.     ------------------------
  2367.     
  2368.     When you do a READNEXT, there is no simple way to return to the previous
  2369.     line of the input file.  You could use the REWIND command, but if you need a
  2370.     line for other work, it is usually much easier to save a copy:
  2371.     
  2372.     SET note = ""
  2373.     SET customer = $FLINE[1 20]
  2374.     SET saveline = $FLINE
  2375.     BEGIN $FLINE ^ "See note below"
  2376.       READNEXT
  2377.       SET note = $FLINE[1 20]
  2378.     END
  2379.     SET    custnum = saveline[22 25]
  2380.     OUTEND |{custnum} {customer} {note}
  2381.     
  2382.     The example above is not very efficient; it would make more sense to extract
  2383.     custnum BEFORE you use READNEXT.  However, in some applications you may find
  2384.     it necessary to save $FLINE before doing a READNEXT.
  2385.     
  2386.  
  2387.                                                                              34
  2388.                                   ----------------
  2389.                                   The PEEK Command
  2390.                                   ----------------
  2391.     
  2392.     FORMAT:        PEEK var1
  2393.     
  2394.     PURPOSE:       Looks at the next input line in a simple text file.
  2395.     
  2396.     PARAMETERS:    var1   is the variable being set
  2397.     
  2398.     RESTRICTIONS:  PEEK can not be used with SPLIT, CHOPped or DBF files.  For
  2399.                    SPLIT or CHOPped files, you can simulate PEEK by using the
  2400.                    GET and REWIND commands.
  2401.     
  2402.     NOTES:         If you are at the end of the input file, PEEK will set var1
  2403.                    to a null value ("").
  2404.     
  2405.     WARNING:       You can use PEEK only once for each pass through the POM
  2406.                    file.  If you use it more than once, you will lose data.
  2407.     
  2408.     ALTERNATIVES:  The READNEXT command
  2409.     
  2410.     If you are processing a simple text file (i.e. a text file in which no input
  2411.     line exceeds 255 characters), you can find out what is on the next input
  2412.     line by using the PEEK command.  Consider this input file:
  2413.     
  2414.     Fred Jones
  2415.     Pencil           $  0.25
  2416.     Pen              $  1.25
  2417.     
  2418.     Mary Smith
  2419.     Protractor       $  1.00
  2420.     Compass          $  2.50
  2421.     Pen              $  1.25
  2422.     Calligraphy Kit  $ 15.30
  2423.     
  2424.     In this input file, a customer's name is followed by one or more items that
  2425.     he or she purchased.  The input file does not contain a number telling us
  2426.     how many of each item there are.  If it is our intention to add up the
  2427.     prices to obtain a total, it would be helpful if we had some warning that we
  2428.     have reached the last item.  Fortunately, a null line (or end of file)
  2429.     follows each list of items.  We can use the PEEK command to take advantage
  2430.     of this, as in the following POM file:
  2431.     
  2432.     
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.                                                                              35
  2443.     BEGIN $FLINE[18] <> "$"           <-- Is this a price line?
  2444.       OUTEND |Customer Name: $FLINE   <-- Output customer's name
  2445.       DONE                            <-- We're finished with this line
  2446.     END
  2447.     PEEK nextline                     <-- Find out what the next line contains
  2448.     BEGIN nextline = ""               <-- If it's null, we have no more items
  2449.       OUTEND |Total:  {total}         <-- Output the total for all purchases
  2450.       SET    total = "0.0"            <-- Reset the total
  2451.     ELSE
  2452.       CALCREAL total = total "+" $FLINE[19 24]  <-- Accumulate the total
  2453.     END
  2454.     
  2455.                                  ------------------
  2456.                                  The REWIND Command
  2457.                                  ------------------
  2458.     
  2459.     FORMAT:        REWIND [value1]
  2460.     
  2461.     PURPOSE:       REWIND backs up to an earlier point in the input file.
  2462.     
  2463.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  2464.     
  2465.     DEFAULTS:      If value1 is omitted, input file is rewound to the beginning
  2466.     
  2467.     RESTRICTIONS:  The input file must be described with CHOP or SPLIT.
  2468.     
  2469.     SEE ALSO:      "Using GET with Text Files"
  2470.     
  2471.     -----------------------
  2472.     Why REWIND is Necessary
  2473.     -----------------------
  2474.     
  2475.     Normally, when you process an input file, you read forward in the file.
  2476.     However, on occasion you may find it necessary to back up to an earlier
  2477.     point in the file.
  2478.     
  2479.     Here is a typical situation where this is necessary:  you are looking for
  2480.     one of several strings of data, and when you find one of them, you want to:
  2481.     
  2482.     - Back up in the input file, to the beginning of the string you found
  2483.     - Use DONE to start processing the POM file from the top
  2484.     
  2485.     Because you rewound, the processing will include the text that you found.
  2486.     This is a handy alternative to saving the text and appending it to the front
  2487.     of $FLINE -- see "The Leftover Technique" for an example of that method.
  2488.     
  2489.     In another situation, you need to know something near the middle or end of
  2490.     the file, and once you have found out what that is, you want to rewind to
  2491.     the beginning and start processing again.  This is known as "multiple-pass"
  2492.     processing, because you pass through the input file more than once.
  2493.     
  2494.     
  2495.  
  2496.  
  2497.                                                                              36
  2498.     ------------
  2499.     Using REWIND
  2500.     ------------
  2501.     
  2502.     If REWIND is used without any parameters (or if you specify REWIND "0"),
  2503.     Parse-O-Matic resets the input file to the beginning.  This will usually be
  2504.     done in a BEGIN/END block, because if you reset the file each time you
  2505.     process the POM file, it will run forever.
  2506.     
  2507.     If REWIND is given a numeric parameter, it will back up that many bytes.
  2508.     (If you are processing a text file, remember to include two bytes for
  2509.     carriage return and linefeed, as necessary.)
  2510.     
  2511.     If the REWIND command is asked to rewind before the beginning of the file,
  2512.     it simply resets to the top.  For example, if you have read 15 bytes out of
  2513.     the input file, and you issue the command REWIND "99", the next byte you
  2514.     read will be the first byte of the file.
  2515.     
  2516.     -------
  2517.     Example
  2518.     -------
  2519.     
  2520.     Consider this POM file:
  2521.     
  2522.     CHOP     0            <-- Handle all reading manually
  2523.     GET      x "1"        <-- Get a byte
  2524.     GET      x "1"        <-- Get another byte
  2525.     OUT      |{x}         <-- Output the byte
  2526.     REWIND   "1"          <-- Back up one byte
  2527.     GET      x "1"        <-- Get the same byte again
  2528.     OUT      |{x}         <-- Output the byte
  2529.     NEXTFILE              <-- Stop processing this input file
  2530.     
  2531.     The code shown above will output the second character of an input file
  2532.     twice, then stop -- not very useful, except as a demonstration!
  2533.     
  2534.     
  2535.     
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.                                                                              37
  2553.     ============================================================================
  2554.                                    INPUT FILTERS
  2555.     ============================================================================
  2556.     
  2557.                                  ------------------
  2558.                                  The MINLEN Command
  2559.                                  ------------------
  2560.     
  2561.     FORMAT:        MINLEN value1 [value2]
  2562.     
  2563.     PURPOSE:       MINLEN specifies the minimum length an input line must be to
  2564.                    be considered for parsing.
  2565.     
  2566.     PARAMETERS:    value1 is the minimum input line length
  2567.                    value2 is the minimum length for a READNEXT command
  2568.     
  2569.     NUMERICS:      Tabs, spaces and commas are stripped from value1 and value2
  2570.     
  2571.     DEFAULTS:      value2 = "0"
  2572.     
  2573.     SEE ALSO:      "The ReadNext Command"
  2574.     
  2575.     If you omit the MINLEN command, the minimum length is assumed to be 1.
  2576.     That is to say, all lines 1 character or longer will be processed and
  2577.     shorter lines (null lines in other words) will be ignored.
  2578.     
  2579.     MINLEN is useful for ignoring brief information lines that clutter up a
  2580.     report that you are parsing.  For example, in the sample file EXAMPL02.POM,
  2581.     the MINLEN command is set to 85 to ensure that all lines shorter than 85
  2582.     characters long will be ignored.  This simplifies the coding considerably.
  2583.     
  2584.     The longest allowable input line is 255 characters, unless you use the
  2585.     SPLIT or CHOP command (see "The Split Command" and "The Chop Command").
  2586.     
  2587.     The optional setting value2 specifies the minimum length for a READNEXT
  2588.     command.  If omitted, this value is assumed to be "0", meaning that
  2589.     READNEXT will, by default, read null lines.  If you set value2 to "1",
  2590.     READNEXT will keep reading until it finds an input line of 1 or more
  2591.     characters, or hits the end of file.  The value2 setting has no effect
  2592.     if you are reading a DBF (DBase) file.
  2593.     
  2594.     
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.                                                                              38
  2608.                                  ------------------
  2609.                                  The IGNORE Command
  2610.                                  ------------------
  2611.     
  2612.     FORMAT:        IGNORE value1 [comparator] value2
  2613.     
  2614.     PURPOSE:       When the comparison is true, the input line is ignored and
  2615.                    all further processing on the input line stops.
  2616.     
  2617.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2618.     
  2619.     ALTERNATIVES:  The ACCEPT and BEGIN commands
  2620.     
  2621.     Here is a typical application of the IGNORE command:
  2622.     
  2623.     IGNORE $FLINE[3 9] ^ "Date"
  2624.     
  2625.     This skips any input line that contains the word "Date" between columns 3
  2626.     and 9 ($FLINE is the line just read from the input file).
  2627.     
  2628.                                  ------------------
  2629.                                  The ACCEPT Command
  2630.                                  ------------------
  2631.     
  2632.     FORMAT:        ACCEPT value1 [comparator] value2
  2633.     
  2634.     PURPOSE:       The ACCEPT command accepts the input line if the comparison
  2635.                    is true.  value2.  ACCEPT commands can be "clustered" to
  2636.                    allow a series of related tests.
  2637.     
  2638.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2639.                    In the following explanation, we will demonstrate the
  2640.                    command using only the "literally identical" ("=")
  2641.                    comparator.
  2642.     
  2643.     ALTERNATIVES:  The IGNORE command
  2644.     
  2645.     If the entire POM file reads as follows:
  2646.     
  2647.     ACCEPT $FLINE[15 17] = "YES"
  2648.     OUTEND "X" = "X" |{$FLINE}
  2649.     
  2650.     then any input line that contains "YES" starting in column 15 is sent to
  2651.     the output file.  All other lines are ignored.
  2652.     
  2653.     
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.                                                                              39
  2663.     -----------------
  2664.     Clustered Accepts
  2665.     -----------------
  2666.     
  2667.     Sometimes you have to check more than one value to see if the input line is
  2668.     valid.  You do this by using "clustered ACCEPTs", which are several ACCEPT
  2669.     commands in a row.
  2670.     
  2671.     Briefly stated, if you have several ACCEPTs in a row ("clustered"), they
  2672.     are all processed to determine if the input line is acceptable or not.  If
  2673.     even one ACCEPT matches up, the line is accepted.  To express this in more
  2674.     detail...
  2675.     
  2676.     When the comparison is true, the line is accepted, and processing of the
  2677.     POM file continues for that input line, even if the immediately following
  2678.     ACCEPTs do NOT produce a match.  After all, we've already got a match!
  2679.     
  2680.     If value1 does NOT contain value2, Parse-O-Matic looks at the next command
  2681.     in the POM file.  If it is not another ACCEPT, the input line is ignored.
  2682.     If it is another ACCEPT, maybe it will product a match -- so Parse-O-Matic
  2683.     moves to that command.
  2684.     
  2685.     The following POM file uses clustered ACCEPTs to accept any line that
  2686.     contains the name "FRED" or "MARY" between columns 5 and 8, or contains the
  2687.     word "MEMBER" between columns 20 and 25.
  2688.     
  2689.     SET    NAME = $FLINE[5 8]         <-- Set the variable
  2690.     ACCEPT NAME = "FRED"              <-- Look for FRED
  2691.     ACCEPT NAME = "MARY"              <-- Look for MARY
  2692.     ACCEPT $FLINE[20 25] = "MEMBER"   <-- Look for MEMBER
  2693.     OUTEND "X" = "X" |{$FLINE}        <-- Output the line if we get this far
  2694.     
  2695.     The following example will NOT work, however:
  2696.     
  2697.     ACCEPT $FLINE[20 25] = "MEMBER"
  2698.     SET    NAME = $FLINE[5 8]
  2699.     ACCEPT NAME = "FRED"
  2700.     ACCEPT NAME = "MARY"
  2701.     OUTEND "X" = "X" |{$FLINE}
  2702.     
  2703.     It will not work because the ACCEPTs are not clustered; if the first ACCEPT
  2704.     fails, the input line is rejected as soon as the SET command is
  2705.     encountered.  The next two ACCEPTs are not reached in such case.
  2706.     
  2707.     
  2708.     
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.                                                                              40
  2718.     ============================================================================
  2719.                                FLOW CONTROL COMMANDS
  2720.     ============================================================================
  2721.     
  2722.                                  -----------------
  2723.                                  The BEGIN Command
  2724.                                  -----------------
  2725.     
  2726.     FORMAT:        The basic format for the BEGIN command is as follows:
  2727.     
  2728.                    BEGIN value1 [comparator] value2
  2729.                    :
  2730.                    Dependant code
  2731.                    :
  2732.                    END
  2733.     
  2734.     PURPOSE:       If the comparison is true (e.g. value1 equals value2), then
  2735.                    the dependant code (the POM lines between the BEGIN and the
  2736.                    END) are executed.  If the comparison is false, then the
  2737.                    dependant code is skipped.
  2738.     
  2739.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2740.                    In the following explanation, we will demonstrate the
  2741.                    command using only the "literally identical" ("=")
  2742.                    comparator.
  2743.     
  2744.     SEE ALSO:      "The Else Command" and "The Again Command"
  2745.     
  2746.     It is traditional in programming to indent code that appears in blocks
  2747.     such as Parse-O-Matic's BEGIN/END technique.  This makes the logic of
  2748.     the POM file easier for us to understand.  For example:
  2749.     
  2750.     BEGIN datatype = "Employee"
  2751.       SET phone    = $FLINE[ 1 10]
  2752.       SET address  = $FLINE[12 31]
  2753.     END
  2754.     
  2755.     BEGIN/END blocks can be nested.  That is to say, you can have BEGIN/END
  2756.     blocks inside other BEGIN/END blocks.  Here is an example, with arrows
  2757.     to indicate the levels of each BEGIN/END block...
  2758.     
  2759.     BEGIN datatype = "Employee"      <---------------------
  2760.       SET phone    = $FLINE[ 1 10]                        |
  2761.       SET address  = $FLINE[12 31]                        |
  2762.       SET areacode = phone[1 3]                           | First
  2763.       BEGIN areacode = "514"         <------- Second      | Level
  2764.         SET local = "Y"                     | Level       | Block
  2765.         SET tax   = "Y"              <------- Block       |
  2766.       END                                                 |
  2767.     END                              <---------------------
  2768.     
  2769.     
  2770.  
  2771.  
  2772.                                                                              41
  2773.     In this case, the "inner" block (starting with BEGIN areacode = "514") is
  2774.     reached only if the "outer" block (BEGIN datatype = "Employee") is true.
  2775.     If the outer block is false, the inner block is ignored.
  2776.     
  2777.     A nested BEGIN/END block must always be completely inside the outer block.
  2778.     Study the following (incorrect) example:
  2779.     
  2780.     BEGIN datatype = "Employee"             <----
  2781.       SET phone    = $FLINE[ 1 10]              |  First
  2782.       SET areacode = phone[1 3]                 |  Level
  2783.       BEGIN areacode = "514"         <---       |  Block?
  2784.         SET local = "Y"                 |       |
  2785.     END                                 |   <----
  2786.       SET tax = "Y"                     |
  2787.       END                            <---  Second Level Block?
  2788.     
  2789.     Parse-O-Matic does not pay attention to the indenting -- it is only a
  2790.     tradition we use to make the file easier to read.  The code will be
  2791.     understood this way:
  2792.     
  2793.     BEGIN datatype = "Employee"      <---------------------
  2794.       SET phone    = $FLINE[ 1 10]                        | First
  2795.       SET areacode = phone[1 3]                           | Level
  2796.       BEGIN areacode = "514"         <--- Second          | Block
  2797.         SET local = "Y"                 | Level           |
  2798.       END                            <--- Block           |
  2799.       SET tax = "Y"                                       |
  2800.     END                              <---------------------
  2801.     
  2802.     You can nest BEGIN/END blocks up to 25 deep -- although it is unlikely you
  2803.     will ever need that much nesting.  Here is an example of code that uses
  2804.     nesting up to three deep:
  2805.     
  2806.     BEGIN datatype = "Dog"           <----------------------------------
  2807.       SET breed = $FLINE[1 10]                                         | First
  2808.       BEGIN breed = "Collie"         <-----------------------          | Level
  2809.         SET noise = "Woof"                                  | Second   | Block
  2810.         BEGIN name = "Spot"          <------ Third          | Level    |
  2811.           SET attitude = "Friendly"        | Level          | Block    |
  2812.         END                          <------ Block          |          |
  2813.       END                            <-----------------------          |
  2814.       BEGIN breed = "Other"          <----------------------- Another  |
  2815.         SET noise = "Arf"                                   | Second   |
  2816.         SET attitude = "Unknown"                            | Level    |
  2817.       END                            <----------------------- Block    |
  2818.     END                              <----------------------------------
  2819.     
  2820.     Once again, the indentation is for clarity only and does not affect the
  2821.     way the POM file runs.  However, you will find that it makes your POM
  2822.     file much easier to understand.
  2823.     
  2824.     
  2825.  
  2826.  
  2827.                                                                              42
  2828.                                   ----------------
  2829.                                   The CALL Command
  2830.                                   ----------------
  2831.     
  2832.     FORMAT:        CALL value1
  2833.     
  2834.     PURPOSE:       Executes a subroutine (see "The Code Command")
  2835.     
  2836.     PARAMETERS:    value1 is the name of the subroutine
  2837.     
  2838.     The basic concepts of the CALL and CODE commands are discussed in the
  2839.     section entitled "The Code Command".
  2840.     
  2841.     --------------
  2842.     Variable CALLs
  2843.     --------------
  2844.     
  2845.     value1 will usually be a literal (e.g. CALL "Output Field"). However, it can
  2846.     also be a variable.  For example:
  2847.     
  2848.     IF       $FLINE[1] = "0" THEN routine = "Handle Type 0" ELSE "Handle Type 1"
  2849.     CALL     routine
  2850.     
  2851.     This calls the subroutine "Handle Type 0" if the first character of $FLINE
  2852.     is "0".  Otherwise, it calls the subroutine "Handle Type 1".  An alternative
  2853.     to this approach is:
  2854.     
  2855.     
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.                                                                              43
  2883.     BEGIN    $FLINE[1] = "0"
  2884.       (code to handle Type 1 records)
  2885.     ELSE
  2886.       (code to handle other types of records)
  2887.     END
  2888.     
  2889.     Both methods accomplish the same thing, so the one you choose is largely a
  2890.     matter of personal preference.  In general, however, you should use CALL and
  2891.     CODE only when the same code is required in several different places in the
  2892.     POM file.  There are some exceptions however, as described in the next
  2893.     section...
  2894.     
  2895.     -----------------------------
  2896.     Making Your Technique Obvious
  2897.     -----------------------------
  2898.     
  2899.     Consider this example:
  2900.     
  2901.     APPEND   routine "Type" $FLINE[1]
  2902.     CALL     routine
  2903.     
  2904.     You can use this method to call subroutines named "Type0", "Type1", "Type2"
  2905.     and so on, according to the first character of $FLINE.  This can make your
  2906.     POM file a lot easier to understand.
  2907.     
  2908.     Additionally, you may sometimes want to break up large parsing jobs into
  2909.     distinct pieces.  Thus, the main part of your POM file might read as
  2910.     follows:
  2911.     
  2912.     CALL     "Break Up Fields"
  2913.     CALL     "Clean Up Data"
  2914.     CALL     "Send to Output"
  2915.     
  2916.     If each of these steps is quite long and involved, your POM file may be
  2917.     easier to read and understand by using CALL, as shown, to portray the basic
  2918.     steps.
  2919.     
  2920.     ------------------------------
  2921.     Avoiding Unknown Code Sections
  2922.     ------------------------------
  2923.     
  2924.     If you attempt to call a subroutine that does not exist, Parse-O-Matic will
  2925.     terminate with an error message, saying it can not find the CODE section.
  2926.     It is a good idea to check for this possibility, as in this example:
  2927.     
  2928.     LOG      "012345" ~ $FLINE[1] "Unknown record type: " $FLINE[1]
  2929.     HALT     "012345" ~ $FLINE[1] "Unknown record type -- see processing log"
  2930.     APPEND   routine "Type" $FLINE[1]
  2931.     CALL     routine
  2932.     
  2933.     This will provide a more meaningful error message if the first character
  2934.     of $FLINE is not one that you expected (zero through five, in the example
  2935.     given above).
  2936.  
  2937.                                                                              44
  2938.                                   ----------------
  2939.                                   The CODE Command
  2940.                                   ----------------
  2941.     
  2942.     FORMAT:        The format of a subroutine is as follows:
  2943.     
  2944.                    CODE value1
  2945.                    :
  2946.                    Code run when this subroutine is invoked by the CALL command
  2947.                    :
  2948.                    END
  2949.     
  2950.     PURPOSE:       Defines a subroutine
  2951.     
  2952.     PARAMETERS:    value1 is the name of the subroutine
  2953.     
  2954.     NOTES:         value1 can be up to 255 characters long and may contain any
  2955.                    characters (including spaces).  Case is not important, so
  2956.                    "Read New Data" is treated the same as "READ NEW DATA".
  2957.                    Leading and trailing spaces and tabs are ignored.
  2958.     
  2959.     Subroutines are useful when a POM file has to perform the same series of
  2960.     commands in several different circumstances.  Consider this POM file:
  2961.     
  2962.     SET      field = $FLINE[10 20]  <-- Get a field
  2963.     CALL     "Output Date Field"    <-- Run a subroutine
  2964.     SET      field = $FLINE[30 40]  <-- Get a field
  2965.     CALL     "Output Date Field"    <-- Run a subroutine
  2966.     CODE     "Output Date Field"    <-- Start of subroutine     <-+
  2967.       CHANGE   field " " "/"        <-- Correct date format       |
  2968.       CHANGE   field "\" "/"        <-- Correct date format       |
  2969.       CHANGE   field "-" "/"        <-- Correct date format       | Subroutine
  2970.       CVTCASE  field field          <-- Convert to uppercase      |
  2971.       OUTEND   |{field}             <-- Output the field          |
  2972.     END                             <-- End of subroutine       <-+
  2973.     
  2974.     In this example, the subroutine (named "Output Date Field") tidies up the
  2975.     data before sending it to the output file.  For example, if the date field
  2976.     is "10 31 98", it is converted to "10/31/98".
  2977.     
  2978.     As you can see, subroutines can reduce the number of lines in a POM file.
  2979.     Also, if you give your subroutines meaningful names, your POM file will be
  2980.     much easier to understand.
  2981.     
  2982.     Subroutines also make it easier to update a POM file.  For example, if you
  2983.     noticed that the date field is sometimes delimited with the "plus" symbol,
  2984.     you could simply add the line  CHANGE field "+" "/"  to the "Output Date
  2985.     Field" subroutine.  In other words, you would add a single line of code
  2986.     instead of several lines.
  2987.     
  2988.     Subroutines are ignored by Parse-O-Matic unless they are explicitly invoked
  2989.     by a CALL command.
  2990.     
  2991.  
  2992.                                                                              45
  2993.     --------------------------
  2994.     Performance Considerations
  2995.     --------------------------
  2996.     
  2997.     If you have a POM file with a lot of subroutines, you can improve its
  2998.     performance slightly by moving all the CODE sections to the end of the file,
  2999.     and placing a DONE command in front of them.  This saves Parse-O-Matic the
  3000.     trouble of reading through them each time it processes a line.
  3001.     
  3002.     -----------------------
  3003.     Nested Subroutine Calls
  3004.     -----------------------
  3005.     
  3006.     You can call a subroutine from within a subroutine.  For example:
  3007.     
  3008.     CODE     "Clean Up Date Field"
  3009.       CHANGE   field " " "/"
  3010.       CHANGE   field "\" "/"
  3011.       CHANGE   field "-" "/"
  3012.       CVTCASE  field field
  3013.     END
  3014.     CODE     "Output Date Field"
  3015.       CALL     "Clean Up Date Field"
  3016.       OUTEND   |{field}
  3017.     END
  3018.     
  3019.     The second subroutine ("Output Date Field") calls the first subroutine
  3020.     ("Clean Up Date Field").  This feature is useful if several subroutines
  3021.     require the same processing.
  3022.     
  3023.     You must be careful not to have circular references (a subroutine that calls
  3024.     a subroutine which in turn calls the first subroutine).  This will call
  3025.     Parse-O-Matic to fail.
  3026.     
  3027.     Subroutine calls can be nested up to 25 deep.  That is to say, a subroutine
  3028.     can call a second subroutine, which can call a third subroutine, and so on,
  3029.     all the way up the 24th subroutine calling the 25th subroutine.  It is,
  3030.     however, unlikely that you will ever nest subroutines more than two or three
  3031.     deep.
  3032.     
  3033.     ----------------------
  3034.     Variable Code Sections
  3035.     ----------------------
  3036.     
  3037.     You may be wondering if you can place a variable in the value1 position of
  3038.     the CODE command, just as you can have a variable CALL command.  While it is
  3039.     possible to do so (i.e. Parse-O-Matic will not fail), we do not officially
  3040.     support this usage, as we see no reason for it.  If you do find a reason for
  3041.     it, make sure that the variable is first converted to uppercase.
  3042.     
  3043.     
  3044.  
  3045.  
  3046.  
  3047.                                                                              46
  3048.     ---------------------------------
  3049.     A Note to Experienced Programmers
  3050.     ---------------------------------
  3051.     
  3052.     Experienced programmers of other languages (e.g. Pascal, C, Basic, etc.) may
  3053.     wonder if there is a way to pass one or more variables to a subroutine.
  3054.     Parse-O-Matic does not currently support traditional features such as
  3055.     functions, variable-passing or local variables. These features (and other
  3056.     niceties such as code libraries) may be added in a later release.
  3057.     Parse-O-Matic's design is guided primarily by customer demand.
  3058.     
  3059.                                   ----------------
  3060.                                   The ELSE Command
  3061.                                   ----------------
  3062.     
  3063.     FORMAT:        The format of a BEGIN/ELSE/END block is as follows:
  3064.     
  3065.                    BEGIN value1 [comparator] value2
  3066.                    :
  3067.                    Code that is run if the comparison is true
  3068.                    :
  3069.                    ELSE
  3070.                    :
  3071.                    Code that is run if the comparison is false
  3072.                    :
  3073.                    END
  3074.     
  3075.     PURPOSE:       The ELSE command tells Parse-O-Matic to execute the
  3076.                    following block of code (up until the END command) if the
  3077.                    corresponding BEGIN comparison is NOT true.
  3078.     
  3079.     NOTES:         The ELSE command is not the same as the ELSE used to pad the
  3080.                    IF statement (e.g. IF xyz = "3" THEN x = "Y" ELSE "N").  In
  3081.                    the IF command, ELSE makes the statement more clear, but it
  3082.                    can be omitted (e.g. IF $FLINE[1] "3" x "Y" "N").
  3083.     
  3084.     Here is an example of a BEGIN/ELSE/END block:
  3085.     
  3086.     BEGIN $FLINE[1 10] = "JOHN SMITH"
  3087.       SET x = "This is John"
  3088.     ELSE
  3089.       SET x = "This is not John"
  3090.     END
  3091.     
  3092.     If you are using several levels of nesting, it is a good idea to indent
  3093.     your code to show the relationship of the BEGIN, ELSE and END statements:
  3094.     
  3095.     
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.                                                                              47
  3103.     BEGIN datatype = "Dog"           <----------------------------------
  3104.       SET breed = $FLINE[1 10]                                         | First
  3105.       BEGIN breed = "Collie"         <-----------------------          | Level
  3106.         SET noise = "Woof"                                  | Second   | Block
  3107.         BEGIN name = "Spot"          <------ Third          | Level    |
  3108.           SET attitude = "Friendly"        | Level          | Block    |
  3109.         END                          <------ Block          |          |
  3110.       ELSE                                                  |          |
  3111.         SET noise = "Arf"                                   |          |
  3112.         SET attitude = "Unknown"                            |          |
  3113.       END                            <-----------------------          |
  3114.     END                              <----------------------------------
  3115.     
  3116.     The ELSE is at "Level 2".  This is because there are three BEGINs ahead of
  3117.     it, but only one END (3 - 1 = 2).
  3118.     
  3119.                                   ---------------
  3120.                                   The END Command
  3121.                                   ---------------
  3122.     
  3123.     FORMAT:        END
  3124.     
  3125.     PURPOSE:       Marks the end of a BEGIN, PROLOGUE or EPILOGUE code block.
  3126.     
  3127.     The END command marks the end of a "code block".  A code block is a series
  3128.     of lines in a POM file that may be run if the conditions are right.
  3129.     
  3130.     For a more detailed discussion of the END command, see the following
  3131.     sections:
  3132.     
  3133.     - "The Begin Command"
  3134.     
  3135.     - "The Prologue Command"
  3136.     
  3137.     - "The Epilogue Command"
  3138.     
  3139.     
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.                                                                              48
  3158.                                  -----------------
  3159.                                  The AGAIN Command
  3160.                                  -----------------
  3161.     
  3162.     FORMAT #1:     BEGIN [value1 [comparator] value2]
  3163.                    :
  3164.                    Code executed if the BEGIN comparison is true or omitted
  3165.                    :
  3166.                    AGAIN [value1 [comparator] value2]
  3167.     
  3168.     FORMAT #2:     BEGIN value1 [comparator] value2
  3169.                    :
  3170.                    Code executed if the BEGIN comparison is true
  3171.                    :
  3172.                    ELSE
  3173.                    :
  3174.                    Code executed if the BEGIN comparison is false
  3175.                    :
  3176.                    AGAIN [value1 [comparator] value2]
  3177.     
  3178.     PURPOSE:       Controls the repetition of a BEGIN block.
  3179.     
  3180.     NOTES:         For an explanation of comparators, see "Using Comparators".
  3181.     
  3182.     SEE ALSO:      "The ReadNext Command", "The Begin Command", "The Else
  3183.                    Command" and "Uninitialized and Persistent Variables"
  3184.     
  3185.     DEFAULTS:      If the comparison part of the AGAIN command is omitted:
  3186.                    - AGAIN repeats if the BEGIN comparison was true or omitted
  3187.                    - AGAIN does not repeat if the BEGIN comparison was false
  3188.     
  3189.     ADVISORY:      If you are familiar with other computer languages, you may
  3190.                    be tempted to use AGAIN to create loops when none are
  3191.                    required.  Remember that a POM file is repeated (i.e.
  3192.                    looped) each time a record or line is read from the input
  3193.                    file.  The AGAIN command is most appropriate when you have
  3194.                    input records with a variable number of items.
  3195.     
  3196.     The AGAIN command allows you to implement "loops".  A loop is a section of
  3197.     code that can be repeated one or more times.
  3198.     
  3199.     AGAIN returns to the corresponding BEGIN if the comparison is true, or if
  3200.     it is omitted.  Since the BEGIN can also have a comparison, and can be used
  3201.     with the ELSE command, this allows many variations:
  3202.     
  3203.     
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.                                                                              49
  3213.     COMMAND ARRANGEMENT             EFFECT
  3214.     ------------------------------  -----------------------------------------
  3215.     BEGIN               AGAIN       Loops forever
  3216.     BEGIN comp          AGAIN       Loops until the BEGIN comparison is false
  3217.     BEGIN               AGAIN comp  Loops until the AGAIN comparison is false
  3218.     BEGIN comp          AGAIN comp  Loops until either comparison is false
  3219.     BEGIN comp   ELSE   AGAIN comp  Loops until either comparison is false
  3220.     BEGIN comp   ELSE   AGAIN       Loops until the BEGIN comparison is false
  3221.     
  3222.     In the last two examples, the ELSE code is run when the BEGIN comparison is
  3223.     false, then processing continues on the POM line after the AGAIN command.
  3224.     When a BEGIN comparison is false, the comparison (if any) of the AGAIN
  3225.     command is not evaluated.
  3226.     
  3227.     To put it another way:  the AGAIN comparison is considered only if the
  3228.     BEGIN comparison is true or omitted.
  3229.     
  3230.     ------------------------------------
  3231.     Using AGAIN for Variable-Length Data
  3232.     ------------------------------------
  3233.     
  3234.     Let us say you have a text file that contains the names of people belonging
  3235.     to various clubs.  The file lists the name of the club, then the number of
  3236.     people in each club, and then the names:
  3237.     
  3238.     Chess Club
  3239.     3
  3240.     John Smith
  3241.     Mary Jones
  3242.     Fred Williams
  3243.     Hopscotch Club
  3244.     0
  3245.     Tennis Club
  3246.     2
  3247.     Jack Martin
  3248.     Debbie Harris
  3249.     
  3250.     
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.                                                                              50
  3268.     You could process this input file with the following POM file:
  3269.     
  3270.     PAD      $FLINE "R" " " "17"      <-- Pad the club name out with spaces
  3271.     OUT      |{$FLINE}                <-- Send the club name to the output file
  3272.     READNEXT                          <-- Get the number of members
  3273.     SET      members  = $FLINE        <-- Remember this number
  3274.     BEGIN    members  = "0"           <-- Check if we have any members
  3275.       OUT      |(None)                <-- Report if we have no members
  3276.     ELSE                              <-- If we have members, do the next part
  3277.       SET      count    = "0"         <-- Initialize a counter
  3278.       BEGIN                           <-- Start the loop
  3279.         READNEXT                      <-- Get the person's name
  3280.         SET    count = count+         <-- Count this person
  3281.         OUT    |{$FLINE}              <-- Send the name to the file
  3282.         OUT    count #< members |/    <-- Add a separator if not the last name
  3283.       AGAIN    count #< members       <-- Go back if we have more members
  3284.     END                               <-- Corresponds to the first BEGIN
  3285.     OUTEND  |                         <-- Start a new line after each club
  3286.     
  3287.     This POM file would generate the following output:
  3288.     
  3289.     Chess Club       John Smith/Mary Jones/Fred Williams
  3290.     Hopscotch Club   (None)
  3291.     Tennis Club      Jack Martin/Debbie Harris
  3292.     
  3293.     ------------------------------
  3294.     Pointless Command Combinations
  3295.     ------------------------------
  3296.     
  3297.     Some combinations of BEGIN, ELSE and AGAIN are pointless.  The following
  3298.     command arrangements contain code that is never run:
  3299.     
  3300.     COMMAND ARRANGEMENT             NOTE
  3301.     ------------------------------  ------------------------------------------
  3302.     BEGIN        ELSE   AGAIN comp  The ELSE portion is never executed
  3303.     BEGIN        ELSE   AGAIN       Loops forever; the ELSE portion never runs
  3304.     
  3305.     
  3306.  
  3307.  
  3308.  
  3309.  
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315.  
  3316.  
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322.                                                                              51
  3323.     --------
  3324.     Examples
  3325.     --------
  3326.     
  3327.     Either of these two POM files will read a text file and ignore any lines
  3328.     that contain the words "COW":
  3329.     
  3330.     Using the AGAIN Command       Using the IGNORE Command
  3331.     -----------------------       ------------------------
  3332.     BEGIN $FLINE ^ "COW"          IGNORE $FLINE ^ "COW"
  3333.       READNEXT                    OUTEND |{$FLINE}
  3334.     AGAIN
  3335.     OUTEND |{$FLINE}
  3336.     
  3337.     The shorter POM file is more efficient, but the results would be the
  3338.     roughly the same for both.  Remember that a POM file is processed each
  3339.     time Parse-O-Matic reads an input record (or line), so the second version
  3340.     is, in effect, looping as many times as there are records in the file.
  3341.     
  3342.     The following POM file will read one line from a file, then send the string
  3343.     [6]123[7]123[6]123[7]123 to the output file:
  3344.     
  3345.     SET      z = "0"
  3346.     BEGIN                      <-----------------------------
  3347.       SET      y = "5"                                      | First
  3348.       BEGIN    y <> "7"        <------------------          | Level
  3349.         SET      x = "0"                         | Second   | (Outermost)
  3350.         SET      y = y+                          | Level    | Loop
  3351.         APPEND   s s "[" y "]"                   | Loop     |
  3352.         BEGIN    x <> "3"      <--------         |          |
  3353.           SET      x = x+              | Third   |          |
  3354.           APPEND   s s x               | Level   |          |
  3355.         AGAIN                  <--------         |          |
  3356.       AGAIN                    <------------------          |
  3357.       SET     z = z+                                        |
  3358.     AGAIN   z <> "2"           <-----------------------------
  3359.     OUTEND  |{s}
  3360.     NEXTFILE
  3361.     
  3362.     The third level (innermost) loop ... generates 123
  3363.     The second level (middle) loop ..... generates [6]123[7]123
  3364.     The first level (outermost) loop ... generates [6]123[7]123[6]123[7]123
  3365.     
  3366.     
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.  
  3376.  
  3377.                                                                              52
  3378.     The following POM file will read one line from a file, then send the
  3379.     string "XXXY" to the output file:
  3380.     
  3381.     SET      z = "0"           <-- Initialize a counter
  3382.     SET      s = ""            <-- Initialize the string we will output
  3383.     BEGIN    z < "3"           <-- Check if the counter has reached "3"
  3384.       SET      z = z+          <-- Add one to the counter
  3385.       APPEND   s s "X"         <-- Add an "X" to the end of the output string
  3386.     ELSE                       /__ The ELSE section is run when
  3387.       APPEND   s s "Y"         \   the BEGIN comparison is false
  3388.     AGAIN                      <-- Go back to the BEGIN
  3389.     OUTEND   |{s}              <-- Continue here after the ELSE portion
  3390.     NEXTFILE                   <-- Stop reading the input file
  3391.     
  3392.                                   ----------------
  3393.                                   The DONE Command
  3394.                                   ----------------
  3395.     
  3396.     FORMAT:        DONE [value1 [comparator] value2]
  3397.     
  3398.     PURPOSE:       The DONE command will discontinue processing the POM file
  3399.                    and proceed to the next input line, whereupon the POM file
  3400.                    will restart at the top.
  3401.     
  3402.     NOTES:         For an explanation of comparators, see "Using Comparators".
  3403.                    In the following explanation, we will demonstrate the
  3404.                    command using only the "literally identical" ("=")
  3405.                    comparator.
  3406.     
  3407.     ALTERNATIVES:  The NEXTFILE, IGNORE and ACCEPT commands
  3408.     
  3409.     The DONE command is most useful when you have a long series of BEGIN/END
  3410.     blocks which make a related comparison.  For example:
  3411.     
  3412.     
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.                                                                              53
  3433.     SET   salesrep = $FLINE[11 50]
  3434.     SET   region   = $FLINE[ 1  2]
  3435.     BEGIN region = "US"
  3436.       OUTEND |Sales representative for U.S.A.: {salesrep}
  3437.       DONE
  3438.     END
  3439.     BEGIN region = "CN"
  3440.       OUTEND |Sales representative for Canada: {salesrep}
  3441.       DONE
  3442.     END
  3443.     BEGIN region = "EU"
  3444.       OUTEND |Sales representative for Europe: {salesrep}
  3445.       DONE
  3446.     END
  3447.     :
  3448.     etc.
  3449.     
  3450.     As you can see, if one of the BEGIN comparisons is true, all of the
  3451.     following ones will inevitably be false.  Rather than processing all the
  3452.     others, you can use the DONE command to bail out and get ready for the
  3453.     next input line.
  3454.     
  3455.     The DONE command provides two benefits:
  3456.     
  3457.     - It can speed up processing slightly
  3458.     - It makes full traces easier to understand
  3459.     
  3460.     For an explanation of traces, see the section entitled "Tracing".
  3461.     
  3462.     Unless you use a comparison (explained later), the DONE command is useful
  3463.     only inside BEGIN/ELSE/END blocks.  If you write a POM file like this:
  3464.     
  3465.     SET custnum  = $FLINE[ 1 10]
  3466.     SET custname = $FLINE[11 50]
  3467.     DONE
  3468.     OUTEND |{custname} {custnum}
  3469.     
  3470.     then the OUTEND statement will NEVER be reached.
  3471.     
  3472.     Here is how you specify a comparison for the DONE command:
  3473.     
  3474.     DONE $FLINE = "End of Data"
  3475.     
  3476.     This discontinues the POM file, and proceeds to the next input line, if the
  3477.     current input line ($FLINE) is "End of Data".
  3478.     
  3479.     
  3480.  
  3481.  
  3482.  
  3483.  
  3484.  
  3485.  
  3486.  
  3487.                                                                              54
  3488.                                 --------------------
  3489.                                 The NEXTFILE Command
  3490.                                 --------------------
  3491.     
  3492.     FORMAT:        NEXTFILE [value [comparator] value]
  3493.     
  3494.     PURPOSE:       NEXTFILE discontinues processing the current input file and
  3495.                    proceeds to the next one, restarting the POM file from the
  3496.                    top.
  3497.     
  3498.     NOTES:         For an explanation of comparators, see "Using Comparators".
  3499.                    In the following explanation, we will demonstrate the
  3500.                    command using only the "literally identical" ("=")
  3501.                    comparator.
  3502.     
  3503.     ALTERNATIVES:  The HALT command
  3504.     
  3505.     The NEXTFILE command is useful when you process multiple input files (see
  3506.     "POM and Wildcards").  Here is an example, which we will call TEST.POM:
  3507.     
  3508.     BEGIN $FLINE = "End of Data"
  3509.       OUTEND |{numlines} lines of data printed
  3510.       SET    numlines = ""
  3511.       NEXTFILE
  3512.     END
  3513.     SET    numlines = numlines+
  3514.     OUTEND |{$FLINE}
  3515.     
  3516.     Let's say you have three text files: DATA1.XYZ, DATA2.XYZ and DATA3.XYZ.
  3517.     The last line of each file says "End of Data".  You could copy all three
  3518.     files to the file OUTPUT.TXT with this command:
  3519.     
  3520.     POM TEST.POM DATA?.XYZ OUTPUT.TXT
  3521.     
  3522.     This would copy the data from each file, but when it gets to the line
  3523.     reading "End of Data", it records the number of lines of data that were
  3524.     printed.  Any lines after the "End of Data" line are skipped, because of
  3525.     the NEXTFILE command.
  3526.     
  3527.     The NEXTFILE command can specify a comparison.  Here is an example:
  3528.     
  3529.     NEXTFILE $FLINE = "End of Data"
  3530.     OUTEND |{$FLINE}
  3531.     
  3532.     Assuming the same input files (DATA1.XYZ etc.), and using the same POM
  3533.     command as last time, this POM file would simply copy up to (but not
  3534.     including" the line that reads "End of Data" in each input file.
  3535.     
  3536.     
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.                                                                              55
  3543.                                   ----------------
  3544.                                   The HALT Command
  3545.                                   ----------------
  3546.     
  3547.     FORMAT:        HALT value1 comparison value2 value3 [value4]
  3548.     
  3549.     PURPOSE:       The HALT command will terminate Parse-O-Matic processing if
  3550.                    the comparison is true.
  3551.     
  3552.     PARAMETERS:    value1 is any value
  3553.                    value2 is any value
  3554.                    value3 is the message to be displayed
  3555.                    value4 is the optional error level (between 100 to 199)
  3556.     
  3557.     NUMERICS:      Tabs, spaces and commas are stripped from value4
  3558.     
  3559.     ALTERNATIVES:  The NEXTFILE and SETERROR commands
  3560.     
  3561.     SEE ALSO:      "The MsgWait Command"
  3562.     
  3563.     Here is an example of the HALT command:
  3564.     
  3565.     HALT sales = "0" "Zero sales!"
  3566.     
  3567.     If the variable named sales is "0", Parse-O-Matic will display an error
  3568.     box reading "Zero sales!" and terminate after you have pressed a key.  A
  3569.     copy of the message is also placed in the processing log POMLOG.TXT (see
  3570.     "Logging").
  3571.     
  3572.     When a HALT condition occurs, Parse-O-Matic terminates with a DOS error
  3573.     level of 100.  You can specify a different value, using value4.  This is
  3574.     useful if you are calling Parse-O-Matic from a batch file or application
  3575.     program and want to handle different errors in different ways.
  3576.     
  3577.     You can set value4 to any number between 100 and 199.  Consider these
  3578.     examples:
  3579.     
  3580.     HALT sales    = "0" "Zero sales"     "150"
  3581.     HALT sales[1] = "-" "Negative sales" "160"
  3582.     
  3583.     This terminates Parse-O-Matic with an error level of 150 if sales are zero.
  3584.     If the first character of sales is a minus sign, Parse-O-Matic terminates
  3585.     with an error level of 160.
  3586.     
  3587.     When coding batch files, remember that the IF ERRORLEVEL command is
  3588.     considered "True" if the error is the specified value or higher.  This
  3589.     means you should always test the higher value first.  See your operating
  3590.     system manual for details.
  3591.     
  3592.     
  3593.  
  3594.  
  3595.  
  3596.  
  3597.                                                                              56
  3598.                                 --------------------
  3599.                                 The SETERROR Command
  3600.                                 --------------------
  3601.     
  3602.     FORMAT:        SETERROR [value1 comparison value2] value3
  3603.     
  3604.     PURPOSE:       The SETERROR command will set the program return code if the
  3605.                    comparison is true (or if it is omitted).
  3606.     
  3607.     PARAMETERS:    value1 is any value
  3608.                    value2 is any value
  3609.                    value3 is the program return code value (between 100 to 199)
  3610.     
  3611.     NUMERICS:      Tabs, spaces and commas are stripped from value3
  3612.     
  3613.     ALTERNATIVES:  The HALT command
  3614.     
  3615.     The SETERROR command sets the program return code, which you can check when
  3616.     Parse-O-Matic has completed processing.  This lets you pass information back
  3617.     to the batch file or program that called Parse-O-Matic.
  3618.     
  3619.     When coding batch files, remember that the IF ERRORLEVEL command is
  3620.     considered "True" if the error is the specified value or higher.  This
  3621.     means you should always test the higher value first.  See your operating
  3622.     system manual for details.
  3623.     
  3624.     Here is a sample POM file, which we will name ERRTEST.POM:
  3625.     
  3626.     SET      custname = $FLINE[ 1 20]
  3627.     SET      owed     = $FLINE[25 30]
  3628.     SET      status   = $FLINE[62 68]
  3629.     SETERROR status   = "OVERDUE" "100"
  3630.     OUTEND   |{custname} {owed} {status}
  3631.     
  3632.     Here is a sample batch file that uses ERRTEST.POM:
  3633.     
  3634.     @ECHO OFF
  3635.     POM ERRTEST.POM INPUT.TXT OUTPUT.TXT
  3636.     IF ERRORLEVEL 200 GOTO PERR
  3637.     IF ERRORLEVEL 100 GOTO OVERDUE
  3638.     GOTO QUIT
  3639.     :PERR
  3640.     ECHO A syntax or processing error was detected by Parse-O-Matic
  3641.     GOTO QUIT
  3642.     :OVERDUE
  3643.     ECHO We have at least one overdue account
  3644.     :QUIT
  3645.     
  3646.     
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.                                                                              57
  3653.                                 --------------------
  3654.                                 The PROLOGUE Command
  3655.                                 --------------------
  3656.     
  3657.     FORMAT:        The format for PROLOGUE (used with the END command) is:
  3658.     
  3659.                    PROLOGUE
  3660.                    :
  3661.                    Dependant code
  3662.                    :
  3663.                    END
  3664.     
  3665.     PURPOSE:       PROLOGUE defines dependant code which is run before the
  3666.                    first line of the input file is read.
  3667.     
  3668.     SEE ALSO:      "The Epilogue Command"
  3669.     
  3670.     PROLOGUE can be used to set up some variables, or set up a heading --
  3671.     anything you only want to do once per input file, at the very start.
  3672.     
  3673.     Here is an example of the PROLOGUE command:
  3674.     
  3675.     PROLOGUE
  3676.       SET both  = "B"
  3677.       SET space = " "
  3678.     END
  3679.     SET    firstname = $FLINE[ 1 10]
  3680.     SET    lastname  = $FLINE[15 25]
  3681.     TRIM   firstname both space
  3682.     TRIM   lastname  both space
  3683.     OUTEND |{firstname} {lastname}
  3684.     
  3685.     When the input file is first opened, the PROLOGUE section sets the
  3686.     variables "both" and "space".  Once they're set, you don't have to change
  3687.     them (since you are just using them to make the code easier to read).  Thus,
  3688.     it makes sense to set them only at the beginning of processing and not
  3689.     bother setting them each time the POM file is executed (i.e. each time an
  3690.     input line is read).
  3691.     
  3692.     If you are working with multiple files (see "POM and Wildcards"), the
  3693.     PROLOGUE is run for each input file.  If you want to run some code for
  3694.     the first file only, you can set a "flag", as in this example:
  3695.     
  3696.     
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.                                                                              58
  3708.     BEGIN firstfile = ""
  3709.       SET firstfile = "N"
  3710.       OUTEND |First file only
  3711.     ELSE
  3712.       OUTEND |Subsequent files
  3713.     END
  3714.     NEXTFILE
  3715.     
  3716.     If you run this POM file on several files at once, using wildcards, the
  3717.     first line of the output file will contain the words "First file only",
  3718.     since the variable "firstfile" has not yet been assigned a value.  On
  3719.     subsequent files, the variable will have the value "N", so the following
  3720.     lines of the output file will read "Subsequent files".
  3721.     
  3722.                                 --------------------
  3723.                                 The EPILOGUE Command
  3724.                                 --------------------
  3725.     
  3726.     FORMAT:        The format for EPILOGUE (used with the END command) is:
  3727.     
  3728.                    EPILOGUE
  3729.                    :
  3730.                    Dependant code
  3731.                    :
  3732.                    END
  3733.     
  3734.     PURPOSE:       EPILOGUE defines dependant code which is run after the last
  3735.                    line of the input file is read and the POM file is executed
  3736.                    to process it.  In other words, once all the input data is
  3737.                    finished, the POM file runs one last time -- but only the
  3738.                    code in the EPILOGUE section.
  3739.     
  3740.     SEE ALSO:      "The Prologue Command"
  3741.     
  3742.     You can use EPILOGUE to output final results.  Let's say your input file
  3743.     looks like this:
  3744.     
  3745.     DESCRIPTION      UNITS SOLD    UNIT PRICE
  3746.     Wildebeest food         325    $     9.99
  3747.     Horse cologne            13    $     3.25
  3748.     Moose alarm             210    $     5.95
  3749.     :                :        :     :       :    (Column positions)
  3750.     1               18       27    33      41
  3751.     
  3752.     You can find out the total number of units sold (of all types) with the
  3753.     following POM file:
  3754.     
  3755.     
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.                                                                              59
  3763.     IGNORE $FLINE[1 7] = "DESCRIP"
  3764.     CALC   units = units "+" $FLINE[18 27]
  3765.     EPILOGUE
  3766.       OUTEND |Total units sold = {units}
  3767.     END
  3768.     
  3769.     This POM file adds up the number of units sold.  The only output is the
  3770.     single line generated by the OUTEND in the EPILOGUE.
  3771.     
  3772.     If you are processing multiple files (see "POM and Wildcards"), the
  3773.     EPILOGUE is run after each input file is finished.
  3774.     
  3775.     
  3776.     
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.                                                                              60
  3818.     ============================================================================
  3819.                                  VARIABLE MODIFIERS
  3820.     ============================================================================
  3821.     
  3822.                                   ----------------
  3823.                                   The TRIM Command
  3824.                                   ----------------
  3825.     
  3826.     FORMAT:        TRIM var1 value1 value2
  3827.     
  3828.     PURPOSE:       TRIM removes the character in value2 from var1.
  3829.     
  3830.     PARAMETERS:    var1   is the variable being set
  3831.                    value1 is "A" = All; "B" = Both ends;
  3832.                              "L" = Left side only; "R" = Right side only;
  3833.                              "M" = Multiples
  3834.                    value2 is the character to be removed.
  3835.     
  3836.     ALTERNATIVES:  The SET, CHANGE and REMAP commands
  3837.     
  3838.     The TRIM command gets rid of unwanted characters in a variable.  It is
  3839.     typically used to remove blanks from either side of text, or leading zeros
  3840.     from numeric data.
  3841.     
  3842.     For example, to remove commas and the leading dollar sign from a number:
  3843.     
  3844.     SET  PRICE = $FLINE[20 26]      <-- Get the variable from the input file
  3845.     TRIM PRICE "A" ","              <-- Trim All
  3846.     TRIM PRICE "L" "$"              <-- Trim Left
  3847.     
  3848.     Here is how it works:
  3849.     
  3850.     If the input contains the string:   "$25,783"
  3851.     The first TRIM changes it to:       "$25783"
  3852.     The second TRIM changes it to:      "25783"
  3853.     
  3854.     You can also squeeze out multiple occurrences of a given character.  For
  3855.     example, to remove multiple spaces from a variable named xyz, use this
  3856.     command:
  3857.     
  3858.     TRIM xyz "M" " "
  3859.     
  3860.     If xyz has the value "  A  B C  ", the command shown above changes it to
  3861.     " A B C ".  You can then get rid of the spaces at both ends with this
  3862.     command:
  3863.     
  3864.     TRIM xyz "B" " "
  3865.     
  3866.     This changes the xyz variable to "A B C".
  3867.     
  3868.     
  3869.  
  3870.  
  3871.  
  3872.                                                                              61
  3873.                                   ---------------
  3874.                                   The PAD Command
  3875.                                   ---------------
  3876.     
  3877.     FORMAT:        PAD var1 value1 value2 value3
  3878.                        :    :       :     :
  3879.     MEANING:       Variable Control Char  Number
  3880.     
  3881.     PURPOSE:       PAD makes var1 a specified length, padded with a
  3882.                    specified character.
  3883.     
  3884.     PARAMETERS:    var1   is the variable being set
  3885.                    value1 is "L", "R", or "C" (Left, Right or Center)
  3886.                    value2 is the character used to pad the string
  3887.                    value3 is the desired string length
  3888.     
  3889.     NUMERICS:      Tabs, spaces and commas are stripped from value3
  3890.     
  3891.     ALTERNATIVES:  The CHANGE command
  3892.     
  3893.     Here is an example of the PAD command.  If the variable ABC is already set
  3894.     to "1234" ...
  3895.     
  3896.     PAD ABC "L" "0" "7"   left-pads it 7 characters wide with zeros ("0001234")
  3897.     PAD ABC "R" " " "5"   right-pads it 5 characters wide with spaces ("1234 ")
  3898.     PAD ABC "C" "*" "8"   centers it, 8 wide, with asterisks ("**1234**")
  3899.     
  3900.     If the length is less than the length of the string, it is unchanged.  For
  3901.     example, if you set variable XYZ to "PINNACLE", then
  3902.     
  3903.     PAD XYZ "R" " " "3"
  3904.     
  3905.     leaves the string as-is ("PINNACLE").
  3906.     
  3907.     Thus, PAD can not be used to shorten a string.  If it is your intention to
  3908.     make XYZ 3 letters long, you can use the SET command:
  3909.     
  3910.     SET XYZ = XYZ[1 3]
  3911.     
  3912.                                  ------------------
  3913.                                  The CHANGE Command
  3914.                                  ------------------
  3915.     
  3916.     FORMAT:        CHANGE var1 value1 value2
  3917.     
  3918.     PURPOSE:       The CHANGE command replaces ALL occurrences of value1
  3919.                    with value2.
  3920.     
  3921.     ALTERNATIVES:  The TRIM command.  (The CHANGE command is more powerful than
  3922.                    TRIM, but is not as efficient).
  3923.     
  3924.     
  3925.  
  3926.  
  3927.                                                                              62
  3928.     Here is an example of the CHANGE command in action:
  3929.     
  3930.     SET    DATE = $FLINE[31 38]
  3931.     CHANGE DATE "/" "--"
  3932.     
  3933.     If the SET command assigns DATE the value:    "93/10/15"
  3934.     Then the CHANGE command converts it to:       "93--10--15"
  3935.     
  3936.                                 -------------------
  3937.                                 The CVTCASE Command
  3938.                                 -------------------
  3939.     
  3940.     FORMAT:        CVTCASE  var1 value1 [value2]
  3941.     
  3942.     PURPOSE:       CVTCASE converts a value to uppercase or lowercase.
  3943.     
  3944.     PARAMETERS:    var1   is the variable being set
  3945.                    value1 is the value being converted
  3946.                    value2 is the optional control setting
  3947.     
  3948.     DEFAULTS:      value2 = "UI"
  3949.     
  3950.     ALTERNATIVES:  The PROPER or REMAP commands; $FLUPC
  3951.     
  3952.     CVTCASE converts value1 to uppercase or lowercase and places the result in
  3953.     var1.  Here are some examples:
  3954.     
  3955.          COMMAND                      DESCRIPTION
  3956.          ---------------------------  --------------------------------
  3957.          CVTCASE xyz "Test Case" "U"  Sets variable xyz to "TEST CASE"
  3958.          CVTCASE xyz "Test Case" "L"  Sets variable xyz to "test case"
  3959.          CVTCASE xyz "Test Case"      Sets variable xyz to "TEST CASE"
  3960.     
  3961.     In the last example, the optional control parameter (value2) was omitted.
  3962.     In such case, CVTCASE will convert the value to uppercase.
  3963.     
  3964.     
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.                                                                              63
  3983.     ----------------
  3984.     Control Settings
  3985.     ----------------
  3986.     
  3987.     The control setting (value2) can be one or two characters long, or it can
  3988.     be omitted (in which case it is assumed to be "UI").  Here are the
  3989.     available settings for value2:
  3990.     
  3991.                     SETTING  CONVERT TO  CHARACTER SET
  3992.                     -------  ----------  ------------------
  3993.                     "L"      Lowercase   IBM Extended ASCII
  3994.                     "LI"     Lowercase   IBM Extended ASCII
  3995.                     "L7"     Lowercase   7-bit ASCII
  3996.                     "U"      Uppercase   IBM Extended ASCII
  3997.                     "UI"     Uppercase   IBM Extended ASCII
  3998.                     "U7"     Uppercase   7-bit ASCII
  3999.     
  4000.     The IBM Extended ASCII character set defines diacritical (accented)
  4001.     characters such as "U Umlaut" and "C Cedille"; these are located in the
  4002.     ASCII table above value 127.  It is the standard character set used by
  4003.     MS-DOS and PC-DOS.
  4004.     
  4005.     The 7-bit ASCII character set is concerned only with the characters in the
  4006.     original definition of ASCII (American Standard Code for Information
  4007.     Interchange), which does not support diacritical characters.  As such,
  4008.     uppercasing and lowercasing affect only alphabetic characters ("A" to "Z",
  4009.     and "a" to "z").  This character set is used by many mini-computers, and
  4010.     is the standard character set of the Unix operating system.
  4011.     
  4012.     The eighth bit is not ignored if you use CVTCASE with the 7-bit ASCII
  4013.     character set.  If you wish to set the eighth bit to zero (perhaps because
  4014.     it is a parity bit), you should use the REMAP command.
  4015.     
  4016.                                  ------------------
  4017.                                  The PROPER Command
  4018.                                  ------------------
  4019.     
  4020.     FORMAT:        PROPER var1 [value1 [value2]]
  4021.     
  4022.     PURPOSE:       The PROPER command converts uppercase text (LIKE THIS) to
  4023.                    mixed-case text (Like This).
  4024.     
  4025.     PARAMETERS:    var1   is the variable being set
  4026.                    value1 is the methods setting
  4027.                    value2 is the name of the Properization Exception File
  4028.     
  4029.     DEFAULTS:      value1 = "IW"
  4030.     
  4031.     ALTERNATIVES:  The CHANGE command; $FLUPC (uppercase version of $FLINE)
  4032.     
  4033.     
  4034.  
  4035.  
  4036.  
  4037.                                                                              64
  4038.     The PROPER command is useful when you have a list of names of people and
  4039.     addresses.  You can also use PROPER to change text that has been typed in
  4040.     uppercase into normal text, with capital letters at the beginning of
  4041.     sentences.
  4042.     
  4043.     The simplest way to convert a variable is as follows:
  4044.     
  4045.     PROPER CustName
  4046.     
  4047.     If CustName contains "JOHN SMITH", it will be changed to "John Smith".
  4048.     
  4049.     The conversion routine is fairly intelligent.  For example, if it is
  4050.     converting the words "JAGUAR XJS", it can tell that XJS is not a word
  4051.     (since it does not contain any vowels) and so the end result will
  4052.     be "Jaguar XJS".  Other "strange-looking" items such as serial numbers
  4053.     can often be recognized by the PROPER command, and left untouched.
  4054.     
  4055.     Nevertheless, it is impossible to handle all situations, so the PROPER
  4056.     command supports a "Properization Exceptions File" (known as a PEF file).
  4057.     A PEF file lists unusual combinations of letters (typically abbreviations,
  4058.     such as Dr.).  The Parse-O-Matic package includes a file named GENERIC.PEF,
  4059.     which you may find helpful.  You can view it with the SEE program provided
  4060.     with Parse-O-Matic.
  4061.     
  4062.     A PEF file is prepared with a text editor and contains one "exception" per
  4063.     line.  Null or blank lines, or lines that start with a semicolon, are
  4064.     ignored.  The longest word that can be specified is 255 characters.
  4065.     Spaces are permitted, but leading and trailing spaces and tabs are ignored.
  4066.     
  4067.     To use the PEF file in your PROPER command, place the file name after the
  4068.     variable name and method setting.  For example:
  4069.     
  4070.     PROPER CustName "W" "GENERIC.PEF"
  4071.     
  4072.     The "W" is the method setting (explained later).  "GENERIC.PEF" is the name
  4073.     of the PEF file.  When Parse-O-Matic looks for the PEF file, it looks for
  4074.     it in the current directory unless an explicit path is specified, then
  4075.     searches elsewhere, if necessary.  (For details, see the section entitled
  4076.     "How Parse-O-Matic Searches for a File".)
  4077.     
  4078.     If it can not find it there, it looks in the
  4079.     directory where POM.EXE is located.  You can, if you wish, specify a
  4080.     complete path to the file, as in this example:
  4081.     
  4082.     PROPER Address "W" "C:\MYFILES\MYPEF.XYZ"
  4083.     
  4084.     If you don't need an exceptions file, you should not use it, since it slows
  4085.     down processing somewhat.  Needless to say, the more items you have in the
  4086.     PEF file, the more it slows down processing.
  4087.     
  4088.     
  4089.  
  4090.  
  4091.  
  4092.                                                                              65
  4093.     The method setting allows you to specify what PROPER does.  There are
  4094.     several kinds of controls, as follows:
  4095.     
  4096.           METHOD   DESCRIPTION
  4097.           ------   -----------
  4098.             I      Intelligent determination of non-words
  4099.             S      Upcase the first character of each sentence
  4100.             U      Upcase the first alphanumeric character of the line
  4101.             W      Upcase the first letter of each word
  4102.     
  4103.     The default method setting is "IW", so if you omit the method setting, or
  4104.     specify a null setting (e.g. PROPER CustName "" "XYZ.PEF"), PROPER will
  4105.     upcase non-words, and the first letter of each word.
  4106.     
  4107.     NOTE:  If you specify a PEF file, you must also specify a method setting,
  4108.     even if it is null.  The line PROPER x "GENERIC.PEF" would not be understood
  4109.     by Parse-O-Matic.  The correct format would be:  PROPER x "" "GENERIC.PEF"
  4110.     
  4111.     The examples provided with Parse-O-Matic demonstrate some ways you can use
  4112.     the PROPER command.  To see the examples, enter INFO at the DOS prompt,
  4113.     or run INFO.BAT from Windows, then select TUTORIAL.
  4114.     
  4115.                                  ------------------
  4116.                                  The INSERT Command
  4117.                                  ------------------
  4118.     
  4119.     FORMAT:        INSERT var1 value1 value2
  4120.     
  4121.     PURPOSE:       The INSERT command inserts text on the left or right of
  4122.                    var1, or at a "found text" position.
  4123.     
  4124.     PARAMETERS:    var1   is the variable being set
  4125.                    value1 is "L" or "R" (Left or Right) or a find-string
  4126.                           (e.g.  "<HELLO")
  4127.                    value2 is the value to be inserted
  4128.     
  4129.     ALTERNATIVES:  The APPEND and CHANGE commands
  4130.     
  4131.     
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.                                                                              66
  4148.     For example, if the variable ABC is set to "Parse-O-Matic", then
  4149.     
  4150.     INSERT ABC "L" "Register "    sets ABC to "Register Parse-O-Matic"
  4151.     INSERT ABC "R" " is super"    sets ABC to "Parse-O-Matic is super"
  4152.     
  4153.     You can use a find-string to insert text either before or after the first
  4154.     occurrence of the text you specify.  For example, if the variable xyz is
  4155.     set to "One a day", then
  4156.     
  4157.     INSERT xyz "<e"    "c"        sets xyz to "Once a day"
  4158.     INSERT xyz ">One " "hour "    sets xyz to "One hour a day"
  4159.     
  4160.     The < prefix means "insert value1 before the found text".  The > prefix
  4161.     means "insert value1 after the found text".
  4162.     
  4163.     If the find-string is not found, nothing is done.
  4164.     
  4165.     NOTE:  Prior to version 3.40 of Parse-O-Matic, the "insert before" opera-
  4166.            tion was denoted by the @ prefix rather than the < prefix.  This
  4167.            still works, so you do not have to change your POM files.
  4168.     
  4169.                                  ------------------
  4170.                                  The APPEND Command
  4171.                                  ------------------
  4172.     
  4173.     FORMAT:        APPEND var1 value1 value2 [value3 [value4]]
  4174.     
  4175.     PURPOSE:       The APPEND command concatenates (adds together) two or more
  4176.                    values and places the result in var1.
  4177.     
  4178.     NOTES:         No variable can hold more than 255 characters.
  4179.     
  4180.     ALTERNATIVES:  The INSERT command
  4181.     
  4182.     Here is an example of the APPEND command:
  4183.     
  4184.     APPEND xyz "AB" "CD" "EF" "GHIJ"
  4185.     
  4186.     This command sets the variable xyz to "ABCDEFGHIJ".
  4187.     
  4188.     The third and fourth values (value3 and value4 in the FORMAT shown above)
  4189.     are optional.  Thus, you can use APPEND with only two values.  For example:
  4190.     
  4191.     SET    x1 = "AB"
  4192.     SET    x2 = "CD"
  4193.     APPEND x3 x1 x2
  4194.     
  4195.     This sets the variable x3 to "ABCD".  You can concatenate a maximum of four
  4196.     values with a single APPEND command.  If you require additional concaten-
  4197.     ations, you can use more APPEND commands:
  4198.     
  4199.     
  4200.  
  4201.  
  4202.                                                                              67
  4203.     APPEND myvar "ABC" "DEF" "GHI" "JKL"
  4204.     APPEND myvar myvar "MNO" "PQR"
  4205.     
  4206.     The first line sets the variable myvar to "ABCDEFGHIJKL".  The second line
  4207.     set myvar to its previous value, plus "MNOPQR", so that its final value is
  4208.     "ABCDEFGHIJKLMNOPQR".
  4209.     
  4210.                                 -------------------
  4211.                                 The OVERLAY Command
  4212.                                 -------------------
  4213.     
  4214.     FORMAT:        OVERLAY var1 value1 value2
  4215.     
  4216.     PURPOSE:       The OVERLAY command overwrites a portion of a variable with
  4217.                    a value, at the specified position.  The length of the
  4218.                    variable is padded with spaces if necessary.
  4219.     
  4220.     PARAMETERS:    var1   is the variable to be overwritten
  4221.                    value1 is the data which will be placed into var1
  4222.                    value2 is the position, in var1, where value1 will be placed
  4223.     
  4224.     NOTES:         No variable can hold more than 255 characters.
  4225.     
  4226.     NUMERICS:      Tabs, spaces and commas are stripped from value2
  4227.                    value2 must be between "1" and "255"
  4228.     
  4229.     SEE ALSO:      "The Append Command" and "The Insert Command"
  4230.     
  4231.     The OVERLAY command lets you replace part of a variable, starting at a
  4232.     particular position.  Here is an example:
  4233.     
  4234.     SET      x = "ABCDEFG"
  4235.     SET      y = "pom"
  4236.     OVERLAY  x y "4"
  4237.     
  4238.     This will change the x variable so it contains "ABCpomG", since it places
  4239.     the "pom" at position "4".
  4240.     
  4241.     If value2 is greater than the length of var1, var1 is padded with spaces to
  4242.     allow value2 to be placed at the specified position.  For example:
  4243.     
  4244.     SET      x = "ABCDEFG"
  4245.     SET      y = "pom"
  4246.     OVERLAY  x y "10"
  4247.     
  4248.     This will change the x variable to "ABCDEFG  pom".  Since var1 was less than
  4249.     10 characters, it had to be extended to allow the "pom" to start in position
  4250.     "10".
  4251.     
  4252.     
  4253.  
  4254.  
  4255.  
  4256.  
  4257.                                                                              68
  4258.     Since no variable can be more than 255 characters, OVERLAY will truncate the
  4259.     result if it extends beyond that:
  4260.     
  4261.     SET      x = "ABCDEFG"
  4262.     SET      y = "pom"
  4263.     OVERLAY  x y "254"
  4264.     
  4265.     The x variable will be 255 characters long (starting with "ABCDEFG",
  4266.     followed by many spaces) and end with "po", since the "p" is in position
  4267.     "254" and the "o" is in the last legal position (i.e. "255").
  4268.     
  4269.     Here are some additional examples:
  4270.     
  4271.     SET      x = ""        <-- Set x to a null (empty) string
  4272.     OVERLAY  x "ABC" "1"   <-- Set x to "ABC" (i.e. the "A" is at position "1")
  4273.     OVERLAY  x "DEF" "4"   <-- Change x from "ABC" to "ABCDEF"
  4274.     OVERLAY  x "IJ"  "9"   <-- Change x to "ABCDEF  IJ"
  4275.     OVERLAY  x "GH"  "7"   <-- Change x to "ABCDEFGHIJ"
  4276.     
  4277.     -------------
  4278.     Simple Arrays
  4279.     -------------
  4280.     
  4281.     You can use OVERLAY to perform some simple array processing, provided the
  4282.     total length of the data items does not exceed 255 characters.  For example,
  4283.     you could store 25 items of up to 10 characters each in a 250-character
  4284.     variable. Here is a helpful subroutine (see "The Code Command") for this
  4285.     kind of operation:
  4286.     
  4287.     CODE     "Calc Array Indexes"
  4288.       SET      ItemSize  = "10"
  4289.       CALC     IndexStart = Index- "*" ItemSize
  4290.       CALC     IndexEnd   = IndexStart "+" ItemSize
  4291.       SET      IndexStart = IndexStart+
  4292.     END
  4293.     
  4294.     This will provide pointers for an array of 25 items of up to 10 characters
  4295.     each, with indexes of 1 to 10. You can use this information with both the
  4296.     OVERLAY and COPY commands.  You could extract the 15th item as follows:
  4297.     
  4298.     SET      Index = "15"
  4299.     CALL     "Calc Array Indexes"
  4300.     COPY     x MyArray IndexStart IndexEnd
  4301.     
  4302.     For a more sophisticated and flexible method of handling arrays, see "Array
  4303.     Variables".
  4304.     
  4305.     
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.                                                                              69
  4313.                                 -------------------
  4314.                                 The MAPFILE Command
  4315.                                 -------------------
  4316.     
  4317.     FORMAT:        value1 value2 [value3]
  4318.     
  4319.     PURPOSE:       MAPFILE reads a file containing data for the REMAP command
  4320.     
  4321.     PARAMETERS:    value1 is the name of the map file
  4322.                    value2 is the map name, used by the REMAP command
  4323.                    value3 is the control settings (AnyCase/MatchCase/Transpose)
  4324.     
  4325.     DEFAULTS:      value3 = "MATCHCASE"
  4326.     
  4327.     NOTES:         The maximum length of a map name is 12 characters
  4328.     
  4329.     SEE ALSO:      "The Remap Command", "How Parse-O-Matic Searches for a File"
  4330.     
  4331.     The MAPFILE command reads in a file which contains data for the REMAP
  4332.     command, and assigns a name to the collection of data so the REMAP command
  4333.     can refer to it.
  4334.     
  4335.     -------------------
  4336.     What is a Map File?
  4337.     -------------------
  4338.     
  4339.     A map file is an ordinary text file; you can create or edit the file with a
  4340.     standard text editor, or a word-processor in "generic text" mode. Map files
  4341.     are usually given the .MPF extension.
  4342.     
  4343.     A map file contains a list of "mappings".  Here are some other words with
  4344.     approximately the same meaning as "mapping":
  4345.     
  4346.       Translation   Correlation   Substitution   Equivalence   Replacement
  4347.     
  4348.     In other words, the map file contains a list of data items that should be
  4349.     replaced by other data items.
  4350.     
  4351.     ----------------
  4352.     Sample Map Files
  4353.     ----------------
  4354.     
  4355.     The following map files are included in the standard Parse-O-Matic package:
  4356.     
  4357.     FILE NAME     DESCRIPTION
  4358.     ------------  ----------------------------------------------------------
  4359.     BIN2CHAR.MPF  Converts binary data into printable characters and periods
  4360.     BIN2CODE.MPF  Converts binary data into hex codes (e.g. 3F 2C A3)
  4361.     ASC2EBCD.MPF  Converts ASCII data to EBCDIC and vice-versa
  4362.     
  4363.     
  4364.  
  4365.  
  4366.  
  4367.                                                                              70
  4368.     ---------------
  4369.     Map File Format
  4370.     ---------------
  4371.     
  4372.     The map file contains one mapping per line.  Each mapping consists of two
  4373.     Parse-O-Matic literals, separated by one or more spaces or tabs. The first
  4374.     value is the "find" column, while the second value is the "replace" column.
  4375.     Here are some examples:
  4376.     
  4377.     "123"  "LOS ANGELES"      <-- Both values are "literal text strings"
  4378.     $39    "9"                <-- A hex code and a literal text string
  4379.     #48    "Zero"             <-- A decimal code and a literal text string
  4380.     $FF$30 #00#00             <-- Hex and decimal literals
  4381.     
  4382.     These columns are lined up for clarity; there is no need to start in a
  4383.     particular column.  Any leading or trailing spaces are removed from a
  4384.     line, and any number of spaces or tabs can appear between the columns.
  4385.     
  4386.     The following line is NOT valid:
  4387.     
  4388.     123    LOS ANGELES
  4389.     
  4390.     The line must use text, hex or decimal literals (e.g. "text", $FF, #FF).
  4391.     
  4392.     Null or blank lines, or lines that start with a semicolon, are ignored.
  4393.     The longest line that can be specified is 255 characters.  The longest
  4394.     value that can be specified is 80 characters (after translation, if it
  4395.     is in hex or decimal mode).
  4396.     
  4397.     ------------
  4398.     Search Order
  4399.     ------------
  4400.     
  4401.     The REMAP command performs substitutions in the order that they appear in
  4402.     the map file.  In most cases, the longer "find" strings should appear
  4403.     first.  For example, let us say you create a map file named FORWARD.MPF,
  4404.     which looks like this:
  4405.     
  4406.     "123"   "in Los Angeles"
  4407.     "12"    "in Montreal"
  4408.     "1"     "in Town of Mount Royal"
  4409.     "2"     "in Podunk"
  4410.     
  4411.     
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.                                                                              71
  4423.     Now let's say you run the following POM file, named FORWARD.POM:
  4424.     
  4425.     MAPFILE "FORWARD"
  4426.     SET     comment = "Forward the memo to office 123"
  4427.     REMAP   comment
  4428.     OUTEND  |{comment}
  4429.     
  4430.     This will produce the following output:
  4431.     
  4432.     Forward the memo to office in Los Angeles
  4433.     
  4434.     This happens because the string "123" is replaced by the string "in Los
  4435.     Angeles".
  4436.     
  4437.     If the order of the lines in FORWARD.MPF are reversed, FORWARD.POM will
  4438.     produce the following output:
  4439.     
  4440.     Forward memo to Office in Town of Mount RoyalinPodunk3
  4441.     
  4442.     This happens because the "1" is found (and replaced) first, followed by the
  4443.     "2".  Since there is no "3" in FORWARD.MPF, it is left alone.
  4444.     
  4445.     Parse-O-Matic does NOT enforce the principle of "progressively shorter
  4446.     'find' strings".  If you are processing a lot of data, you can improve
  4447.     processing speed slightly by placing a short, frequently-used "find" string
  4448.     near the top of the list.  As long as it is not a sub-string of (i.e.
  4449.     contained within) one of the following strings, it will not cause any
  4450.     problems.
  4451.     
  4452.     
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.                                                                              72
  4478.     -------------
  4479.     Case Matching
  4480.     -------------
  4481.     
  4482.     You can set value3 to "AnyCase" or "MatchCase" (the default).
  4483.     
  4484.     ANYCASE:    The find string need not match in case ("John" = "JOHN")
  4485.     MATCHCASE:  The find string must match ("John" does not match "JOHN")
  4486.     
  4487.     Processing is faster if you use the default setting (MatchCase).
  4488.     
  4489.     ---------------
  4490.     Reverse Mapping
  4491.     ---------------
  4492.     
  4493.     If you want the mapping process to work "backwards", you can use the
  4494.     "Transpose" control setting in value3.  For example:
  4495.     
  4496.     MAPFILE "MYFILE.MPF" "MYFILE" "AnyCase Transpose"
  4497.     
  4498.     This reverses the mapping process:  the "find" column is treated like the
  4499.     "replace with" column, and vice-versa.
  4500.     
  4501.     The standard Parse-O-Matic package contains a map file (ASC2EBCD.MPF) which
  4502.     will translate ASCII files into EBCDIC files -- and vice-versa.
  4503.     
  4504.     NOTE:  EBCDIC is a character representation used on certain large mainframe
  4505.            computers.  Both ASCII and EBCDIC characters are eight bits long,
  4506.            but EBCDIC uses different bit patterns for most characters.
  4507.     
  4508.     Since both the "find" and "replace with" columns in ASC2EBCD.MPF are only
  4509.     one character wide, and since there is no duplication within either column,
  4510.     the translation process is perfectly reversible.  For example:
  4511.     
  4512.     
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.                                                                              73
  4533.     PROLOGUE
  4534.       CHOP     1 20                                <-- Read 20 bytes at a time
  4535.       MAPFILE  "ASC2EBCD.MPF" "EBCDIC"             <-+
  4536.       MAPFILE  "ASC2EBCD.MPF" "ASCII" "TRANSPOSE"    | Set up maps
  4537.       MAPFILE  "BIN2CODE.MPF" "CODE"               <-+
  4538.     END
  4539.     SET      x = $FLINE                            <-+
  4540.     REMAP    x "CODE"                                | Display original text in
  4541.     OUTEND   |[ORIGINAL] [{$FLINE}]                  | normal & hex-coded form
  4542.     OUTEND   |[ORIGINAL] [{x}]                     <-+
  4543.     REMAP    $FLINE "EBCDIC"                       <-+
  4544.     SET      x = $FLINE                              | Convert to EBCDIC and
  4545.     REMAP    x "CODE"                                | display in coded form
  4546.     OUTEND   |[EBCDIC  ] [{x}]                     <-+
  4547.     REMAP    $FLINE "ASCII"                        <-+
  4548.     SET      x = $FLINE                              | Convert EBCDIC back to
  4549.     REMAP    x "CODE"                                | ASCII; display hex code
  4550.     OUTEND   |[ASCII   ] [{x}]                     <-+
  4551.     OUTEND   |                                     <-- Output a separator line
  4552.     
  4553.     You can run this POM file against any file, then view the output file.  You
  4554.     will see how the original text is converted into EBCDIC and then the EBCDIC
  4555.     is converted back to ASCII.  (Most of the data in the output file is
  4556.     represented in "hex dump" format, since your computer is not designed to
  4557.     display EBCDIC.)
  4558.     
  4559.     TRANSPOSE will often let you use a single map file instead of two, but
  4560.     before using this technique you should carefully consider how mapping will
  4561.     take place (see "Irreversible Mapping", below).
  4562.     
  4563.     --------------------
  4564.     Irreversible Mapping
  4565.     --------------------
  4566.     
  4567.     Consider the following POM file:
  4568.     
  4569.     MAPFILE "MYMAP.MPF" "XYZ"
  4570.     MAPFILE "MYMAP.MPF" "ZYX" "TRANSPOSE"
  4571.     REMAP   $FLINE "XYZ"
  4572.     REMAP   $FLINE "ZYX"
  4573.     OUTEND  |{$FLINE}
  4574.     
  4575.     In many cases, this is equivalent to the following one-line POM file:
  4576.     
  4577.     OUTEND  |{$FLINE}
  4578.     
  4579.     because the first REMAP changes $FLINE one way, and the second REMAP
  4580.     changes it back.
  4581.     
  4582.     
  4583.  
  4584.  
  4585.  
  4586.  
  4587.                                                                              74
  4588.     This is not true in ALL cases, however.  In some circumstances a REMAP is
  4589.     not reversible.  Consider the following map file:
  4590.     
  4591.     "XYZ"  "CAB"
  4592.     "ABC"  "C"
  4593.     "DEF"  "ABC"
  4594.     
  4595.     Now consider the following sequence of events.  (The * and # characters
  4596.     show what gets replaced in each step.)
  4597.     
  4598.                  Original string   . . . . . . . . .   ABCDEF
  4599.                                                        ***###
  4600.     
  4601.                                                        *###
  4602.                  Remap produces this result  . . . .   CABC
  4603.                                                        ***
  4604.     
  4605.                                                        ***
  4606.                  Transposed remap of result  . . . .   XYZC
  4607.     
  4608.     If you follow the steps of the substitutions, you will see where the
  4609.     confusion arises.  As a general rule, simple substitutions (with no
  4610.     duplications in whole or in part) are reversible, but if you have any
  4611.     doubts, you can always take the safe route and use a separate map file
  4612.     for each direction.  (See "Search Order", above, for additional insight
  4613.     into this matter.)
  4614.     
  4615.     ------------------
  4616.     Memory Limitations
  4617.     ------------------
  4618.     
  4619.     The MAPFILE command reads the map data into RAM memory.  You will normally
  4620.     have sufficient memory for thousands of bytes worth of mappings. However,
  4621.     if you do not have enough memory to hold the data, Parse-O-Matic will
  4622.     display an error message, then terminate.  (See "Solving Memory Problems")
  4623.     
  4624.     To help you track memory usage, the MAPFILE command records memory status
  4625.     (bytes used and bytes left) in the processing log (see "Logging").
  4626.     
  4627.     -----------------------
  4628.     An Example of Remapping
  4629.     -----------------------
  4630.     
  4631.     The standard Parse-O-Matic package contains two sample map files:
  4632.     
  4633.     BIN2CODE.MPF maps single bytes to hex codes  (e.g. Hex $31 becomes "31 ")
  4634.     BIN2CHAR.MPF maps single bytes to either printable characters or periods
  4635.     
  4636.     You can view these files with the SEE program (included with Parse-O-Matic)
  4637.     or you can load them into a text editor program.
  4638.     
  4639.     Here is a POM file that uses the sample map files to create a hex dump of a
  4640.     binary file:
  4641.  
  4642.                                                                              75
  4643.     CHOP    1 16                  <-- Read the file 16 bytes at a time
  4644.     SETLEN  w $FLINE              <-- Get the actual number of bytes read
  4645.     BEGIN w <> "16"
  4646.       PAD $FLINE "R" #0 "16"      <-- If less than 16 bytes, pad with nulls
  4647.     END
  4648.     SET     x = $FLINE            <-- Make a copy of $FLINE
  4649.     SET     y = $FLINE            <-- Make a copy of $FLINE
  4650.     MAPFILE "BIN2CHAR" "CHAR"     <-- See Note
  4651.     MAPFILE "BIN2CODE.MPF" "CODE"
  4652.     REMAP   x "CHAR"              <-- Change the bytes to printable characters
  4653.     REMAP   y "CODE"              <-- Change the bytes to hex codes
  4654.     OUTEND  |x y                  <-- Output the line
  4655.     
  4656.     Note:  Since the file name (value1) does not have an extension,
  4657.            Parse-O-Matic will add the .MPF extension.  Thus, the actual file
  4658.            name Parse-O-Matic looks for is "BIN2CHAR.MPF".
  4659.     
  4660.                                  -----------------
  4661.                                  The REMAP Command
  4662.                                  -----------------
  4663.     
  4664.     FORMAT:        REMAP var1 value1
  4665.     
  4666.     PURPOSE:       REMAP transforms sub-strings into other strings
  4667.     
  4668.     PARAMETERS:    var1   is the variable being transformed
  4669.                    value1 is the map name (see "The MapFile Command")
  4670.     
  4671.     ALTERNATIVES:  The LOOKUP and CHANGE commands
  4672.     
  4673.     SEE ALSO:      "The MapFile Command"
  4674.     
  4675.     The REMAP command performs intensive substitutions on a variable.  It is
  4676.     equivalent to a large number of CHANGE commands, but has the following
  4677.     advantages:
  4678.     
  4679.     - It is faster than using a large number of CHANGEs
  4680.     - It does not expend your available values (see "Values")
  4681.     - It prevents multiple substitutions
  4682.     
  4683.     
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.  
  4691.  
  4692.  
  4693.  
  4694.  
  4695.  
  4696.  
  4697.                                                                              76
  4698.     -------------------
  4699.     REMAP Versus CHANGE
  4700.     -------------------
  4701.     
  4702.     The "multiple substitution" issue is most important distinction between
  4703.     CHANGE and REMAP.  REMAP protects substituted text from being
  4704.     resubstituted.  Consider the following POM lines:
  4705.     
  4706.     SET    x = "cat dog mouse"
  4707.     CHANGE x "cat" "dog"
  4708.     CHANGE x "dog" "cat"
  4709.     
  4710.     You might expect these lines to change x to "Dog Cat Mouse", but the actual
  4711.     result is "cat cat mouse".  The first CHANGE command sets the x variable to
  4712.     "dog dog mouse".  The next command changes the dogs into cats!
  4713.     
  4714.     You can avoid this problem by using intermediate substitutions or some such
  4715.     work-around, but this ends up complicating the POM file considerably.
  4716.     Moreover, this approach can be unwieldy if you have to perform a large
  4717.     number of substitutions.
  4718.     
  4719.     -----------
  4720.     Using REMAP
  4721.     -----------
  4722.     
  4723.     To accomplish the "cat/dog" substitution mentioned earlier, you can create
  4724.     a map file (named CATDOG.MPF) with a text editor.  It will look like this:
  4725.     
  4726.     "cat"  "dog"
  4727.     "dog"  "cat"
  4728.     
  4729.     Your POM file will then look like this:
  4730.     
  4731.     MAPFILE "CATDOG.MPF" "PETS"
  4732.     SET     x = "cat dog mouse"
  4733.     REMAP   x "PETS"
  4734.     
  4735.     This will change the x variable to "dog cat mouse".
  4736.     
  4737.     For another example of the REMAP command, see "The MapFile Command".
  4738.     
  4739.     
  4740.     
  4741.  
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749.  
  4750.  
  4751.  
  4752.                                                                              77
  4753.     ============================================================================
  4754.                                  FREE-FORM COMMANDS
  4755.     ============================================================================
  4756.     
  4757.                             ----------------------------
  4758.                             What are Free-Form Commands?
  4759.                             ----------------------------
  4760.     
  4761.     The free-form commands are used for extracting information from an input
  4762.     line that does not have its data in precise columns.  Consider the
  4763.     following input file:
  4764.     
  4765.     Mouse     Gazelle   Mouse     Elephant
  4766.     Dog       Giraffe   Elk       Mongoose
  4767.     Monkey    Snake     Caribou   Trout
  4768.     |         |         |         |
  4769.     Column 1  Col 11    Col 21    Col 31
  4770.     
  4771.     Extracting data that is arranged in tidy columns is simple -- all you need
  4772.     is the SET command.  However, you will need a more powerful command if the
  4773.     data is "free-form", like this:
  4774.     
  4775.     Mouse,Gazelle,Mouse,Elephant
  4776.     Dog,Giraffe,Elk,Mongoose
  4777.     Monkey,Snake,Caribou,Trout
  4778.     
  4779.     The data is not arranged in tidy columns.  For tasks like this, you need
  4780.     the free-form commands.
  4781.     
  4782.                                  -----------------
  4783.                                  The PARSE Command
  4784.                                  -----------------
  4785.     
  4786.     FORMAT:        PARSE var1 value1 value2 value3 [value4]
  4787.                          :    :      :      :       :
  4788.     MEANING:       Variable   Source From   To      Control
  4789.     
  4790.     PURPOSE:       PARSE sets var1 to the text (found in value1) between
  4791.                    text fragments specified by value2 and value3.
  4792.     
  4793.     PARAMETERS:    var1   is the variable being set
  4794.                    value1 is the source text being read
  4795.                    value2 specifies the starting position (decapsulator)
  4796.                    value3 specifies the ending position (decapsulator)
  4797.                    value4 is the optional control setting
  4798.     
  4799.     DEFAULTS:      value4 = "X"
  4800.     
  4801.     ALTERNATIVES:  The PEEL command, and COPY used with FINDPOSN
  4802.     
  4803.     
  4804.  
  4805.  
  4806.  
  4807.                                                                              78
  4808.     Consider the following free-form data:
  4809.     
  4810.     Mouse,Gazelle,Mouse,Elephant
  4811.     Dog,Giraffe,Elk,Mongoose
  4812.     Monkey,Snake,Caribou,Trout
  4813.     
  4814.     The PARSE command lets you extract the "Nth" item.  For example, to extract
  4815.     the third item in each line in the free-form example above, you could use
  4816.     this command:
  4817.     
  4818.     PARSE  xyz  $FLINE  "2*,"  "3*,"
  4819.     
  4820.     This means "set the variable xyz by looking in $FLINE (the line just read
  4821.     from the input file) and taking everything between the second comma and the
  4822.     third comma".  For the three lines in the sample input file, the variable
  4823.     xyz is set to Mouse, then Elk, then Caribou.
  4824.     
  4825.     -------------
  4826.     Decapsulators
  4827.     -------------
  4828.     
  4829.     In the "From" specification in the previous example (i.e. the "2*," part
  4830.     of the command):
  4831.     
  4832.           2    means "the second occurrence"
  4833.           *    is a delimiter to mark the end of the occurrence number
  4834.           ,    is the text you are looking for
  4835.     
  4836.     Both the "From" and "To" specifications use this format.  Commands using
  4837.     this format are said to use "decapsulators", because you are extracting
  4838.     text that is encapsulated (i.e. surrounded) by other text.
  4839.     
  4840.     Decapsulators may be used to find more than a single character.  The
  4841.     surrounding text can be up to 80 characters long.  Let's say the input file
  4842.     looks like this:
  4843.     
  4844.     Mouse%:Gazelle%:Mouse%:Elephant
  4845.     Dog%:Giraffe%:Elk%:Mongoose
  4846.     Monkey%:Snake%:Caribou%:Trout
  4847.     
  4848.     You can extract the third item in each line with this command:
  4849.     
  4850.            PARSE  xyz  $FLINE  "2*%:"  "3*%:"
  4851.                   ___  ______   _ ___    _ ___
  4852.                    |     |      |  |     |  |
  4853.      Variable to set     |      |  |     |  |
  4854.         The value to parse      |  |     |  "To" text being sought
  4855.          "From" occurrence number  |     "To" occurrence number
  4856.             "From" text being sought
  4857.     
  4858.     This command sets the variable xyz to Mouse, then Elk, then Caribou.
  4859.     
  4860.     
  4861.  
  4862.                                                                              79
  4863.     ------------------
  4864.     Sample Application
  4865.     ------------------
  4866.     
  4867.     The PARSE command is particularly useful for extracting information from
  4868.     comma-delimited files.  Here is an example of a comma-delimited file:
  4869.     
  4870.     "Mouse","Gazelle","Mouse","Elephant"
  4871.     "Dog","Giraffe","Elk","Mongoose"
  4872.     "Monkey","Snake","Caribou","Trout"
  4873.     
  4874.     You can extract all the fields with this series of commands (note the use
  4875.     of doubled-up quotes to represent a single quotation mark -- see the
  4876.     section "Delimiters" for details):
  4877.     
  4878.     PARSE  field1  $FLINE  "1*"""  "2*"""
  4879.     PARSE  field2  $FLINE  "3*"""  "4*"""
  4880.     PARSE  field3  $FLINE  "5*"""  "6*"""
  4881.     PARSE  field4  $FLINE  "7*"""  "8*"""
  4882.     
  4883.     For the first line of the sample input file, field1 is set to Mouse, field2
  4884.     is set to Gazelle, and so on.
  4885.     
  4886.     ---------------------
  4887.     The Occurrence Number
  4888.     ---------------------
  4889.     
  4890.     The occurrence number must be between 1 and 255.  The following lines are
  4891.     not valid PARSE commands:
  4892.     
  4893.     PARSE  xyz  $FLINE  "0*,"  "1*,"    <-- "From" decapsulator invalid: uses 0
  4894.     PARSE  xyz  $FLINE  "1*,"  "256*,"  <-- "To" decapsulator invalid: uses 256
  4895.     
  4896.     The occurrence number must always be followed by a "*" so you can search
  4897.     for a number.  Consider the following example (the meaning of which would
  4898.     be unclear without the "*" delimiter):
  4899.     
  4900.     PARSE  xyz  "XXX2YYY2ZZZ2"  "1*2"  "2*2"
  4901.     
  4902.     This sets xyz to the text occurring between the first "2" and the second
  4903.     "2".  In other words, xyz is set to "YYY".
  4904.     
  4905.     
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912.  
  4913.  
  4914.  
  4915.  
  4916.  
  4917.                                                                              80
  4918.     ---------------------------
  4919.     Finding the Last Occurrence
  4920.     ---------------------------
  4921.     
  4922.     A decapsulator can refer to "the LAST occurrence":
  4923.     
  4924.     PARSE  xyz  "AaaBAbbBAccB"  ">*A"  ">*B"
  4925.     
  4926.     In both decapsulators, the ">" symbol means "the last occurrence".  Thus,
  4927.     the command tells Parse-O-Matic, "Set the xyz variable to everything
  4928.     between the last A and the last B".  This sets the xyz variable to "cc".
  4929.     
  4930.     You can also use the "<" character to mean "the FIRST occurrence", although
  4931.     this is somewhat redundant, since the following commands are equivalent:
  4932.     
  4933.     PARSE  xyz  "AaaBAbbBAccB"  "<*A"  "<*B"
  4934.     PARSE  xyz  "AaaBAbbBAccB"  "1*A"  "1*B"
  4935.     PARSE  xyz  "AaaBAbbBAccB"  "A"  "B"
  4936.     
  4937.     All three commands set the xyz variable to "aa".
  4938.     
  4939.     ---------------------
  4940.     Unsuccessful Searches
  4941.     ---------------------
  4942.     
  4943.     If PARSE does not find the search text, the variable will be set to a null
  4944.     ("").  Here are two examples:
  4945.     
  4946.     PARSE  abc  "ABCDEFGHIJ"  "1*K"  "1*J"   <-- There is no "K"
  4947.     PARSE  abc  "ABCDEFGHIJ"  "1*A"  "1*X"   <-- There is no "X"
  4948.     
  4949.     If the "from" value is less than the "to" value, Parse-O-Matic will display
  4950.     an error message, then terminate.  For example:
  4951.     
  4952.     PARSE  abc  "ABCDEFGHIJ"  "1*J"  "1*A"   <-- "J" comes after "A"
  4953.     
  4954.     This kind of failure typically happens if the input data contains an odd
  4955.     arrangement of text that you had not foreseen.
  4956.     
  4957.     
  4958.  
  4959.  
  4960.  
  4961.  
  4962.  
  4963.  
  4964.  
  4965.  
  4966.  
  4967.  
  4968.  
  4969.  
  4970.  
  4971.  
  4972.                                                                              81
  4973.     -------------------
  4974.     The Control Setting
  4975.     -------------------
  4976.     
  4977.     The PARSE command has an optional "Control" parameter, which tells PARSE
  4978.     whether to include or exclude the surrounding text that was found.  By
  4979.     default (as shown in all of the preceding examples), the delimiting text
  4980.     is excluded.  However, if you want to include it, you can add "I" at the
  4981.     end of the PARSE command, as in this example:
  4982.     
  4983.     PARSE  xyz  "aXcaYcaZc"  "2*a"  "2*c"  "I"
  4984.     
  4985.     This tells Parse-O-Matic to give you everything between the second "a" and
  4986.     the second "c" -- including the "a" and "c".  In other words, this sets the
  4987.     variable xyz to "aYc".  You can also set the Control specification to "X"
  4988.     (meaning "exclude"), although since this is the default setting for PARSE,
  4989.     it really isn't necessary.  Here is an example:
  4990.     
  4991.     PARSE  xyz  "a1ca2ca3c"  "2*a"  "2*c"  "X"
  4992.     
  4993.     This sets the variable xyz to "2".
  4994.     
  4995.     ----------------------
  4996.     The Plain Decapsulator
  4997.     ----------------------
  4998.     
  4999.     The occurrence number is not always needed.  Either the "From" or "To"
  5000.     decapsulator can be represented as a plain string, as follows:
  5001.     
  5002.     PARSE $FLINE "ABC" "XYZ"
  5003.     
  5004.     This means:
  5005.     
  5006.     - Start at the first "ABC" found in the value being parsed
  5007.     - End with the first "XYZ" found in the value being parsed
  5008.     
  5009.     
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.                                                                              82
  5028.     ---------------------
  5029.     The Null Decapsulator
  5030.     ---------------------
  5031.     
  5032.     Here is helpful variation of the "From" decapsulator:
  5033.     
  5034.     ""   means "Start from the first character in the value being parsed"
  5035.     
  5036.     A similar variation can be used with the "To" decapsulator:
  5037.     
  5038.     ""   means "End with the last character in the value being parsed"
  5039.     
  5040.     If you use the null ("") decapsulator for "From" or "To", the "found" value
  5041.     (the first character for "From", or the last character for "To") will
  5042.     always be included (see "Overlapping Decapsulators" for the single
  5043.     exception to this rule).  Here is an example:
  5044.     
  5045.     PARSE  xyz  "ABCABCABC"  ""  "2*C"
  5046.     
  5047.     This sets the variable xyz to "ABCAB".  The "From" value (i.e. the first
  5048.     character) is NOT excluded.  However, when PARSE finds the "To" value (i.e.
  5049.     the second occurrence of the letter C) it IS excluded.  If you want to
  5050.     include the second "C", you should write the command this way:
  5051.     
  5052.     PARSE  xyz  "ABCABCABC"  ""  "2*C"  "I"
  5053.     
  5054.     The following two commands accomplish the same thing:
  5055.     
  5056.     PARSE  xyz  "ABCD"  ""  ""
  5057.     SET    xyz  "ABCD"
  5058.     
  5059.     They are equivalent because the PARSE command means "Set the variable xyz
  5060.     with everything between (and including) the first and last character".
  5061.     
  5062.     
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.                                                                              83
  5083.     ---------------------------------------
  5084.     Why Null Decapsulators Work Differently
  5085.     ---------------------------------------
  5086.     
  5087.     The reason that PARSE treats the null ("") decapsulator differently may
  5088.     not be immediately obvious, since the examples given here are very simple,
  5089.     and not representative of "real world" applications. However, in day-to-day
  5090.     usage, you will frequently find it helpful to be able to specify a command
  5091.     that says, "Give me everything from the beginning of the line to just
  5092.     before such-and-such".
  5093.     
  5094.     Here is a command that means "Give me everything from just after the dollar
  5095.     sign, to the end of the line":
  5096.     
  5097.     PARSE  xyz  "I'd like to have $250.00"  "1*$"  ""
  5098.     
  5099.     This sets xyz to "250.00".  If you want to include the dollar sign, write
  5100.     the command this way:
  5101.     
  5102.     PARSE  xyz  "I'd like to have $250.00"  "1*$"  ""  "I"
  5103.     
  5104.     -------------------------
  5105.     Overlapping Decapsulators
  5106.     -------------------------
  5107.     
  5108.     Earlier, it was mentioned that the text found by the null decapsulator is
  5109.     "always included" and is not affected by the "X" (Exclude) control.  There
  5110.     is one exception to this:  if the null decapsulator's "found text" is
  5111.     contained in the text found by the other decapsulator, it WILL be affected.
  5112.     For example:
  5113.     
  5114.     PARSE x "ABCDEFABCDEF" "" "1*AB" "X"
  5115.     
  5116.     This command tells Parse-O-Matic "give me everything between the first
  5117.     character and the first occurrence of AB".  Since the two items overlap
  5118.     (i.e. the first "AB" includes the first character), the first character
  5119.     does indeed get excluded. As a result, the x variable is set to an empty
  5120.     string ("").
  5121.     
  5122.     Here is another example:
  5123.     
  5124.     PARSE x "ABCDEFABCDEF" ">*F" "" "X"
  5125.     
  5126.     This command tells Parse-O-Matic "give me everything between the last
  5127.     occurrence of F and the last character".  Both decapsulators refer to the
  5128.     same character (i.e. the final "F"), so it is excluded. As a result, the x
  5129.     variable is set to an empty string ("").
  5130.     
  5131.     NOTE:  In some circumstances, the FINDPOSN command is NOT affected by this
  5132.            exception.  It will do its best to make sense of your request if the
  5133.            decapsulators overlap, and one of them is a null decapsulator.  For
  5134.            details, see "The FindPosn Command".
  5135.     
  5136.  
  5137.                                                                              84
  5138.     --------------------
  5139.     Parsing Empty Fields
  5140.     --------------------
  5141.     
  5142.     Consider the following command:
  5143.     
  5144.     PARSE x ",,,JOHN,SMITH" "2*," "3*,"
  5145.     
  5146.     There is nothing between the second and third comma, so the x variable
  5147.     is set to "" (an empty string).
  5148.     
  5149.     Now consider this command:
  5150.     
  5151.     PARSE x ",,,JOHN,SMITH" "" ","
  5152.     
  5153.     You are asking for everything from the first character to the first
  5154.     comma (which also happens to be the first character).  Obviously, there is
  5155.     nothing "between" the two characters, so the x variable would be set to ""
  5156.     (an empty string).
  5157.     
  5158.     -------------------
  5159.     Additional Examples
  5160.     -------------------
  5161.     
  5162.     For more examples of the PARSE command, see the demonstrations provided
  5163.     with Parse-O-Matic (type INFO at the DOS prompt, or run INFO.BAT from
  5164.     Windows, then select TUTORIAL).
  5165.     
  5166.                                 ----------------
  5167.                                 The PEEL Command
  5168.                                 ----------------
  5169.     
  5170.     FORMAT:        PEEL  var1 var2   value1 value2 [value3]
  5171.                          :    :      :      :       :
  5172.     MEANING:       Variable   Source From   To      Control
  5173.     
  5174.     PURPOSE:       The PEEL command works just like PARSE, but after setting
  5175.                    var1, it REMOVES the parsed value (including the delimiters)
  5176.                    from var2.
  5177.     
  5178.     PARAMETERS:    var1   is the variable being set
  5179.                    var2   is the source text being read
  5180.                    value1 specifies the starting position (decapsulator)
  5181.                    value2 specifies the ending position (decapsulator)
  5182.                    value3 is the optional control setting
  5183.     
  5184.     DEFAULTS:      value3 = "X"  (See "The PARSE Command" for discussion)
  5185.     
  5186.     When you are breaking up a complex line into fields, PEEL can simplify
  5187.     matters considerably, because the line being interpreted gradually becomes
  5188.     less complex.
  5189.     
  5190.     
  5191.  
  5192.                                                                              85
  5193.     Here is a simple example.  Let's say you have an input file containing a
  5194.     single line:
  5195.     
  5196.     AA/BB/CC/DD
  5197.     
  5198.     If you run this POM file against the input file:
  5199.     
  5200.     PEEL   x $FLINE "" "/"       <-- Strip out the AA and remove the /
  5201.     OUTEND |{x}
  5202.     PEEL   x $FLINE "" "/"       <-- Strip out the BB and remove the /
  5203.     OUTEND |{x}
  5204.     PEEL   x $FLINE "" "/"       <-- Strip out the CC and remove the /
  5205.     OUTEND |{x}
  5206.     OUTEND |{$FLINE}
  5207.     
  5208.     then the output file will look like this:
  5209.     
  5210.     AA
  5211.     BB
  5212.     CC
  5213.     DD
  5214.     
  5215.     What is happening is that $FLINE is gradually being stripped of the text
  5216.     that is being found.  After the first PEEL, $FLINE contains "BB/CC/DD",
  5217.     and so on.  After the final PEEL, $FLINE only contains "DD".
  5218.     
  5219.     -------------------
  5220.     The Control Setting
  5221.     -------------------
  5222.     
  5223.     The "I" and "X" control parameters behave the same way as they do in the
  5224.     PARSE command: they specify whether or not the surrounding text is included
  5225.     in var1.  Take note, however, that the starting and ending characters
  5226.     are always removed from var2, along with the "found" text, regardless of
  5227.     the control parameter.  In other words, the control parameter only affects
  5228.     the first variable (x in the example above), not the second ($FLINE in the
  5229.     example).
  5230.     
  5231.     
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.  
  5246.  
  5247.                                                                              86
  5248.     --------------------
  5249.     Parsing Empty Fields
  5250.     --------------------
  5251.     
  5252.     Consider the following commands:
  5253.     
  5254.     SET   z = ",,,JOHN,SMITH"
  5255.     PEEL  x z "2*," "3*,"
  5256.     
  5257.     There is nothing between the second and third comma, so the x variable
  5258.     is set to "" (an empty string).  After the PEEL command, the z variable
  5259.     will be two commas shorter (",JOHN,SMITH,23.00").  If you are trying to
  5260.     extract data from a comma-delimited line, this is probably not what you
  5261.     want (since it gets rid of two commas).  When taking apart a delimited
  5262.     file, it often makes sense to start peeling from the left side of the
  5263.     string.  Consider these commands:
  5264.     
  5265.     SET   z = ",,,JOHN,SMITH"
  5266.     PEEL  x z "" ","
  5267.     
  5268.     You are asking for everything from the first character to the first
  5269.     comma (which also happens to be the first character).  Obviously, there is
  5270.     nothing "between" the two characters, so the x variable would be set to ""
  5271.     (an empty string).  After the PEEL command, the z variable will be one
  5272.     comma shorter (",,JOHN,SMITH").
  5273.     
  5274.     
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287.  
  5288.  
  5289.  
  5290.  
  5291.  
  5292.  
  5293.  
  5294.  
  5295.  
  5296.  
  5297.  
  5298.  
  5299.  
  5300.  
  5301.  
  5302.                                                                              87
  5303.     --------------------------
  5304.     The Left-Peeling Technique
  5305.     --------------------------
  5306.     
  5307.     You can use the "left-peeling" technique to take apart an entire line.  This
  5308.     is especially useful when interpreting a comma-delimited file.
  5309.     
  5310.     SET   z = ",,MARY,JONES,"
  5311.     PEEL  a z "" ","                 <-- Sets the a variable to ""
  5312.     PEEL  b z "" ","                 <-- Sets the b variable to ""
  5313.     PEEL  c z "" ","                 <-- Sets the c variable to "MARY"
  5314.     PEEL  d z "" ","                 <-- Sets the d variable to "JONES"
  5315.     SET   e = z                      <-- Sets the e variable to ""
  5316.     
  5317.     The e variable is null because there is nothing after the last comma -- in
  5318.     other words, the final field is empty.  If the initial value of the z
  5319.     variable was ",,MARY,JONES,99" then the e variable would be set to "99".
  5320.     
  5321.     ----------------------
  5322.     The Leftover Technique
  5323.     ----------------------
  5324.     
  5325.     Sometimes you are faced with a parsing task in which the input lines are
  5326.     more than 255 characters long, yet there is no way to know where each
  5327.     field begins.  This makes it impossible to use the SPLIT command in the
  5328.     usual way.
  5329.     
  5330.     This type of problem generally arises when processing comma-delimited or
  5331.     tab-delimited files.
  5332.     
  5333.     Here is a sample POM file which handles input lines up to 300 characters
  5334.     long, provided that no field is more than 155 characters long.
  5335.     
  5336.     
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.                                                                              88
  5358.     SPLIT    1-100, 101-200, 201-300   <-- Process input lines in three segments
  5359.     IGNORE   $FLINE = ""               <-- Ignore any splits that yield nothing
  5360.     BEGIN    leftover <> ""            <-- See if we have anything left over
  5361.       APPEND   $FLINE leftover $FLINE  <-- Append what's left over
  5362.       SET      leftover = ""           <-- We've used up the left over data
  5363.     END
  5364.     BEGIN                              <-- Loop through the parts we can extract
  5365.       FINDPOSN x $09                   <-- Look for a tab
  5366.       BEGIN    x <> "0"                <-- See if we found a tab
  5367.         SET      foundtab = "Y"        <-- Yes, we found a tab
  5368.         PEEL     x $FLINE "" #09       <-- Peel away everything up to the tab
  5369.         OUTEND   |{x}                  <-- Process the text we peeled away
  5370.       ELSE
  5371.         SET      foundtab = "N"        <-- No, we didn't find a tab
  5372.         BEGIN    $SPLIT = "3"          <-- See if this is the last of the text
  5373.           OUTEND   |{$FLINE}           <-- Output whatever is left over
  5374.         ELSE
  5375.           SET      leftover = $FLINE   <-- Save this part for the next split
  5376.         END
  5377.       END
  5378.     AGAIN    foundtab = "Y"            <-- Continue if this segment had a tab
  5379.     
  5380.                                 -----------------
  5381.                                 The PEELX Command
  5382.                                 -----------------
  5383.     
  5384.     FORMAT:        PEELX var1 var2   value1 value2 [value3]
  5385.                          :    :      :      :       :
  5386.     MEANING:       Variable   Source From   To      Control
  5387.     
  5388.     PURPOSE:       The PEELX command works just like PEEL, but if it can not find
  5389.                    the delimiters being sought, it sets var1 to var2, and var2
  5390.                    to null.
  5391.     
  5392.     PARAMETERS:    var1   is the variable being set
  5393.                    var2   is the source text being read
  5394.                    value1 specifies the starting position (decapsulator)
  5395.                    value2 specifies the ending position (decapsulator)
  5396.                    value3 is the optional control setting
  5397.     
  5398.     DEFAULTS:      value3 = "X"  (See "The PARSE Command" for discussion)
  5399.     
  5400.     The PEELX command works exactly the same as the PEEL command, except that if
  5401.     it can not find the text being sought (as specified by value1 and value2),
  5402.     it sets var1 to var2 and sets var2 to null.
  5403.     
  5404.     This is very useful when you are stripping away one item at a time from the
  5405.     left side of a string.  For example, let us say you had an input line that
  5406.     contained part numbers arranged like this:
  5407.     
  5408.     A100-34 A100-35 A202-34 A303-35 B143-99 B716-34
  5409.     
  5410.     
  5411.  
  5412.                                                                              89
  5413.     Now let us say that you wanted to output every part number that contained
  5414.     "-34". The obvious choice is to peel off each part number at the space, but
  5415.     the last part number does not have a space after it.  You could take the
  5416.     extra step of appending a space, but PEELX saves you the trouble, as in this
  5417.     example:
  5418.     
  5419.     BEGIN
  5420.       PEELX     word $FLINE "" " "
  5421.       OUTEND    word ^ "-34" |{word}
  5422.     AGAIN $FLINE <> ""
  5423.     
  5424.     The PEELX command strips out the part numbers as "A100-34", "A100-35" and so
  5425.     on, until $FLINE contains only "B716-34".  Then, when PEELX looks for a space,
  5426.     it does not find it.  So it sets the variable "word" to "B716-34" and sets
  5427.     $FLINE to null.
  5428.     
  5429.     
  5430.     
  5431.  
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439.  
  5440.  
  5441.  
  5442.  
  5443.  
  5444.  
  5445.  
  5446.  
  5447.  
  5448.  
  5449.  
  5450.  
  5451.  
  5452.  
  5453.  
  5454.  
  5455.  
  5456.  
  5457.  
  5458.  
  5459.  
  5460.  
  5461.  
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467.                                                                              90
  5468.     ============================================================================
  5469.                                 POSITIONAL COMMANDS
  5470.     ============================================================================
  5471.     
  5472.                                  ------------------
  5473.                                  General Discussion
  5474.                                  ------------------
  5475.     
  5476.     NOTE:  If you are a programmer, you may be tempted to use positional
  5477.            commands even when other Parse-O-Matic commands are more efficient.
  5478.            The positional approach is reminiscent of the parsing strategies
  5479.            used in traditional programming languages, so you may use them
  5480.            because of their familiarity.  The following material discusses
  5481.            this issue, to help you to create shorter, faster POM files.
  5482.     
  5483.     -----------------------------
  5484.     What are Positional Commands?
  5485.     -----------------------------
  5486.     
  5487.     Parse-O-Matic's positional commands let you work with the numeric position
  5488.     of one text string in another.  For example, if the variable xyz contains
  5489.     the value "ABCD":
  5490.     
  5491.     SEARCH   POSITION
  5492.     STRING    IN xyz    COMMENTS
  5493.     ------   --------   -----------------------------------------
  5494.     "A"        "1"      "A" appears in the 1st position of "ABCD"
  5495.     "AB"       "1"
  5496.     "ABCD"     "1"
  5497.     "C"        "3"      "C" appears in the 3rd position of "ABCD"
  5498.     "CD"       "3"
  5499.     "D"        "4"
  5500.     "AC"       "0"      "0" since "AC" does not appear in "ABCD"
  5501.     
  5502.     ----------------------------
  5503.     Why Use Positional Commands?
  5504.     ----------------------------
  5505.     
  5506.     Positional commands give you the precise control you need for certain
  5507.     difficult parsing tasks. For example, if you want to obtain the last three
  5508.     characters of a string of known length (e.g. "ABCDEFG"), the standard
  5509.     approach is:
  5510.     
  5511.     SET abc = "ABCDEFG"
  5512.     SET xyz = abc[5 7]
  5513.     
  5514.     However, if the length of the string is not known, you can not use the
  5515.     substrings in [square brackets].  (To make Parse-O-Matic run as fast as
  5516.     possible for standard parsing jobs, you can not use variables within
  5517.     square brackets.)
  5518.     
  5519.     
  5520.  
  5521.  
  5522.                                                                              91
  5523.     If the length of the string is not known, you can use positional commands
  5524.     to obtain the last three characters.  Here is an example:
  5525.     
  5526.     SET    abc = "Unknown"
  5527.     SETLEN len abc
  5528.     CALC   lenminus = len "-" "2"
  5529.     COPY   xyz abc lenminus len
  5530.     
  5531.     The SETLEN command finds the length (i.e. the last character position) of
  5532.     the abc variable.  In this case, the answer is "7", since "Unknown" is seven
  5533.     characters long.  The CALC command subtracts "2" from this length, setting
  5534.     the lenminus variable to "5".  Finally, the COPY command copies from
  5535.     position "5" to "7", setting the variable xyz to "own" -- the last three
  5536.     characters of the abc variable.
  5537.     
  5538.     -----------------
  5539.     A Cautionary Note
  5540.     -----------------
  5541.     
  5542.     Positional commands are useful for some applications, but many parsing jobs
  5543.     do not require them.  The commands SET, IF, PARSE and PEEL can usually do
  5544.     the same job with less effort. For example, the following approaches are
  5545.     equivalent:
  5546.     
  5547.                  STANDARD APPROACH       POSITIONAL APPROACH
  5548.                  -----------------       ---------------------
  5549.                  SET   abc "AB/CD"       SET      abc = "AB/CD"
  5550.                  PARSE xyz abc "/"       FINDPOSN n abc "/"
  5551.                                          COPY     xyz abc n+
  5552.     
  5553.     The positional approach requires more lines than the standard approach to
  5554.     extracting the characters after the "/" character.  Another problem is that
  5555.     because positional commands give you fine control of the parsing process,
  5556.     it is up to you to guard against exceptional situations.  Consider this
  5557.     example:
  5558.     
  5559.     FINDPOSN x $FLINE "/"
  5560.     CALC     x = x "+" "1"
  5561.     COPY     xyz $FLINE x
  5562.     
  5563.     If $FLINE (the current input line) contains the value "ABC/DEF":
  5564.     
  5565.     FINDPOSN sets x to "4" (the position of the "/" character)
  5566.     CALC     increases x to "5"
  5567.     COPY     sets xyz to "DEF" -- from position "5" to the end of $FLINE
  5568.     
  5569.     Unfortunately, a problem occurs if $FLINE does not contain a slash:
  5570.     
  5571.     FINDPOSN sets x to "0" (meaning the "/" was not found)
  5572.     CALC     increases x to "1"
  5573.     COPY     copies from position "1" to the end of $FLINE
  5574.     
  5575.     
  5576.  
  5577.                                                                              92
  5578.     This may not be what you intended.  If you want to return a null string
  5579.     when $FLINE does not contain a slash, you could use a single PARSE command:
  5580.     
  5581.     PARSE xyz $FLINE "/"
  5582.     
  5583.     This copies anything after the slash to the xyz variable.  If $FLINE does
  5584.     not contain a slash, xyz is set to "".
  5585.     
  5586.     The precise control provided by Parse-O-Matic's positional commands makes
  5587.     them indispensible for certain parsing applications.  Just remember that
  5588.     with added power comes added responsibility:  you will sometimes have to
  5589.     add extra code to handle unusual situations.
  5590.     
  5591.     ---------------------------
  5592.     Negative Positional Indices
  5593.     ---------------------------
  5594.     
  5595.     In most cases, you will use the COPY, DELETE and EXTRACT commands with
  5596.     absolute character positions.  For example:
  5597.     
  5598.     SET      x = "ABCDE"
  5599.     COPY     y x "2" "4"
  5600.     
  5601.     This sets variable y to "BCD".
  5602.     
  5603.     However, sometimes you need to work from the other end (i.e. the right-hand
  5604.     side) of the variable.  For this reason, COPY, DELETE and EXTRACT support
  5605.     negative indices, which count back from the right edge of the variable.
  5606.     
  5607.     For example, let's say you want to find out what the last two characters of
  5608.     a variable are.  You could do it this way:
  5609.     
  5610.     SET      x = "ABCDE"              <-- Sets the variable
  5611.     SETLEN   xlen x                   <-- Finds out how long it is
  5612.     CALC     x1 = xlen "-" "1"        <-- Calculates the 2nd-to-last position
  5613.     COPY     z x x1 xlen              <-- Copies the last two characters
  5614.     
  5615.     This sets the variable z to "DE", which is indeed the last two characters of
  5616.     the x variable.
  5617.     
  5618.     
  5619.  
  5620.  
  5621.  
  5622.  
  5623.  
  5624.  
  5625.  
  5626.  
  5627.  
  5628.  
  5629.  
  5630.  
  5631.  
  5632.                                                                              93
  5633.     An easier method is to use negative positional indices (available in the
  5634.     COPY, DELETE and EXTRACT commands).  In this case, the solution is much
  5635.     simpler:
  5636.     
  5637.     SET      x = "ABCDE"
  5638.     COPY     z x "-2" "-1"
  5639.     
  5640.     This sets the variable z to "DE".  The "from" specification of "-2" means
  5641.     "the second-to-last character".  The "-1" specification means "the last
  5642.     character".  (Strictly speaking, you could omit the "-1", since the default
  5643.     "to" value is "copy to the end of the variable".)
  5644.     
  5645.     In most parsing applications, it is unusual to work from the right-hand side
  5646.     of the variable (see "The Left-Peeling Method" for comparison) because data
  5647.     tends to be read from left to right.  However, negative positional indices
  5648.     do give you some additional flexibility that may be useful in difficult
  5649.     parsing situations.
  5650.     
  5651.                                  ------------------
  5652.                                  The SETLEN Command
  5653.                                  ------------------
  5654.     
  5655.     FORMAT:        SETLEN var1 value1
  5656.     
  5657.     PURPOSE:       SETLEN sets var1 to the length of value1.
  5658.     
  5659.     Here is an example of the SETLEN command:
  5660.     
  5661.     SET    x = "ABCD"
  5662.     SETLEN y x
  5663.     
  5664.     This sets variable y to "4".
  5665.     
  5666.     One handy application for SETLEN is to underline text.  For example:
  5667.     
  5668.     SET      name = $FLINE[1 15]
  5669.     TRIM     name "B" " "
  5670.     SETLEN   nlen name
  5671.     SET      uline = ""
  5672.     PAD      uline "L" "-" nlen
  5673.     OUTEND   |{name}
  5674.     OUTEND   |{uline}
  5675.     
  5676.     If the input line contains the name "JOHN SMITH", the output would be:
  5677.     
  5678.     JOHN SMITH
  5679.     ----------
  5680.     
  5681.     For another example that does underlining, see "POM and Wildcards".
  5682.     
  5683.     
  5684.  
  5685.  
  5686.  
  5687.                                                                              94
  5688.                                  ------------------
  5689.                                  The DELETE Command
  5690.                                  ------------------
  5691.     
  5692.     FORMAT:        DELETE var1 value1 [value2]
  5693.     
  5694.     PURPOSE:       The DELETE command removes a range of characters (specified
  5695.                    as a starting and ending position) from a variable.
  5696.     
  5697.     PARAMETERS:    var1   is the variable from which characters will be removed
  5698.                    value1 is the starting position (e.g. "1" = First character)
  5699.                           can be a negative index ("-3" = 3rd-to-last character)
  5700.                    value2 is the optional ending position; if it is omitted,
  5701.                           it is assumed to mean "the last character in var1"
  5702.                           can be a negative index ("-2" = 2nd-to-last character)
  5703.     
  5704.     NOTES:         If value1 is null or "0", value1 = "1"
  5705.                    If value2 is null or "0", value2 = "last character in var1"
  5706.     
  5707.     ALTERNATIVES:  The PEEL, TRIM, CHANGE, SET and APPEND commands
  5708.     
  5709.     Here is an example of the DELETE command:
  5710.     
  5711.     SET    x = "ABC///DEF"
  5712.     DELETE x "4" "6"
  5713.     
  5714.     This deletes from position 4 to 6, so the variable x is set to "ABCDEF".
  5715.     
  5716.     If value2 is omitted, DELETE assumes you wish to delete everything from
  5717.     the starting position to the end of the string.  For example:
  5718.     
  5719.     SET    x = "ABC///DEF"
  5720.     DELETE x "4"
  5721.     
  5722.     This sets x to "ABC".
  5723.     
  5724.     
  5725.  
  5726.  
  5727.  
  5728.  
  5729.  
  5730.  
  5731.  
  5732.  
  5733.  
  5734.  
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740.  
  5741.  
  5742.                                                                              95
  5743.                                   ----------------
  5744.                                   The COPY Command
  5745.                                   ----------------
  5746.     
  5747.     FORMAT:        COPY var1 value1 value2 [value3]
  5748.     
  5749.     PURPOSE:       The COPY command copies a range of characters (specified as
  5750.                    a starting and ending position) from a value to a variable.
  5751.     
  5752.     PARAMETERS:    var1   is the variable being set
  5753.                    value1 is the source value, from which you will copy text
  5754.                    value2 is the starting position (e.g. "1" = First character)
  5755.                           can be a negative index ("-3" = 3rd-to-last character)
  5756.                    value3 is the optional ending position; if it is omitted,
  5757.                           it is assumed to mean "the last character in value1"
  5758.                           can be a negative index ("-2" = 2nd-to-last character)
  5759.     
  5760.     NUMERICS:      Tabs, spaces and commas are stripped from value2 and value3
  5761.     
  5762.     NOTES:         If value2 is null or "0", value1 = "1"
  5763.                    If value3 is null or "0", value3 = "last char in value1"
  5764.     
  5765.     ALTERNATIVES:  The SET command
  5766.     
  5767.     Here is an example of the COPY command:
  5768.     
  5769.     SET    x = "ABC///DEF"
  5770.     COPY   y x "4" "6"
  5771.     
  5772.     This copies from position 4 to 6, so the variable y is set to "///".
  5773.     
  5774.     If value2 is omitted, COPY assumes you wish to copy everything from the
  5775.     starting position to the end of the string.  For example:
  5776.     
  5777.     SET    x = "ABC///DEF"
  5778.     COPY   y x "4"
  5779.     
  5780.     This sets y to "///DEF".
  5781.     
  5782.     To make your POM files easier to read, you might consider padding the
  5783.     COPY command with an equals sign to remind you that a variable is being
  5784.     set. For example:
  5785.     
  5786.     COPY   y = x "4" "6"
  5787.     
  5788.     This emphasizes that the variable y is being set to a substring of x.
  5789.     For more information about padding, see "Padding for Clarity".
  5790.     
  5791.     
  5792.  
  5793.  
  5794.  
  5795.  
  5796.  
  5797.                                                                              96
  5798.                                 -------------------
  5799.                                 The EXTRACT Command
  5800.                                 -------------------
  5801.     
  5802.     FORMAT:        EXTRACT var1 var2 value1 [value2]
  5803.     
  5804.     PURPOSE:       The EXTRACT command works like COPY, but removes the
  5805.                    characters from the source variable after copying them to
  5806.                    a variable.
  5807.     
  5808.     PARAMETERS:    var1   is the variable that will contain the characters
  5809.                           extracted from var2
  5810.                    var2   is the variable from which characters will be copied
  5811.                           to var1, then removed
  5812.                    value1 is the starting position (e.g. "1" = First character)
  5813.                           can be a negative index ("-3" = 3rd-to-last character)
  5814.                    value2 is the optional ending position; if it is omitted,
  5815.                           it is assumed to mean "the last character in var2"
  5816.                           can be a negative index ("-2" = 2nd-to-last character)
  5817.     
  5818.     NUMERICS:      Tabs, spaces and commas are stripped from value1 and value2
  5819.     
  5820.     NOTES:         If value1 is null or "0", value1 = "1"
  5821.                    If value2 is null or "0", value2 = "last character in var2"
  5822.     
  5823.     ALTERNATIVES:  The PEEL command
  5824.     
  5825.     Here is an example of the EXTRACT command:
  5826.     
  5827.     SET     x = "ABC///DEF"
  5828.     EXTRACT y x "4" "6"
  5829.     
  5830.     This copies from position 4 to 6, so the variable y is set to "///".
  5831.     The characters copied to variable y are removed from x, so that it now
  5832.     contains the value "ABCDEF".
  5833.     
  5834.     If value2 is omitted, EXTRACT assumes you wish to extract everything from
  5835.     the starting position to the end of the string.  For example:
  5836.     
  5837.     SET     x = "ABC///DEF"
  5838.     EXTRACT y x "4"
  5839.     
  5840.     This sets y to "///DEF", while the variable x is set to "ABC" (i.e. the
  5841.     original value for x, with the extracted characters removed).
  5842.     
  5843.     
  5844.  
  5845.  
  5846.  
  5847.  
  5848.  
  5849.  
  5850.  
  5851.  
  5852.                                                                              97
  5853.                                 --------------------
  5854.                                 The FINDPOSN Command
  5855.                                 --------------------
  5856.     
  5857.     FORMAT:        FINDPOSN var1 value1 value2 [value3 [value4]]
  5858.                             :    :      :       :       :
  5859.     MEANING:       1) Variable   Source Find    :       :
  5860.                    2) Variable   Source From    To      Control
  5861.     
  5862.     PURPOSE:       The FINDPOSN command finds one text string in another.  It
  5863.                    locates the starting or ending position of a string, or
  5864.                    a string delimited by one or two other strings.
  5865.     
  5866.     PARAMETERS:    var1   is the variable that will contain the position if
  5867.                           the string is found (e.g. "2" means it was found
  5868.                           in the second position of value1; "0" means the
  5869.                           string was not found)
  5870.                    value1 is the string being searched
  5871.                    value2 is the string being sought, or...
  5872.                              the left-most part of a string being sought
  5873.                    value3 is the right-most part of the string being sought;
  5874.                              if it is set to null (""), it is assumed to mean
  5875.                              "the last character in value1"
  5876.                    value4 is the control setting
  5877.     
  5878.     DEFAULTS:      value4 = "IS"
  5879.     
  5880.     ALTERNATIVES:  The SCANPOSN command
  5881.     
  5882.     SEE ALSO:      This section is much easier to understand if you have
  5883.                    studied "The Parse Command".
  5884.     
  5885.     There are two ways to use the FINDPOSN command:  the "Plain String Find"
  5886.     and the "Embedded String Find".  These are discussed below.
  5887.     
  5888.     ---------------------
  5889.     The Plain String Find
  5890.     ---------------------
  5891.     
  5892.     In its simplest form, the Plain String Find locates a string (value2) in
  5893.     another string (value1) and assigns its position to a variable (var1).
  5894.     Here is an example:
  5895.     
  5896.     FINDPOSN x $FLINE "Fred"
  5897.     
  5898.     This looks for the first occurrence of "Fred" in $FLINE (the current input
  5899.     line).  If $FLINE contains "Hello Fred!", the command will set the variable
  5900.     x to "7", since "Fred" starts in the seventh character position.
  5901.     
  5902.     
  5903.  
  5904.  
  5905.  
  5906.  
  5907.                                                                              98
  5908.     ---------------------------
  5909.     Using a Single Decapsulator
  5910.     ---------------------------
  5911.     
  5912.     Sometimes  you don't want to find the FIRST occurrence, but the second,
  5913.     third, and so on.  You can use a single decapsulator (see "The Parse
  5914.     Command") to specify this.  For example:
  5915.     
  5916.     SET      z = "This is the way to demonstrate the FINDPOSN command"
  5917.     FINDPOSN x z "the"
  5918.     FINDPOSN y z "2*the"
  5919.     
  5920.     The first FINDPOSN command finds the first occurrence of "the", using a
  5921.     plain string, so it sets the variable x to "9", since the first "the"
  5922.     starts in the ninth position.
  5923.     
  5924.     The second FINDPOSN command uses a decapsulator with the occurrence number
  5925.     "2*", which means "look for the second occurrence".  Thus, it sets the
  5926.     variable y to "32", since the second "the" occurs in that position.
  5927.     
  5928.     Incidentally, the first FINDPOSN could also have been written this way:
  5929.     
  5930.     FINDPOSN x z "1*the"
  5931.     
  5932.     which is another way of saying, "Look for the first occurrence".  However,
  5933.     if no occurrence number is specified, FINDPOSN assumes you are looking for
  5934.     the first occurrence.
  5935.     
  5936.     ----------------------------
  5937.     The Encapsulated String Find
  5938.     ----------------------------
  5939.     
  5940.     NOTE:  The Encapsulated String Find is very similar to the PARSE command.
  5941.            If you do not find the following discussion sufficiently
  5942.            instructive, you can gain some additional insight by reading the
  5943.            section of this manual entitled "The Parse Command".
  5944.     
  5945.     The Encapsulated String Find looks for a string that is encapsulated by
  5946.     (i.e. located between) two other strings.  This is useful if your input
  5947.     data contains text that is surrounded by delimiters.  One common example is
  5948.     the "comma-delimited" file (see "Why You Need Parse-O-Matic -- An Example"
  5949.     for a sample).  Here is another situation where data is surrounded by
  5950.     delimiters:
  5951.     
  5952.     
  5953.  
  5954.  
  5955.  
  5956.  
  5957.  
  5958.  
  5959.  
  5960.  
  5961.  
  5962.                                                                              99
  5963.     |Mouse |Gazelle|Mouse  |Elephant|
  5964.     |Dog   |Giraffe|Elk    |Mongoose|
  5965.     |Monkey|Snake  |Caribou|Trout   |
  5966.     
  5967.     One can imagine an application that would create tabular data like this --
  5968.     cleverly (but annoyingly) reducing the column widths to the minimum.  This
  5969.     would make the column starting and ending positions unpredictable.
  5970.     
  5971.     You could use the PARSE command to obtain values from each column, but if
  5972.     you have a lot of data, it would be more efficient to determine the
  5973.     starting and ending positions at the outset.
  5974.     
  5975.     Let's say you wanted to extract the third column.  You could set up your
  5976.     POM file like this:
  5977.     
  5978.     BEGIN startposn = ""
  5979.       FINDPOSN startposn $FLINE "3*|" "4*|" "XS"
  5980.       FINDPOSN endposn   $FLINE "3*|" "4*|" "XE"
  5981.       HALT     startposn = "0" "Missing delimiter!"
  5982.     END
  5983.     COPY animal $FLINE startposn endposn
  5984.     OUTEND |{animal}
  5985.     
  5986.     The lines between the BEGIN and END are run only once for the entire
  5987.     parsing job, since they set the startposn variable to something other than
  5988.     a null ("") string.  (See "Uninitialized and Persistent Variables")
  5989.     
  5990.     The first FINDPOSN command uses the decapsulators "3*|" and "4*|" to locate
  5991.     the text between the third and fourth "|" delimiters, but because of the
  5992.     "XS" control value (described later), startposn is set to the position
  5993.     AFTER the delimiter. (Briefly, "XS" means "exclude the found text, and
  5994.     refer to the starting position of the text that follows it.)  Thus, the
  5995.     variable startposn is set to "12"; "Mouse" starts in the twelfth position.
  5996.     
  5997.     The second FINDPOSN command sets the ending position (endposn) in a similar
  5998.     way.  It finds the third and fourth "|" delimiters, but because of the "XE"
  5999.     control setting, it sets endposn to the position BEFORE the fourth
  6000.     delimiter. (Briefly, "XE" means "exclude the found text, and refer to the
  6001.     ending position of the text that precedes it.)
  6002.     
  6003.     The HALT command is simply a safeguard to ensure that the input data
  6004.     follows the correct format.  If the first FINDPOSN fails to find the
  6005.     third or fourth "|" delimiter, it will set startposn to "0" (meaning "not
  6006.     found").
  6007.     
  6008.     The COPY command copies $FLINE (the current input line) from the starting
  6009.     position (startposn) to the ending position (endposn).  This value is then
  6010.     output by the OUTEND command.
  6011.     
  6012.     
  6013.  
  6014.  
  6015.  
  6016.  
  6017.                                                                             100
  6018.     ----------------
  6019.     Control Settings
  6020.     ----------------
  6021.     
  6022.     The control settings give you precise control of the part of the string
  6023.     to which you are referring.  Valid control settings are:
  6024.     
  6025.     SETTING  MEANING
  6026.     -------  -------
  6027.       IS     Include found text and report where the  entire   text starts
  6028.       IE     Include found text and report where the  entire   text ends
  6029.       XS     Exclude found text and report where the delimited text starts
  6030.       XE     Exclude found text and report where the delimited text ends
  6031.     
  6032.     NOTE:  While FINDPOSN greatly resembles the PARSE command, the default
  6033.            control setting is different.  In PARSE, the control setting is
  6034.            assumed to be "X" if it is omitted.  In FINDPOSN, however, the
  6035.            control setting is assumed to be "IS" if it is omitted.
  6036.     
  6037.     Let us assume that the we set the variable z as follows:
  6038.     
  6039.     SET z = "ABzzzCDEFzzzGH"
  6040.     
  6041.     This produces the following results:
  6042.     
  6043.             COMMAND                            VALUE FOR x VARIABLE
  6044.             ---------------------------------  --------------------
  6045.             FINDPOSN x z "1*zzz" "2*zzz" "IS"           "3"
  6046.             FINDPOSN x z "1*zzz" "2*zzz" "XS"           "6"
  6047.             FINDPOSN x z "1*zzz" "2*zzz" "XE"           "9"
  6048.             FINDPOSN x z "1*zzz" "2*zzz" "IE"          "12"
  6049.     
  6050.     The following illustration may make the results easier to understand:
  6051.     
  6052.     +------------------------------------------------------------------------+
  6053.     |                                                                        |
  6054.     | Measuring Scale:             12345678901234                            |
  6055.     |                              --------------                            |
  6056.     |         Command: FINDPOSN x "ABzzzCDEFzzzGH" "zzz" "2*zzz" "<control>" |
  6057.     |                                |  |  |  |                              |
  6058.     |   Control Value:              IS XS XE IE                              |
  6059.     |         Results:               3  6  9 12                              |
  6060.     |                                                                        |
  6061.     +------------------------------------------------------------------------+
  6062.     
  6063.     In the example, the control values have the following specific meanings:
  6064.     
  6065.     "IS" ("Include, Start") = start of entire text (from "1*zzz" to "2*zzz")
  6066.     "XS" ("Exclude, Start") = start of text after  the "from" item ("1*zzz")
  6067.     "XE" ("Exclude, End")   =  end  of text before the  "to"  item ("2*zzz")
  6068.     "IE" ("Include, End")   =  end  of entire text (from "1*zzz" to "2*zzz")
  6069.     
  6070.     
  6071.  
  6072.                                                                             101
  6073.     ------------------
  6074.     Insoluble Searches
  6075.     ------------------
  6076.     
  6077.     FINDPOSN returns "0" (zero) when it can not find a string, or if it is
  6078.     presented with an insoluble dilemma.  Here are some examples:
  6079.     
  6080.     FINDPOSN x "CatDog" "Moose"        <-- "Moose" can not be found
  6081.     FINDPOSN x "ABCDEF" "A" "G"        <-- "G" can not be found
  6082.     FINDPOSN x "ABCDEF" "A" "2*E"      <-- There is no second "E"
  6083.     
  6084.     Here is another insoluble search:
  6085.     
  6086.     FINDPOSN x "ABCDEF" "C" "D" "XS"
  6087.     FINDPOSN x "ABCDEF" "C" "D" "XE"
  6088.     
  6089.     There is nothing between the "from" and "to" delimiters. Since we are
  6090.     excluding the delimiters themselves (with "XS" and "XE" specifications), we
  6091.     can not provide a "start" or "end" value for what we found -- we didn't
  6092.     find anything!  Hence, we have nothing for which to return a starting or
  6093.     ending position.
  6094.     
  6095.     ------------------
  6096.     Null Decapsulators
  6097.     ------------------
  6098.     
  6099.     Consider these next two commands:
  6100.     
  6101.     FINDPOSN x "ABCDEF" "F" "" "XS"
  6102.     FINDPOSN x "ABCDEF" "F" "" "XE"
  6103.     
  6104.     What comes between "F" and the end of the string?  Bear in mind, however,
  6105.     that when you use a null ("") to mean "the last character", it is not
  6106.     excluded (see "The Null Decapsulator" in the section entitled "The Parse
  6107.     Command", for a discussion).  Thus, the two FINDPOSN commands "find" the
  6108.     final character "F", and both return "6".
  6109.     
  6110.     These both return "6" because the "F" is both the starting and ending
  6111.     position of what we found, and we included (rather than excluded) the
  6112.     starting and ending delimiters ("F" and the last character, respectively).
  6113.     
  6114.     Similarly, the following commands return a "1":
  6115.     
  6116.     FINDPOSN x "ABCDEF" "" "A" "XS"
  6117.     FINDPOSN x "ABCDEF" "" "A" "XE"
  6118.     
  6119.     Even though there is nothing between "A" and "the first character", the
  6120.     first character is not excluded, since we are using a null decapsulator.
  6121.     As a result, we find the string "A" and return its position, which is "1".
  6122.     
  6123.     
  6124.  
  6125.  
  6126.  
  6127.                                                                             102
  6128.     ---------------------
  6129.     Finding The Last Word
  6130.     ---------------------
  6131.     
  6132.     One common use for FINDPOSN is to find the last occurrence of a word in a
  6133.     line of text.  Consider the following lines:
  6134.     
  6135.     SET       z = "Parse-O-Matic is a fine product!"
  6136.     FINDPOSN  x z ">* " "" "XS"
  6137.     
  6138.     This will set the x variable to 25 (the position of the final word).  The
  6139.     command looks for the last "space" character (which is in position 24),
  6140.     then (because of the "XS" control) returns the position of the character
  6141.     following it.
  6142.     
  6143.     ---------------
  6144.     Who Needs This?
  6145.     ---------------
  6146.     
  6147.     At this point, you may be wondering, "Why do I need to have this kind of
  6148.     precise control?"  Well, in most cases you don't, so you will tend to use
  6149.     the "Plain String Find" (described earlier).  However, certain complex
  6150.     parsing applications demand that you make a distinction between the text
  6151.     that encapsulates a piece of text, and the encapsulated text itself.  When
  6152.     faced with this kind of task, you will see that Parse-O-Matic's FINDPOSN
  6153.     command lets you accomplish in one line what would take dozens of lines in
  6154.     a traditional programming language.
  6155.     
  6156.     
  6157.  
  6158.  
  6159.  
  6160.  
  6161.  
  6162.  
  6163.  
  6164.  
  6165.  
  6166.  
  6167.  
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181.  
  6182.                                                                             103
  6183.                                 --------------------
  6184.                                 The SCANPOSN Command
  6185.                                 --------------------
  6186.     
  6187.     FORMAT:        SCANPOSN var1 var2 value1 value2 [value3]
  6188.                             :    :    :      :        :
  6189.     MEANING:                from to   source scanlist control
  6190.     
  6191.     PURPOSE:       SCANPOSN searches the source value for one of the scanterms
  6192.                    in the scanlist (see "Terminology", below).  SCANPOSN finds
  6193.                    out which scanterm provides the best match, then returns the
  6194.                    "from" (starting) and "to" (ending) positions of that
  6195.                    scanterm in the source value.
  6196.     
  6197.     TERMINOLOGY:   scanterm  An item in a scanlist; one of the things you are
  6198.                              searching the source value for.
  6199.                    scanlist  A list of scanterms.  Here is an example of a
  6200.                              scanlist:  "/Mr/Mrs/Ms"
  6201.     
  6202.     PARAMETERS:    var1   is the variable that will contain the starting
  6203.                           position if one of the scanterms is found (e.g. "2"
  6204.                           means it was found in the second position of value1;
  6205.                           "0" means SCANPOSN did not find any of the scanterms)
  6206.                    var2   is the variable that will contain the ending position
  6207.                           if one of the scanterms is found
  6208.                    value1 is the source string -- the string being searched
  6209.                    value2 is the scanlist (see "Terminology", above)
  6210.                    value3 is the optional control string
  6211.     
  6212.     DEFAULTS:      value3 = "I" (i.e. Ignore case)
  6213.     
  6214.     ALTERNATIVES:  The FINDPOSN command
  6215.     
  6216.     A common requirement in parsing is to find out if one of several strings can
  6217.     be found in another string.  For example, you might want to find out if a
  6218.     name starts with a "salutation" (Mr., Mrs., Ms.).  You can do this by looping
  6219.     through the various strings and comparing each one, but SCANPOSN lets you do
  6220.     all this with a single command.
  6221.     
  6222.     For example, to search for a salutation in a string:
  6223.     
  6224.     SCANPOSN from to $FLINE "/Mr./Mrs./Miss/Ms."
  6225.     
  6226.     If $FLINE (the line just read from the input file) contains one of the
  6227.     scanterms in the scanlist, SCANPOSN will set the "from" and "to" variables.
  6228.     Thus, if $FLINE contains "Ms. Mary Jones", the "from" variable is set to "1"
  6229.     and the "to" variable is set to "3" (since "Ms." goes from positions 1 to 3
  6230.     in $FLINE).
  6231.     
  6232.     If none of the scanterms is found, the "from" variable is set to "0".  Thus,
  6233.     if $FLINE contains "John Smith", no salutation is found, and the SCANPOSN
  6234.     command shown above will set the "from" variable to "0".
  6235.     
  6236.  
  6237.                                                                             104
  6238.     ------------
  6239.     The Scanlist
  6240.     ------------
  6241.     
  6242.     The scanlist can contain one or more scanterms.  The FIRST character in the
  6243.     scanlist is interpreted as the delimiter (separator) for the scanterms.
  6244.     Thus, the following scanlists are all valid:
  6245.     
  6246.     "/Mr./Mrs./Miss/Ms."                          <-- Delimiter is:   /
  6247.     "xMr.xMrs.xMissxMs."                          <-- Delimiter is:   x
  6248.     "@Library@School@Gymnasium@Clinic/Hospital"   <-- Delimiter is:   @
  6249.     "/Cow"                                        <-- Delimiter is:   /
  6250.     
  6251.     The first example ("/Mr./Mrs./Miss/Ms.") has already been demonstrated.  The
  6252.     second example uses the letter "x" as a delimiter.  This would cause a
  6253.     problem if one of the scanterms contained an "x", since it would be treated
  6254.     as TWO scanterms.  For example:
  6255.     
  6256.     "xJohnxTrixiexFred"
  6257.     
  6258.     The name "Trixie" contains an "x", so it would be broken down into two
  6259.     scanterms ("Tri" and "ie").  You should always choose a scanlist delimiter
  6260.     that does not appear in the list of scanterms.
  6261.     
  6262.     -----------------------
  6263.     Accommodating Variation
  6264.     -----------------------
  6265.     
  6266.     When you design a scanlist, you should take into account the possibility
  6267.     that the input might contain strange variations.  Consider this command:
  6268.     
  6269.     SCANPOSN x y "Mr John Smith" "/Mr./Mrs./Ms."
  6270.     
  6271.     This will set the x variable to "0" because the "Mr" is followed by a space,
  6272.     not a period.  A more "forgiving" command would be:
  6273.     
  6274.     SCANPOSN x y "Mr John Smith" "/Mr./Mrs./Ms./Mr /Mrs /Ms "
  6275.     
  6276.     This would successfully locate the "Mr " string, and set x to "1" and y to
  6277.     "3". (The "3" points to the space.)
  6278.     
  6279.     
  6280.  
  6281.  
  6282.  
  6283.  
  6284.  
  6285.  
  6286.  
  6287.  
  6288.  
  6289.  
  6290.  
  6291.  
  6292.                                                                             105
  6293.     ------------------------------
  6294.     Handling Prefixes and Suffixes
  6295.     ------------------------------
  6296.     
  6297.     When designing a scanlist, you should consider that a scanterm might be
  6298.     part of a word.  For example:
  6299.     
  6300.     SCANPOSN x y "Mississipi Sue" "/MR./MRS./MISS/MS."
  6301.     
  6302.     This will find the "Miss" in Mississippi, even though this is not part of
  6303.     a salutation.  A more appropriate command would be:
  6304.     
  6305.     SCANPOSN x y "Mississipi Sue" "/MR./MRS./MISS /MS."
  6306.     
  6307.     The space after "Miss" in the scanlist ensures that if it is found, it will
  6308.     be separate from any word following it.
  6309.     
  6310.     The trailing space is not necessary for the scanterm "MR.", since no word
  6311.     contains a period.  However, if you do include spaces after the periods
  6312.     (as in "/MR. /MRS. /MISS /MS. ") it may simplify your subsequent parsing
  6313.     operations.
  6314.     
  6315.     You must also take suffixes into account.  For example:
  6316.     
  6317.     SCANPOSN x y "Zinc Enterprises" "/INC/CO/ENTERPRISES"
  6318.     
  6319.     This will find the "inc" in "Zinc".  You can add a space in front of each
  6320.     scanterm to ensure that it is separated from any other word:
  6321.     
  6322.     SCANPOSN x y "Zinc Enterprises" "/ INC/ CO/ ENTERPRISES"
  6323.     
  6324.     You may be tempted to put spaces on both sides of a word, to handle both
  6325.     prefixes and suffixes.  However, consider this example:
  6326.     
  6327.     SCANPOSN x y "Wazoo Inc" "/ INC / CO / ENTERPRISES "
  6328.     
  6329.     None of the scanterms is found, because the "Inc" in the source string
  6330.     does not end in a space.  You can address this kind of problem with the
  6331.     control settings (described next).
  6332.     
  6333.     ----------------------
  6334.     Controlling the Search
  6335.     ----------------------
  6336.     
  6337.     Unless otherwise instructed, SCANPOSN will find the first scanterm that
  6338.     appears anywhere in the source string, and return its start and end
  6339.     positions.  You can modify this behavior by using the optional control
  6340.     parameter (value3).
  6341.     
  6342.     The control parameter contains one or more characters, each of which has
  6343.     a special meaning.
  6344.     
  6345.     
  6346.  
  6347.                                                                             106
  6348.     CHARACTER   MEANING
  6349.     ---------   -------
  6350.        <        Find the leftmost match
  6351.        >        Find the rightmost match
  6352.        I        Ignore case (e.g. Xyz matches XYZ)
  6353.        M        Match case (e.g. Xyz does not match XYZ)
  6354.     
  6355.     Here are some valid control settings:
  6356.     
  6357.     SETTING   MEANING
  6358.     -------   -------
  6359.      "<M"     Find the leftmost match, which much match case
  6360.      "<I"     Find the leftmost match, ignoring case
  6361.      ">M"     Find the rightmost match, which must match case
  6362.      "M"      Find any match, but the case must be the same
  6363.     
  6364.     NOTES:  If neither "I" nor "M" are specified, SCANPOSN assumes "I".
  6365.             If neither "<" nor ">" are specified, SCANPOSN does a "Find-Any"
  6366.             search (explained below).
  6367.     
  6368.     -----------------------------
  6369.     Leftmost, Rightmost, Find-Any
  6370.     -----------------------------
  6371.     
  6372.     The ">" (rightmost) control setting tells SCANPOSN to find the scanterm that
  6373.     has the highest "to" value with the lowest "from" value.  This means that
  6374.     ALL of the scanterms are evaluated.  Consider this command:
  6375.     
  6376.     SCANPOSN x y "SHREWxxxCATxxxMOUSExxx" "/CAT/DOGGY/MOUSE/ELK" ">"
  6377.     
  6378.     SCANPOSN finds "CAT", but continues looking to see if there are any better
  6379.     matches to the right.  Eventually it finds MOUSE and sets x to "15" and y
  6380.     to "19" (pointing at "MOUSE").
  6381.     
  6382.     If you use the "<" (leftmost) parameter, SCANPOSN will check all the
  6383.     scanterms to find out which one has the lowest "from" position with the
  6384.     highest "to" value.
  6385.     
  6386.     SCANPOSN x y "SHREWxxxCATxxxMOUSExxx" "/CAT/DOGGY/MOUSE/ELK" "<"
  6387.     
  6388.     This will set x to "9" and y to "11" (pointing at "CAT").
  6389.     
  6390.     If you do not specify "<" or ">", SCANPOSN finds the first scanterm it can,
  6391.     and ignores the rest.
  6392.     
  6393.     SCANPOSN x y "SHREWxxxCATxxxMOUSExxx" "/CAT/DOGGY/MOUSE/ELK"
  6394.     
  6395.     The first scanterm is "CAT", and this can be found at positions 9 to 11.
  6396.     SCANPOSN will return those values, and ignore the rest of the scanterms.
  6397.     
  6398.     The absence of a "<" or ">" is known as a "Find-Any" search.  You can use
  6399.     this if you want to know if one of the scanterms appears in the source
  6400.     string, but you are not interested in finding out which one.
  6401.  
  6402.                                                                             107
  6403.     ------------------------
  6404.     The Best Match Principle
  6405.     ------------------------
  6406.     
  6407.     NOTE:  The "Best Match" principle does not apply to the "Find-Any" search.
  6408.            It applies only to the Leftmost ("<") and Rightmost (">") searches.
  6409.     
  6410.     To use the SCANPOSN command effectively, you must understand the concept of
  6411.     "the best match".  This can be illustrated with an example:
  6412.     
  6413.     SCANPOSN x y "MegaWhizco International" "/CO/WHIZCO/MEGAWHIZ" ">"
  6414.     
  6415.     The SCANPOSN command finds the scanterm CO at positions 5 to 6.  However, it
  6416.     continues looking for an even better match.
  6417.     
  6418.     It finds that WHIZCO is just as far to the right (i.e. it ends at position
  6419.     6), but has a lower starting position.  This makes it a "better" match.
  6420.     
  6421.     The next scanterm (MEGAWHIZ) has a lower starting position, but its ending
  6422.     position is not as good (i.e. not as far to the right).  It is rejected
  6423.     because we are looking for the rightmost string.
  6424.     
  6425.     As a result, SCANPOSN will set x to "1" and y to "6".
  6426.     
  6427.     In other words, when SCANPOSN is looking for the rightmost scanterm, it will
  6428.     first identify the "found" scanterms which have the highest ending position,
  6429.     and then choose the longest one.
  6430.     
  6431.     Here is an example using a leftmost search:
  6432.     
  6433.     SCANPOSN x y "Our catalog is enclosed" "CAT/MOOSE/CATALOG/DOG" "<"
  6434.     
  6435.     The SCANPOSN finds CAT at positions 5 to 7, but as it continues checking
  6436.     the scanterms, it finds that CATALOG is just as far to the left (i.e. it
  6437.     starts at position 5), but it is a better match since it has a higher ending
  6438.     position.
  6439.     
  6440.     As a result, SCANPOSN will set x to "5" and y to "11".
  6441.     
  6442.     The "Best Match" principle does not affect "Find-Any" searches.  For
  6443.     example:
  6444.     
  6445.     SCANPOSN x y "Our catalog is enclosed" "CAT/MOOSE/CATALOG/DOG"
  6446.     
  6447.     This sets x to "5" and y to "7".  Since this is a "Find-Any" search (i.e.
  6448.     neither "<" nor ">" are specified in the control settings), SCANPOSN stops
  6449.     looking as soon as it has found a match.
  6450.     
  6451.     
  6452.  
  6453.  
  6454.  
  6455.  
  6456.  
  6457.                                                                             108
  6458.     When doing a Find-Any search, you can not be sure if any of the other scan
  6459.     terms appear in the source string.  For example:
  6460.     
  6461.     SCANPOSN x y "Our cat and dog are upstairs" "CAT/DOG"
  6462.     
  6463.     This will find CAT and stop looking for additional matches.  If you change
  6464.     the order of the scanlist, you will get different values:
  6465.     
  6466.     SCANPOSN x y "Our cat and dog are upstairs" "DOG/CAT"
  6467.     
  6468.     Thus, a Find-Any search is useful only for detecting if one of the scanterms
  6469.     appears in the source string.  After doing a Find-Any search, you can check
  6470.     if the "from" value is "0" (meaning no scanterms were found).  If it is not
  6471.     "0", it means one of the terms WAS found.  For example:
  6472.     
  6473.     SET      source   = "Our cat catalog is enclosed"
  6474.     SET      scanlist = "CATALOG/MOOSE/CAT/DOG"
  6475.     SCANPOSN from to source scanlist
  6476.     BEGIN    from = "0"
  6477.       OUTEND  |None of the scanterms appeared in the string {source}
  6478.     ELSE
  6479.       OUTEND  |At least one of the scanterms appears in the string {source}
  6480.     END
  6481.     
  6482.     
  6483.     
  6484.  
  6485.  
  6486.  
  6487.  
  6488.  
  6489.  
  6490.  
  6491.  
  6492.  
  6493.  
  6494.  
  6495.  
  6496.  
  6497.  
  6498.  
  6499.  
  6500.  
  6501.  
  6502.  
  6503.  
  6504.  
  6505.  
  6506.  
  6507.  
  6508.  
  6509.  
  6510.  
  6511.  
  6512.                                                                             109
  6513.     ============================================================================
  6514.                                    DATE COMMANDS
  6515.     ============================================================================
  6516.     
  6517.                                  ------------------
  6518.                                  General Discussion
  6519.                                  ------------------
  6520.     
  6521.     Parse-O-Matic's date-oriented commands provide you with a convenient way to
  6522.     work with dates.  While you can accomplish the same thing using other
  6523.     Parse-O-Matic commands (LOOKUP, PAD etc.), the date functions are optimized
  6524.     for speed, so if your parsing job does a lot of date-format conversions, it
  6525.     will run faster.
  6526.     
  6527.     --------------------
  6528.     The POMDATE.CFG File
  6529.     --------------------
  6530.     
  6531.     When a date command is first executed, Parse-O-Matic reads in a file named
  6532.     POMDATE.CFG.  (The method by which Parse-O-Matic finds the file is
  6533.     discussed in the section "How Parse-O-Matic Searches for a File".)
  6534.     
  6535.     POMDATE.CFG is a self-documenting text file that contains the default
  6536.     date format string (explained later), and the names of the twelve months.
  6537.     You can edit this file with a standard text editor, or a word-processor in
  6538.     "generic text" mode.
  6539.     
  6540.     As originally supplied with Parse-O-Matic, the default date format string
  6541.     is "?y/?n/?d", which produces YY/MM/DD dates (e.g. July 1 1998 becomes
  6542.     98/07/01). You can change this to reflect your own preference.
  6543.     
  6544.     If you are parsing data in a language other than English, you can also
  6545.     change the names of the months.
  6546.     
  6547.     ------------
  6548.     Date Formats
  6549.     ------------
  6550.     
  6551.     A date format is a sequence of characters that briefly describes the
  6552.     appearance of a date.  For example, the format "Y-T-?n" describes a
  6553.     year/month/day format that looks like this:  1998-JULY-02
  6554.     
  6555.     The following characters have a special meaning in the date format
  6556.     string:  d M m n T t Y y ?
  6557.     
  6558.     For these special characters, uppercase and lowercase are important.
  6559.     For example, "T" is not the same as "t".
  6560.     
  6561.     All characters other than the special characters are interpreted "as-is",
  6562.     and are included in the final date string.
  6563.     
  6564.     
  6565.  
  6566.  
  6567.                                                                             110
  6568.     The following table explains the meaning of the special characters used
  6569.     to specify year, month and day, using the date July 2, 1998 for the
  6570.     examples:
  6571.     
  6572.          CHAR  MEANING                     SAMPLE FORMAT  SAMPLE RESULT
  6573.          ----  --------------------------  -------------  -------------
  6574.           Y    4-digit year                d-m-Y          2-Jul-1998
  6575.           y    1- or 2-digit year          d-m-y          2-Jul-98
  6576.           n    1- or 2-digit month         d/n/y          2/7/98
  6577.           m    3-letter month              d/m/y          2/Jul/98
  6578.           M    3-letter month (uppercase)  d M y          2 JUL 98
  6579.           t    Month                       t d, Y         July 2, 1998
  6580.           T    Month (uppercase)           T d Y          JULY 2 1998
  6581.           d    Day                         y/m/d          98/7/2
  6582.     
  6583.     The ? character can be used in the date format to pad out one-digit
  6584.     values to two digits.  The following table uses the date February 3, 2001
  6585.     for the examples:
  6586.     
  6587.                        SAMPLE DATE FORMAT   SAMPLE RESULT
  6588.                        ------------------   -------------
  6589.                        y-?n-?d              1-02-03
  6590.                        ?y/m/?d              01/Feb/03
  6591.                        ?n/?d Y              02/01 2001
  6592.                        t '?y                February '01
  6593.     
  6594.     As the last example shows, it is not necessary to use month, day and year;
  6595.     you can omit any item to obtain an abbreviated date.
  6596.     
  6597.     
  6598.  
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604.  
  6605.  
  6606.  
  6607.  
  6608.  
  6609.  
  6610.  
  6611.  
  6612.  
  6613.  
  6614.  
  6615.  
  6616.  
  6617.  
  6618.  
  6619.  
  6620.  
  6621.  
  6622.                                                                             111
  6623.                                  -----------------
  6624.                                  The TODAY Command
  6625.                                  -----------------
  6626.     
  6627.     FORMAT:        TODAY var1 [value1]
  6628.     
  6629.     PURPOSE:       The TODAY command sets a variable (var1) to today's date, in
  6630.                    a variety of formats.
  6631.     
  6632.     DEFAULTS:      If value1 is not specified, TODAY uses the default date
  6633.                    format, which is specified in the file POMDATE.CFG.
  6634.     
  6635.     NOTES:         For a discussion of date formats (including the default date
  6636.                    format), see the "General Discussion" section at the
  6637.                    beginning of this chapter.
  6638.     
  6639.     SEE ALSO:      "The Date Command"
  6640.     
  6641.     Assuming today's date is July 1 1998, here are some examples:
  6642.     
  6643.                COMMAND              THE VARIABLE xyz IS SET TO...
  6644.                -------------------  -----------------------------
  6645.                TODAY xyz            The default date format
  6646.                TODAY xyz ""         The default date format
  6647.                TODAY xyz "Y-M-?d"   1998-JUL-01
  6648.                TODAY xyz "t d Y"    July 1 1998
  6649.                TODAY xyz "t 'y"     July '98
  6650.     
  6651.     As the last example shows, it is not necessary to use month, day and year;
  6652.     you can omit any item to obtain an abbreviated date.
  6653.     
  6654.     
  6655.  
  6656.  
  6657.  
  6658.  
  6659.  
  6660.  
  6661.  
  6662.  
  6663.  
  6664.  
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670.  
  6671.  
  6672.  
  6673.  
  6674.  
  6675.  
  6676.  
  6677.                                                                             112
  6678.                                   ----------------
  6679.                                   The DATE Command
  6680.                                   ----------------
  6681.     
  6682.     FORMAT:        DATE var1 value1 value2 value3 [value4]
  6683.     
  6684.     PURPOSE:       The DATE command sets a variable (var1) to given year
  6685.                    (value1), month (value2) and day (value3), or a subset of
  6686.                    these items, in a variety of formats, as specified by the
  6687.                    format string (value4).
  6688.     
  6689.     PARAMETERS:    var1   is the variable being set
  6690.                    value1 is the year (e.g. "1998" or "98")
  6691.                    value2 is the month (e.g. "1" = January)
  6692.                    value3 is the day (1 to 31)
  6693.                    value4 is the date format
  6694.     
  6695.     NUMERICS:      Tabs, spaces and commas are stripped from value1, 2 and 3
  6696.     
  6697.     DEFAULTS:      If value4 is omitted, DATE uses the default date format,
  6698.                    which is specified in the file POMDATE.CFG.
  6699.     
  6700.     NOTES:         For a discussion of date formats (including the default date
  6701.                    format), see the "General Discussion" section at the
  6702.                    beginning of this chapter.
  6703.     
  6704.     SEE ALSO:      "The Today Command"
  6705.     
  6706.     Assuming the date being set is July 1 1998, here are some examples:
  6707.     
  6708.     COMMAND                             THE VARIABLE xyz IS SET TO...
  6709.     ----------------------------------  -----------------------------
  6710.     DATE xyz "98"   "07" "01"           The default date format
  6711.     DATE xyz "1998" "07" "01" ""        The default date format
  6712.     DATE xyz "98"    "7"  "1" "Y-M-?d"  1998-JUL-01
  6713.     DATE xyz "98"   "07" "01" "t d Y"   July 1 1998
  6714.     DATE xyz "98"    "7" "01" "t 'y"    July '98
  6715.     DATE xyz "98"    "7"   "" "t 'y"    July '98
  6716.     
  6717.     As the last two examples show, it is not necessary to use month, day and
  6718.     year; you can omit any item to obtain an abbreviated date.
  6719.     
  6720.     If a date is outside a valid range, Parse-O-Matic halts with an error.
  6721.     Acceptable value ranges are:  Year 0 to 9999; Month 1 to 12; Day 1 to 31
  6722.     
  6723.     If the year is between 0 and 99, Parse-O-Matic makes the following
  6724.     assumptions:
  6725.     
  6726.     - If the number is between 80 and 99, it means 1980 to 1999
  6727.     - If the number is between  0 and 79, it means 2000 to 2079
  6728.     
  6729.     Parse-O-Matic does not check that a date is "possible", so you could set
  6730.     a date to "February 31, 2001", even though February never has 31 days.
  6731.  
  6732.                                                                             113
  6733.                                --------------------
  6734.                                The MONTHNUM Command
  6735.                                --------------------
  6736.     
  6737.     FORMAT:        MONTHNUM var1 value1
  6738.     
  6739.     PURPOSE:       The MONTHNUM command sets the month number of a given month.
  6740.     
  6741.     ALTERNATIVES:  The LOOKUP command
  6742.     
  6743.     Here is an example of the MONTHNUM command:
  6744.     
  6745.     MONTHNUM xyz "February"
  6746.     
  6747.     This will set the variable xyz to "2".
  6748.     
  6749.     The comparison is performed on the basis of the number of characters
  6750.     available, without regard to case, so the following would also work:
  6751.     
  6752.     MONTHNUM xyz "FEB"
  6753.     
  6754.     If the result is ambiguous, Parse-O-Matic returns the first match.  For
  6755.     example:
  6756.     
  6757.     MONTHNUM xyz "JU"
  6758.     
  6759.     This will set xyz to "6", although it could refer to either June or July.
  6760.     
  6761.     If MONTHNUM can not find a match, it will return a null ("") string.
  6762.     For example:
  6763.     
  6764.     MONTHNUM xyz "ZZZ"
  6765.     
  6766.     Since no month starts with "ZZZ", this will set xyz to "".
  6767.     
  6768.     If you are writing a Parse-O-Matic application that will be run in several
  6769.     languages (using different POMDATE.CFG files), you should carefully study
  6770.     the names of the months in each language to avoid problems.  In English, it
  6771.     is always sufficient to provide the first three letters.  In French,
  6772.     however, you need at least four letters, to distinguish between "Juin"
  6773.     (June) and "Juillet" (July).
  6774.     
  6775.     Parse-O-Matic can use only one POMDATE.CFG file at a time, so the MONTHNUM
  6776.     command can not be used to translate month names from one language to
  6777.     another.  You can, however, accomplish the same thing with the LOOKUP
  6778.     command.
  6779.     
  6780.     
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787.                                                                             114
  6788.                                 --------------------
  6789.                                 The ZERODATE Command
  6790.                                 --------------------
  6791.     
  6792.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  6793.     
  6794.     FORMAT:        ZERODATE value1 value2 value3
  6795.     
  6796.     PURPOSE:       Specifies "day zero" for the date serial number used by the
  6797.                    MAKETEXT command when it uses the DATE predefined data type.
  6798.     
  6799.     PARAMETERS:    value1 is the year  (e.g. "1900")
  6800.                    value2 is the month (e.g. "12" for December)
  6801.                    value3 is the day   (e.g. "5")
  6802.     
  6803.     NUMERICS:      Tabs, spaces and commas are stripped from value1, 2 and 3
  6804.     
  6805.     DEFAULTS:      If the ZERODATE command is omitted, the zero date is assumed
  6806.                    to be Jan. 1, 1753 (equivalent to ZERODATE "1753" "1" "1").
  6807.     
  6808.     SEE ALSO:      "The MakeText Command" and "Predefined Data Types"
  6809.     
  6810.     A "date serial number" is a common method of representing a date in a data
  6811.     file.  It works by counting the number of days since a given date, taking
  6812.     into account the extra days for leap years.
  6813.     
  6814.     Leap years occur in every year that is divisible by four, with the
  6815.     exception of century years -- unless they are divisible by 400. Thus, 1900
  6816.     is not a leap year, but 2000 is.
  6817.     
  6818.     The ZERODATE command specifies "Day 0".  For example, if you specify
  6819.     ZERODATE "1918" "11" "11" (November 11, 1918), you get the following:
  6820.     
  6821.                      DATE               DATE SERIAL NUMBER
  6822.                      -----------------  ------------------
  6823.                      November  9, 1918          -2
  6824.                      November 10, 1918          -1
  6825.                      November 11, 1918           0
  6826.                      November 12, 1918           1
  6827.                      November 13, 1918           2
  6828.     
  6829.     ... and so on.  Most programs set the zero date far enough back that
  6830.     negative numbers are not encountered in normal usage.
  6831.     
  6832.     ZERODATE will not accept a starting year before "1753", which was the first
  6833.     full year that most of the Western world started using the Gregorian
  6834.     calendar.
  6835.     
  6836.     
  6837.     
  6838.  
  6839.  
  6840.  
  6841.  
  6842.                                                                             115
  6843.     ============================================================================
  6844.                                 CALCULATION COMMANDS
  6845.     ============================================================================
  6846.     
  6847.                                   ----------------
  6848.                                   The CALC Command
  6849.                                   ----------------
  6850.     
  6851.     FORMAT:        CALC var1 value1 operation value2
  6852.     
  6853.     PURPOSE:       The CALC command performs an integer arithmetic operation on
  6854.                    the two values and assigns the answer to var1.
  6855.     
  6856.     NUMERICS:      Tabs, spaces and commas are stripped from value1 and value2
  6857.     
  6858.     ALTERNATIVES:  The CALCREAL command
  6859.     
  6860.     SEE ALSO:      "Inline Incrementing and Decrementing"
  6861.     
  6862.     Integer arithmetic refers to whole numbers.  1, 10 and 10000 are integers,
  6863.     while 2.0, 3.14159 and 98.5 are not.
  6864.     
  6865.     Let's say your input file looks like this:
  6866.     
  6867.     DESCRIPTION      UNITS SOLD    UNIT PRICE
  6868.     ---------------- ----------    ----------
  6869.     Dog collar               15    $     3.00
  6870.     Cat collar               25    $     2.50
  6871.     Cat caller                3    $     7.25
  6872.     Birdie num-nums       1,305    $     6.25
  6873.     ---------------- ----------    ----------
  6874.     End of Data
  6875.     :                :        :     :       :
  6876.     :                :        :     :       :    (Column positions)
  6877.     1               18       27    33      41
  6878.     
  6879.     
  6880.  
  6881.  
  6882.  
  6883.  
  6884.  
  6885.  
  6886.  
  6887.  
  6888.  
  6889.  
  6890.  
  6891.  
  6892.  
  6893.  
  6894.  
  6895.  
  6896.  
  6897.                                                                             116
  6898.     You can find out the total number of units sold (of all types) with the
  6899.     following POM file:
  6900.     
  6901.     IGNORE $FLINE[1 7] = "DESCRIP"
  6902.     IGNORE $FLINE[1 7] = "-------"
  6903.     BEGIN $FLINE = "End of Data"
  6904.       OUTEND |Total units sold = {units}
  6905.     ELSE
  6906.       CALC units = units "+" $FLINE[18 27]
  6907.     END
  6908.     
  6909.     As you can see from the example, all spaces and commas are stripped from
  6910.     the number.  Tab characters (ASCII 09) are also stripped.
  6911.     
  6912.     You will also notice that CALC can not be used for the prices, since they
  6913.     are not integer data.  To add up the prices, you must use the CALCREAL
  6914.     command (see "The CalcReal Command").
  6915.     
  6916.     Note in particular that the operation ("+" in this case) is in quotes.  If
  6917.     you omit the quotes, Parse-O-Matic will report an error.
  6918.     
  6919.     The following operations can be performed with CALC:
  6920.     
  6921.             SYMBOL     DESCRIPTION
  6922.             ---------  --------------------------------------------
  6923.             "+"        value1 plus value2
  6924.             "-"        value1 minus value2
  6925.             "*"        value1 times value2
  6926.             "/"        value1 divided by value2 (remainder ignored)
  6927.             "HIGHEST"  the larger number (value1 or value2)
  6928.             "LOWEST"   the smaller number (value1 or value2)
  6929.     
  6930.     Here are some more examples of the CALC command:
  6931.     
  6932.                    COMMAND                           ANSWER
  6933.                    --------------------------------  ------
  6934.                    CALC answer = "12" "/" "4"           "3"
  6935.                    CALC answer = "12" "HIGHEST" "4"    "12"
  6936.                    CALC answer = "12" "LOWEST"  "4"     "4"
  6937.                    CALC answer = "12" "-" "4"           "8"
  6938.                    CALC answer = "12" "+" "4"          "16"
  6939.                    CALC answer = "12" "*" "4"          "48"
  6940.     
  6941.     CALC can handle numbers between -2,147,483,648 and 2,147,483,647.
  6942.     
  6943.     
  6944.  
  6945.  
  6946.  
  6947.  
  6948.  
  6949.  
  6950.  
  6951.  
  6952.                                                                             117
  6953.                                 --------------------
  6954.                                 The CALCREAL Command
  6955.                                 --------------------
  6956.     
  6957.     FORMAT:        CALCREAL var1 value1 operation value2 [fixed-decimals]
  6958.     
  6959.     PURPOSE:       CALCREAL works the same way as CALC, except that it handles
  6960.                    decimal numbers.
  6961.     
  6962.     NUMERICS:      Tabs, spaces and commas are stripped from value1, value2,
  6963.                    and the "fixed-decimals" value
  6964.     
  6965.     ALTERNATIVES:  The CALC command
  6966.     
  6967.     SEE ALSO:      "The Rounding Command"
  6968.     
  6969.     Using the sample data given in the CALC section, you could write the
  6970.     following POM file:
  6971.     
  6972.     IGNORE $FLINE[1 7] = "DESCRIP"
  6973.     IGNORE $FLINE[1 7] = "-------"
  6974.     BEGIN $FLINE = "End of Data"
  6975.       OUTEND |Total units sold = {units}
  6976.       OUTEND |Total value sold = {value}
  6977.     ELSE
  6978.       CALC     units = units "+" $FLINE[18 27]
  6979.       CALCREAL value = value "+" $FLINE[33 41]
  6980.     END
  6981.     
  6982.     CALCREAL can handle values +/- 99,999,999,999, but its accuracy decreases
  6983.     when you are dealing with large numbers, as approximated below:
  6984.     
  6985.     Accurate to 1 decimal place  between +/- 9,999,999,999
  6986.     Accurate to 2 decimal places between +/-   999,999,999
  6987.     Accurate to 3 decimal places between +/-    99,999,999
  6988.     Accurate to 4 decimal places between +/-     9,999,999
  6989.     Accurate to 5 decimal places between +/-       999,999
  6990.     
  6991.     You can specify a fixed number of decimal positions in the answer by using
  6992.     the optional "fixed-decimals" value.  For example:
  6993.     
  6994.     SET z = "3.14159"
  6995.     CALCREAL x = z "+" "0" "2"      <-- This sets x to "3.14"
  6996.     CALCREAL x = z "+" "0" "4"      <-- This sets x to "3.1415"
  6997.     
  6998.     You will notice, in the second example, that no "rounding" takes place.
  6999.     The number is simply truncated at the requested decimal position.
  7000.     
  7001.     
  7002.  
  7003.  
  7004.  
  7005.  
  7006.  
  7007.                                                                             118
  7008.     Here are some more examples of the CALCREAL command:
  7009.     
  7010.            COMMAND                                           ANSWER
  7011.            -----------------------------------------------  --------
  7012.            CALCREAL answer = "12.0"  "*"        "4.0"  "2"   "48.00"
  7013.            CALCREAL answer = "12.0"  "HIGHEST"  "4.0"  "2"   "12.00"
  7014.            CALCREAL answer =   "12"  "LOWEST      "4"  "1"     "4.0"
  7015.            CALCREAL answer =   "12"  "-"          "4"  "3"   "8.000"
  7016.            CALCREAL answer =   "12"  "+"          "4"  "1"    "16.0"
  7017.            CALCREAL answer =    "7"  "/"          "2"  "2"    "3.50"
  7018.            CALCREAL answer =    "7"  "/"          "2"          "3.5"
  7019.            CALCREAL answer =    "7"  "*"          "2"         "14.0"
  7020.     
  7021.     As shown in the examples, if you do not use the optional fixed-decimal
  7022.     value, calculations are in "floating point".  That is to say, the answer
  7023.     has as many decimal places as necessary.  (Bear in mind the accuracy
  7024.     restrictions mentioned earlier.)  Trailing zeros are removed, unless there
  7025.     are no digits after the decimal point, in which case a 0 is added.
  7026.     
  7027.                               ------------------------
  7028.                               The INC and DEC Commands
  7029.                               ------------------------
  7030.     
  7031.     FORMAT:        INC var1 [value1]
  7032.                    DEC var1 [value1]
  7033.     
  7034.     PURPOSE:       INC:  Adds 1 (or whatever value1 is set to) to var1
  7035.                    DEC:  Subtracts 1 (or whatever value1 is set to) from var1
  7036.     
  7037.     NUMERICS:      Tabs, spaces and commas are stripped from var1 and value1.
  7038.                    Both var1 and value1 must be integers.
  7039.                    var1   must be between -2147483640 and 2147483647.
  7040.                    value1 must be between  -100000000 and  100000000.
  7041.     
  7042.     DEFAULTS:      If value1 is not specified, it is assumed to be "1".
  7043.     
  7044.     ALTERNATIVES:  The CALC command
  7045.     
  7046.     SEE ALSO:      "Inline Incrementing and Decrementing"
  7047.     
  7048.     The INC command adds "1" to var1, while the DEC command subtracts "1".  You
  7049.     can also specify a number other than "1" by specifying the optional value1.
  7050.     Here is a sample sequence of commands...
  7051.     
  7052.     SET      x = ""     <-- Parse-O-Matic treats null numerics as equal to "0"
  7053.     INC      x          <-- Sets x to "1"
  7054.     INC      x          <-- Sets x to "2"
  7055.     DEC      x          <-- Sets x to "1"
  7056.     INC      x "2"      <-- Sets x to "3"
  7057.     DEC      x "3"      <-- Sets x to "0"
  7058.     
  7059.     
  7060.  
  7061.  
  7062.                                                                             119
  7063.     Note that if you specify a negative value for value1, INC and DEC work the
  7064.     opposite way.  For example, if you subtract "-1" from "2", you would get "3".
  7065.     Here are some examples:
  7066.     
  7067.     SET      x = "10"
  7068.     DEC      x "-2"     <-- Sets x to "12"
  7069.     INC      x "-3"     <-- Sets x to "9"
  7070.     
  7071.     Incrementing or decrementing a variable by "0" leaves it unchanged.
  7072.     
  7073.                                 --------------------
  7074.                                 The ROUNDING Command
  7075.                                 --------------------
  7076.     
  7077.     FORMAT:        ROUNDING "Y" or ROUNDING "N"
  7078.     
  7079.     PURPOSE:       Controls rounding of answers given by the CALCREAL command
  7080.                    when it is in "fixed-decimal" mode.
  7081.     
  7082.     PARAMETERS:    ROUNDING "Y" turns on rounding (the default)
  7083.                    ROUNDING "N" turns off rounding
  7084.     
  7085.     ALTERNATIVES:  The CALCREAL command can be used in "floating point" mode,
  7086.                    and you can perform rounding and truncation operations
  7087.                    yourself, within the POM file.
  7088.     
  7089.     Due to the way that real numbers (as opposed to integers) are calculated in
  7090.     binary, CALCREAL can sometimes return unexpected results.  For example:
  7091.     
  7092.     CALCREAL x = "400.00" "-" "390.60"
  7093.     
  7094.     produces the answer "9.399999" rather than the expected answer of "9.4".
  7095.     
  7096.     This discrepancy is due to the nature of real-mode calculations in binary
  7097.     (i.e. inside the computer). The answer is actually very close indeed to the
  7098.     correct answer, yet it could cause problems if you specify the actual number
  7099.     of digits of precision ("fixed-decimals" mode instead of "floating point"
  7100.     mode).  For example:
  7101.     
  7102.     ROUNDING "N"                              <-- This is explained later
  7103.     CALCREAL x = "400.00" "-" "390.60" "2"    <-- 2 digits of precision
  7104.     
  7105.     This sets the x variable to "3.39", which is clearly wrong.  What has
  7106.     happened is that the remaining digits of the floating-point answer were
  7107.     simply truncated (i.e. removed).
  7108.     
  7109.     
  7110.  
  7111.  
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.                                                                             120
  7118.     Normally, Parse-O-Matic's built-in rounding will add a small value
  7119.     appropriate to the number of digits of fixed-decimal precision you have
  7120.     specified:
  7121.     
  7122.                      PRECISION   SAMPLE NUMBER   ROUNDING VALUE
  7123.                      ---------   -------------   --------------
  7124.                          1           9.9            + 0.05
  7125.                          2           9.99           + 0.005
  7126.                          3           9.999          + 0.0005
  7127.     
  7128.     ... and so on.  Thus, CALCREAL "400.00" "-" "390.60" "2" first generates the
  7129.     floating-point answer "9.3999999999", adds "0.005", yielding "9.4049999999".
  7130.     This is then truncated to two digits, yielding "9.40", which is the correct
  7131.     answer.
  7132.     
  7133.     You can turn this rounding behavior off with the following command:
  7134.     
  7135.     ROUNDING "N"
  7136.     
  7137.     You can turn it back on with this command:
  7138.     
  7139.     ROUNDING "Y"
  7140.     
  7141.     By default, rounding is enabled, so unless you explicitly turn it off, there
  7142.     is no need to use the ROUNDING "Y" command.
  7143.     
  7144.     No rounding is performed when CALCREAL is used in "floating-point" mode.
  7145.     
  7146.                                 --------------------
  7147.                                 The CALCBITS Command
  7148.                                 --------------------
  7149.     
  7150.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  7151.     
  7152.     FORMAT:        CALCBITS var1 value1 operation value2
  7153.     
  7154.     PURPOSE:       CALCBITS performs logical operations
  7155.     
  7156.     SEE ALSO:      "The MakeData Command"
  7157.     
  7158.     The CALCBITS command performs "bit-wise" operations on single bytes.  The
  7159.     following operations can be performed with CALCBITS:
  7160.     
  7161.                   SYMBOL     DESCRIPTION
  7162.                   ---------  ---------------------------------
  7163.                   "AND"      value1 AND value2
  7164.                   "OR"       value1 OR  value2
  7165.                   "XOR"      value1 XOR value2
  7166.                   "SHR"      Shift value1 right by value2 bits
  7167.                   "SHL"      Shift value1 left  by value2 bits
  7168.     
  7169.     Let us say you want to strip the high bit from all of the bytes in an input
  7170.     file.  You could accomplish this with the following POM file:
  7171.  
  7172.                                                                             121
  7173.     CHOP     1-1                    <-- Read the input file one byte at a time
  7174.     CALCBITS z $FLINE "AND" $7F     <-- Remove the high bit from the byte
  7175.     OUT      |{z}                   <-- Send the result to the output file
  7176.     
  7177.     Note that because we are reading the file one byte at a time, $FLINE is
  7178.     always one byte long.  Parse-O-Matic will terminate with an error message
  7179.     if you attempt to use CALCBITS with a value longer than one byte.  Thus,
  7180.     assuming the variable xyz contains "ABCDEF", the following line is valid:
  7181.     
  7182.     CALCBITS answer = xyz[3] "AND" $7F
  7183.     
  7184.     However, the following line would not be permitted because it refers to
  7185.     more than one byte:
  7186.     
  7187.     CALCBITS answer = xyz[3 4] "AND" $7F
  7188.     
  7189.     Here are some more examples of the CALCBITS command:
  7190.     
  7191.     COMMAND                           ANSWER   COMMENTS
  7192.     -------------------------------   ------   ------------------------------
  7193.     CALCBITS answer = $FF "AND" $7F     $7F
  7194.     CALCBITS answer = "9" "AND" $39     $39    $39 is the character "9"
  7195.     CALCBITS answer = $F0 "OR"  $0F     $FF
  7196.     CALCBITS answer = $7F "XOR" $08     $77
  7197.     CALCBITS answer = $80 "SHR" $01     $40    $80 = 10000000; $40 = 01000000
  7198.     CALCBITS answer = $01 "SHR" $01     $00    $01 = 00000001; $00 = 00000000
  7199.     CALCBITS answer = $01 "SHL" $01     $02    $01 = 00000001; $02 = 00000010
  7200.     CALCBITS answer = $80 "SHL" $01     $00    $80 = 10000000; $00 = 00000000
  7201.     
  7202.     In most of these examples, we use hex notation (e.g. $01), but you can also
  7203.     use single characters (e.g. "3" which is equivalent to $33) or decimal
  7204.     notation (e.g. #64 which is equivalent to $40).  However, you should always
  7205.     bear in mind that you are working with the underlying bit pattern.  The
  7206.     following lines are NOT equivalent:
  7207.     
  7208.     CALCBITS answer = $7F "SHL" $01         <-- Shifts left one bit
  7209.     CALCBITS answer = $7F "SHL" "1"         <-- This is not the same!
  7210.     
  7211.     The second line interprets "1" as hex $31 (decimal 49).  There is obviously
  7212.     no point in shifting an eight-bit byte 49 positions to the left.
  7213.     
  7214.     
  7215.     
  7216.  
  7217.  
  7218.  
  7219.  
  7220.  
  7221.  
  7222.  
  7223.  
  7224.  
  7225.  
  7226.  
  7227.                                                                             122
  7228.     ============================================================================
  7229.                                 INPUT PREPROCESSORS
  7230.     ============================================================================
  7231.     
  7232.                                  -----------------
  7233.                                  The SPLIT Command
  7234.                                  -----------------
  7235.     
  7236.     FORMAT:        SPLIT from-position to-position [,from-pos'n to-pos'n] [...]
  7237.     
  7238.     SEE ALSO:      "The Leftover Technique"
  7239.     
  7240.     IMPORTANT:     This command is analyzed at compile time, which means it can
  7241.                    not be used conditionally (i.e. in a BEGIN/END block).
  7242.     
  7243.     The maximum length of an input line from a text file is 255 characters.  If
  7244.     your input file is wider than that, you must break up the file into
  7245.     manageable chunks, using the SPLIT command.  This command lets you specify
  7246.     the way in which each input line is broken up so that it will look like
  7247.     several SEPARATE lines.
  7248.     
  7249.     For example, if your input lines were up to 300 characters wide, you could
  7250.     specify:
  7251.     
  7252.     SPLIT 1 255, 256 300
  7253.     
  7254.     This breaks up each line as if it was two lines.  (If some of the lines are
  7255.     less than 256 characters, they will still be treated as two lines, although
  7256.     the second line will be null (i.e. empty).)
  7257.     
  7258.     You can specify up to 130 splits (use multiple SPLIT commands if
  7259.     necessary).  With SPLIT, Parse-O-Matic can handle large input records,
  7260.     up to a maximum total length of 32767 characters.
  7261.     
  7262.     The best way of handling SPLIT or CHOPped files is to use a combination of
  7263.     the $SPLIT variable (explained in more detail later) and BEGIN/END.  For
  7264.     example:
  7265.     
  7266.     SPLIT 1 250, 251 300
  7267.     BEGIN $SPLIT = "1"
  7268.       SET a = $FLINE[ 1 10]
  7269.       SET b = $FLINE[11 20]
  7270.     END
  7271.     BEGIN $SPLIT = "2"
  7272.       SET x = $FLINE[ 1 10]
  7273.       SET y = $FLINE[11 20]
  7274.       OUTEND |{a} {b} {x} {y}
  7275.     END
  7276.     
  7277.     This outputs the data which appears (in the input file) in columns 1-10,
  7278.     11-20, 251-260 and 261-280.
  7279.     
  7280.     
  7281.  
  7282.                                                                             123
  7283.     ------------------------------
  7284.     Indicating Actual Input Length
  7285.     ------------------------------
  7286.     
  7287.     The final split must indicate the maximum length of the line.  Thus, if you
  7288.     have a text file with a maximum line length of 275, you still have to
  7289.     indicate this, even if you are only interested in the first 100 characters:
  7290.     
  7291.     SPLIT 1-100, 101-275
  7292.     
  7293.     You could use IGNORE $SPLIT = "2" to get rid of the additional text lines.
  7294.     
  7295.     ---------------------
  7296.     Non-Contiguous Splits
  7297.     ---------------------
  7298.     
  7299.     Your splits do not have to be contiguous.  For example, the following SPLIT
  7300.     command is legal:
  7301.     
  7302.     SPLIT 5 39, 41 100, 247 285
  7303.     
  7304.     The first four characters of each split would be ignored, so your first
  7305.     split would contain only the characters at positions 5 to 39 of the line.
  7306.     Similarly, the second split would contain the 41st through 100th character,
  7307.     and the third split would contain the 247th through 285th character.
  7308.     
  7309.     
  7310.  
  7311.  
  7312.  
  7313.  
  7314.  
  7315.  
  7316.  
  7317.  
  7318.  
  7319.  
  7320.  
  7321.  
  7322.  
  7323.  
  7324.  
  7325.  
  7326.  
  7327.  
  7328.  
  7329.  
  7330.  
  7331.  
  7332.  
  7333.  
  7334.  
  7335.  
  7336.  
  7337.                                                                             124
  7338.                                   ----------------
  7339.                                   The CHOP Command
  7340.                                   ----------------
  7341.     
  7342.     FORMAT:        CHOP from-position to-position [,from-pos'n to-pos'n] [...]
  7343.                    CHOP 0
  7344.     
  7345.     PURPOSE:       Controls the number of bytes Parse-O-Matic will read from
  7346.                    the input file each time it processes the POM file.
  7347.     
  7348.     SEE ALSO:      "The Get Command"
  7349.     
  7350.     IMPORTANT:     This command is analyzed at compile time, which means it can
  7351.                    not be used conditionally (i.e. in a BEGIN/END block).
  7352.     
  7353.     The CHOP command works the same way as the SPLIT command, with one
  7354.     exception:  it informs Parse-O-Matic that the input is a fixed-record-
  7355.     length file. In other words, it means that the input records are
  7356.     distinguished by having a particular (and exact) length, rather than being
  7357.     separated by end-of-line characters (Carriage Return, Linefeed) as is the
  7358.     case for a standard text file.
  7359.     
  7360.     Thus, if you have an input file containing fixed-length records, each of
  7361.     which is 200 characters wide, you could specify it like this:
  7362.     
  7363.     CHOP 1 200
  7364.     
  7365.     If the input record is more than 255 characters, you must break it up into
  7366.     smaller chunks.  For example, if the input record was 300 characters wide,
  7367.     you could break it up like this:
  7368.     
  7369.     CHOP 1 250, 251 300
  7370.     
  7371.     By using CHOP, Parse-O-Matic can handle input records up to 32767
  7372.     characters wide.  You can use the $SPLIT variable to manage your use of
  7373.     CHOP.  See the example in the section describing the SPLIT command.
  7374.     
  7375.     --------------
  7376.     Manual Reading
  7377.     --------------
  7378.     
  7379.     There is a special form of the CHOP command, which looks like this:
  7380.     
  7381.     CHOP 0
  7382.     
  7383.     This tells Parse-O-Matic that you will handle all file reading yourself. In
  7384.     such case, $FLINE is always null.  The only way to get data from the input
  7385.     file is with the GET command.
  7386.     
  7387.     When you use CHOP 0 for manual reading, the MINLEN and READNEXT commands
  7388.     have no meaning.  If you place them in the POM file, they are ignored.
  7389.     
  7390.     
  7391.  
  7392.                                                                             125
  7393.     ============================================================================
  7394.                                   LOOKUP COMMANDS
  7395.     ============================================================================
  7396.     
  7397.                                  ------------------
  7398.                                  The LOOKUP Command
  7399.                                  ------------------
  7400.     
  7401.     FORMAT:        LOOKUP var1 value1
  7402.     
  7403.     PURPOSE:       The LOOKUP command searches for value1 in a text file (the
  7404.                    name of which is specified either by the LOOKFILE command or
  7405.                    the /L startup parameter). When POM finds it, it sets var1
  7406.                    to another value found on the same line.
  7407.     
  7408.     ALTERNATIVES:  The REMAP command
  7409.     
  7410.     Let us suppose you created a text file, named NAMES.TBL, like this:
  7411.     
  7412.     R. REAGAN        Ronald Reagan
  7413.     D. EISENHOWER    Dwight Eisenhower
  7414.     G. BUSH          George Bush
  7415.     B. CLINTON       Bill Clinton
  7416.     :                :
  7417.     Column 1         Column 18
  7418.     
  7419.     This file can be used to look up a name, as in this POM file:
  7420.     
  7421.     LOOKFILE "NAMES.TBL"
  7422.     LOOKCOLS "1" "17" "18" "34"
  7423.     SET      oldname = $FLINE[21 37]
  7424.     TRIM     oldname "R" " "
  7425.     LOOKUP   newname = oldname
  7426.     OUTEND   |{oldname} {newname}
  7427.     
  7428.     The LOOKFILE command specifies the name of the look-up file.  The LOOKCOLS
  7429.     command specifies the starting and end columns for both the "text-to-look-
  7430.     for" field (known as the key field) and the "text-to-get" field (known as
  7431.     the data field).
  7432.     
  7433.     The LOOKUP command will look for oldname in NAMES.TBL.  If oldname is set
  7434.     to "G. BUSH", LOOKUP sets newname to "George Bush".  If, however, oldname
  7435.     is set to "G. WASHINGTON", which doesn't appear in NAMES.TBL, newname
  7436.     is set to "" (that is to say, an empty string).
  7437.     
  7438.     
  7439.  
  7440.  
  7441.  
  7442.  
  7443.  
  7444.  
  7445.  
  7446.  
  7447.                                                                             126
  7448.     -------------
  7449.     Search Method
  7450.     -------------
  7451.     
  7452.     When searching for the key field, LOOKUP compares text according to the
  7453.     length of the string you are looking for.  If your LOOKUP file looks like
  7454.     this:
  7455.     
  7456.         ABCDEF    456
  7457.         ABC       678
  7458.         XYZABC    345
  7459.         XYZ       123
  7460.     
  7461.     then the command LOOKUP x = "XYZ" would match on "XYZABC".  If this search
  7462.     procedure is a problem for you, there are two ways you can deal with it:
  7463.     
  7464.     1)  Pad your search strings before searching, as in this example:
  7465.     
  7466.         PAD     search "R" " " "6"
  7467.         LOOKUP  x = search
  7468.     
  7469.         If the search variable was original set to "XYZ", the PAD command
  7470.         would set it to "XYZ   ", which would not match XYZABC.
  7471.     
  7472.     2)  Put the shorter key fields in the lookup file ahead of the longer
  7473.         ones (of which they are a sub-string), as in this example:
  7474.     
  7475.         ABC       678
  7476.         ABCDEF    456
  7477.         XYZ       123
  7478.         XYZABC    345
  7479.     
  7480.         It is worth pointing out that this look-up file is sorted in
  7481.         ASCII order (whereas the example given earlier was not).  A sorted
  7482.         file can be more efficient, as explained in "The LookSpec Command".
  7483.     
  7484.     -----------
  7485.     Limitations
  7486.     -----------
  7487.     
  7488.     There is no limit to the number of lines that you can put in a look-up
  7489.     file.  However, the more lines there are, the longer it will take to
  7490.     process (because there is more to search).  The maximum length of a line
  7491.     in a look-up file is 255 characters.
  7492.     
  7493.     
  7494.  
  7495.  
  7496.  
  7497.  
  7498.  
  7499.  
  7500.  
  7501.  
  7502.                                                                             127
  7503.     -----------------------
  7504.     Null Lines and Comments
  7505.     -----------------------
  7506.     
  7507.     In the look-up file, null (empty) lines are ignored.  You can also include
  7508.     comments in the file by starting the line with a semi-colon:
  7509.     
  7510.     ; Some of the Presidents of the United States
  7511.     R. REAGAN        Ronald Reagan
  7512.     D. EISENHOWER    Dwight Eisenhower
  7513.     G. BUSH          George Bush
  7514.     
  7515.     The LOOKUP command can be used for more than just names, of course.  You
  7516.     could use it to look up prices, phone numbers, addresses and so on.
  7517.     
  7518.     ----------------
  7519.     Multiple Columns
  7520.     ----------------
  7521.     
  7522.     You can use the same lookup file to find different items that are related
  7523.     to the same key field.  For example, let's say you have created a lookup
  7524.     file, named EMPLOYEE.TBL, which looks like this:
  7525.     
  7526.     ; EMPLOYEE#   NAME           PHONE
  7527.       00001       John Smith     555-1212
  7528.       00002       Mary Jones     555-2121
  7529.       00003       Fred Johnson   555-1122
  7530.     
  7531.     You could look up an employee's name and phone number as follows:
  7532.     
  7533.     LOOKFILE "EMPLOYEE.TBL"
  7534.     LOOKCOLS "3" "7" "15" "37"
  7535.     LOOKSPEC "N" "Y" "N"
  7536.     LOOKUP   empdata = "00002"
  7537.     SET      name  = empdata[ 1 12]
  7538.     SET      phone = empdata[16 23]
  7539.     TRIM     name  "B" " "
  7540.     TRIM     phone "B" " "
  7541.     
  7542.     You could, of course, specify a different LOOKCOLS prior to each LOOKUP,
  7543.     but that would mean reading the disk twice.  It most cases, it is faster
  7544.     to obtain the data all at once, then extract it.
  7545.     
  7546.     
  7547.  
  7548.  
  7549.  
  7550.  
  7551.  
  7552.  
  7553.  
  7554.  
  7555.  
  7556.  
  7557.                                                                             128
  7558.     -------------------
  7559.     LOOKUP Versus REMAP
  7560.     -------------------
  7561.     
  7562.     If you have only a few thousand bytes of lookup data, you might be able to
  7563.     use the REMAP command instead of LOOKUP.  However, you can not simply
  7564.     replace LOOKFILE and LOOKUP with MAPFILE and REMAP.  REMAP does not return
  7565.     a null value if it can not find the item being sought, so you will have to
  7566.     change your POM file to compare the original string with the revised
  7567.     string, in order to see if it has changed (i.e. it was found).  Even with
  7568.     this test, REMAP might "fool you" if it finds a partial match.
  7569.     
  7570.     If you are processing a lot of input data, using REMAP may speed up
  7571.     processing, since REMAP works in RAM memory, while LOOKUP reads the disk.
  7572.     However, if your disk uses "caching", the performance improvement may be
  7573.     negligible.
  7574.     
  7575.                                 --------------------
  7576.                                 The LOOKFILE Command
  7577.                                 --------------------
  7578.     
  7579.     FORMAT:        LOOKFILE value1
  7580.     
  7581.     PURPOSE:       The LOOKFILE command specifies the name of the look-up file
  7582.                    for the next LOOKUP command.
  7583.     
  7584.     SEE ALSO:      "How Parse-O-Matic Searches for a File"
  7585.     
  7586.     LOOKFILE lets you use several look-up files in one POM file. For example:
  7587.     
  7588.     SET      name = $FLINE[1 20]
  7589.     ;   Look up the name
  7590.     LOOKFILE "NAMES.TBL"
  7591.     LOOKCOLS "1" "25" "30" "50"
  7592.     LOOKUP   fullname = name
  7593.     ;   Look up phone number
  7594.     LOOKFILE "PHONE.TBL"
  7595.     LOOKCOLS "1" "25" "30" "40"
  7596.     LOOKUP   phone = name
  7597.     ;   Output result
  7598.     OUTEND   |{name} {fullname} {newname}
  7599.     
  7600.     If you only have one look-up file, you may omit the LOOKFILE command and
  7601.     specify the file name on the command line, using the /L parameter.  For
  7602.     example, you could write a POM file like this:
  7603.     
  7604.     
  7605.  
  7606.  
  7607.  
  7608.  
  7609.  
  7610.  
  7611.  
  7612.                                                                             129
  7613.     SET      name = $FLINE[1 20]
  7614.     ;   Look up the name
  7615.     LOOKCOLS "1" "25" "30" "50"
  7616.     LOOKUP   fullname = name
  7617.     ;   Output result
  7618.     OUTEND   |{name} {fullname}
  7619.     
  7620.     Your POM command could then look like this:
  7621.     
  7622.     POM MYPOM.POM INPUT.TXT OUTPUT.TXT /LC:\MYFILES\NAMES.TBL
  7623.     
  7624.     This technique allows you to use several different look-up files with the
  7625.     same POM file, simply by changing the command line.  (The method by which
  7626.     Parse-O-Matic finds the file is discussed in the section "How Parse-O-Matic
  7627.     Searches for a File".)
  7628.     
  7629.     The longest line allowed in a look-up file is 255 characters long.
  7630.     
  7631.     If you specify a null look-up file name (e.g. LOOKFILE ""), Parse-O-Matic
  7632.     closes the current look-up file (if one is open).  This is necessary if you
  7633.     wish to delete the file, using the ERASE command.
  7634.     
  7635.                                 --------------------
  7636.                                 The LOOKCOLS Command
  7637.                                 --------------------
  7638.     
  7639.     FORMAT:        LOOKCOLS value1 value2 value3 value4
  7640.     
  7641.     PURPOSE:       The LOOKCOLS command specifies the starting and ending
  7642.                    columns for the key and data fields in a look-up file (see
  7643.                    the explanation of the LOOKUP command for an overview of
  7644.                    look-up files).
  7645.     
  7646.     PARAMETERS:    value1 specifies the starting column for the key  field
  7647.                    value2 specified the  ending  column for the key  field
  7648.                    value3 specifies the starting column for the data field
  7649.                    value4 specified the  ending  column for the data field
  7650.     
  7651.     NUMERICS:      Tabs, spaces and commas are stripped from value1, 2, 3 and 4
  7652.     
  7653.     You can specify a null value to indicate "same as last time".  For example:
  7654.     
  7655.     SET name = $FLINE[1 20]
  7656.     LOOKFILE "NAMES.TBL"
  7657.     LOOKCOLS "1" "25" "30" "50"
  7658.     LOOKUP   fullname = name
  7659.     LOOKFILE "PHONE.TBL"
  7660.     LOOKCOLS "" "" "" "40"
  7661.     LOOKUP   phonenum = name
  7662.     OUTEND   |{name} {fullname} {phonenum}
  7663.     
  7664.     The second LOOKCOLS command uses the same numbers for the first three
  7665.     values that the first LOOKCOLS command used.
  7666.  
  7667.                                                                             130
  7668.     If you do not specify a LOOKCOLS command, the default values are:
  7669.     
  7670.     Key Field:   Starting column  =   1
  7671.                  Ending column    =  10
  7672.     Data Field:  Starting column  =  12
  7673.                  Ending column    = 255
  7674.     
  7675.     This is equivalent to LOOKCOLS "1" "10" "12" "255".
  7676.     
  7677.                                 --------------------
  7678.                                 The LOOKSPEC Command
  7679.                                 --------------------
  7680.     
  7681.     FORMAT:        LOOKSPEC value1 value2 value3
  7682.     
  7683.     PURPOSE:       The LOOKSPEC command configures the way the next LOOKUP
  7684.                    command will work.
  7685.     
  7686.     PARAMETERS:    value1 = Trim           ("Y" or "N" -- default "Y")
  7687.                    value2 = Sorted         ("Y" or "N" -- default "N")
  7688.                    value3 = Case-sensitive ("Y" or "N" -- default "N")
  7689.     
  7690.     The Trim setting specifies whether or not the data field should have spaces
  7691.     stripped off both ends.
  7692.     
  7693.     The Sorted setting specifies whether or not the look-up file is sorted by
  7694.     the key field.  A sorted file is much faster than an unsorted file.  This
  7695.     is especially noticeable if you have a large look-up file and a lot of
  7696.     input to process.
  7697.     
  7698.     The Case-sensitive setting specifies whether or not LOOKUP should distin-
  7699.     guish between upper and lower case when searching.  The default setting is
  7700.     "N" (No), so that LOOKUP would find "John Smith", even if it appeared in
  7701.     the look-up file as "JOHN SMITH".  It is usually safest to set Case-
  7702.     sensitivity to "N", but if you set it to "Y", searching is slightly faster.
  7703.     
  7704.     You can specify a null value to indicate "same as last time".  For example:
  7705.     
  7706.     SET name = $FLINE[1 20]
  7707.     LOOKFILE "DATA.TBL"
  7708.     LOOKCOLS "1" "25" "30" "50"
  7709.     LOOKSPEC "Y" "Y" "Y"
  7710.     LOOKUP   fullname = name
  7711.     LOOKCOLS "" "" "60" "70"
  7712.     LOOKSPEC "N" "" ""
  7713.     LOOKUP   phonenum = name
  7714.     OUTEND   |{name} {fullname} {phonenum}
  7715.     
  7716.     The second LOOKSPEC command uses the same settings for Sorted and Case-
  7717.     sensitivity as the first one, but specifies a different Trim setting.
  7718.     
  7719.     
  7720.     
  7721.  
  7722.                                                                             131
  7723.     ============================================================================
  7724.                                   DATA CONVERTERS
  7725.     ============================================================================
  7726.     
  7727.                                 --------------------
  7728.                                 The MAKEDATA Command
  7729.                                 --------------------
  7730.     
  7731.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  7732.     
  7733.     FORMAT:        MAKEDATA var1 value1 value2
  7734.     
  7735.     PURPOSE:       MAKEDATA converts text data into a binary format.
  7736.     
  7737.     PARAMETERS:    var1     is the variable being set
  7738.                    value1   is the text data you want to convert
  7739.                    value2   is the predefined data type you want to create
  7740.     
  7741.     NUMERICS:      Tabs, spaces and commas are stripped from value1, if it is
  7742.                    numeric (as indicated by value2)
  7743.     
  7744.     SEE ALSO:      "Predefined Data Types" and "The CalcBits Command"
  7745.     
  7746.     When you are writing to a binary file (using the OUT command), you often
  7747.     need to convert text information to a binary representation.  MAKEDATA
  7748.     recognizes many standard data formats (see "Predefined Data Types").
  7749.     
  7750.     --------------------
  7751.     Creating Binary Data
  7752.     --------------------
  7753.     
  7754.     Let us say you have a four-line text file that looks like this:
  7755.     
  7756.      1234
  7757.      -456
  7758.        23
  7759.     90211
  7760.     
  7761.     Here is a POM file that reads the numbers from the file, then outputs them
  7762.     in binary format, as 16-bit signed integers:
  7763.     
  7764.     MAKEDATA z $FLINE "INTEGER"    <-- Convert the number to an integer
  7765.     OUT      |{z}                  <-- Send the integer to the output file
  7766.     
  7767.     We use OUT instead of OUTEND, since OUTEND would put an end-of-line
  7768.     (Carriage Return, Line Feed) after the data.
  7769.     
  7770.     If the POM file shown in the example was run with the input data shown,
  7771.     it would create an output file containing four integers.  In other words,
  7772.     the file would be eight bytes long (four integers of two bytes each).
  7773.     
  7774.     
  7775.  
  7776.  
  7777.                                                                             132
  7778.     ----------------
  7779.     Converting Dates
  7780.     ----------------
  7781.     
  7782.     In some files, a date serial number (see "The ZeroDate Command") might be
  7783.     represented by a numeric format such as INTEGER or LONGINT.  To write a
  7784.     date serial number to the output file, you must first convert the date with
  7785.     MAKEDATA, then use MAKEDATA again to convert the resulting number to the
  7786.     appropriate data type.
  7787.     
  7788.     The value1 part of the MAKEDATA must be in a precise format:
  7789.     
  7790.     "YYYY [M]M [D]D"               <-- Square brackets indicate optional digits
  7791.     
  7792.     That is to say:
  7793.     
  7794.     1) A four-digit year
  7795.     2) A space
  7796.     3) A one or two digit month (January = 1 or 01, December = 12)
  7797.     4) A space
  7798.     5) A one or two digit day of the month (e.g. 1 or 01 or 31)
  7799.     
  7800.     You can assemble the date string from various other data, using the
  7801.     DATE command.  Let us say you have a one-line text file that contains
  7802.     the date in Month-Day-Year format:
  7803.     
  7804.     01-01-2001
  7805.     
  7806.     You can read this file and output a date serial number as a long integer
  7807.     (LONGINT) with the following POM file:
  7808.     
  7809.     ZERODATE "2000" "1" "1"                <-- Set "day zero"
  7810.     SET      year  = $FLINE[7 10]          <-- Get the year
  7811.     SET      month = $FLINE[1  2]          <-- Get the month
  7812.     SET      day   = $FLINE[4  5]          <-- Get the day of the month
  7813.     DATE     x year month day "Y ?n ?d"    <-- Set x to "2001 01 01"
  7814.     MAKEDATA y x "DATE"                    <-- Set y to "366"
  7815.     MAKEDATA z y "LONGINT"                 <-- Set z to a long integer
  7816.     OUT      |{z}                          <-- Place it in the output file
  7817.     
  7818.     A typical problem with date data is that the year does not include
  7819.     the first two digits (e.g. you have "97" instead of "1997").  In
  7820.     such cases, your POM file has to make a decision as to which century
  7821.     the date belongs to.  Here is one way to handle this situation:
  7822.     
  7823.     BEGIN year #>= "50"
  7824.       CALC year = year + "1900"
  7825.     ELSE
  7826.       CALC year = year + "2000"
  7827.     END
  7828.     
  7829.     
  7830.  
  7831.  
  7832.                                                                             133
  7833.     This works around the problem as follows:
  7834.     
  7835.             Any year between     is placed in         Examples
  7836.             ----------------     ----------------     --------------
  7837.             "50" and "99"        the 20th century     "1950"  "1999"
  7838.             "00" and "49"        the 21st century     "2000"  "2049"
  7839.     
  7840.     You have to be careful when choosing the "cut-off date" (1950, in the
  7841.     example above).  You should make your decision only after studying your
  7842.     input data carefully.
  7843.     
  7844.     ------------------------
  7845.     Practical Considerations
  7846.     ------------------------
  7847.     
  7848.     The examples shown here assume that your input file contains only one kind
  7849.     of data.  In most cases, you will use the CHOP command to obtain complete
  7850.     data records of fixed length, then use SET to extract portions thereof.
  7851.     If you are reading a file with variable-length records, you can use CHOP 0
  7852.     (manual reading) and the GET command.
  7853.     
  7854.                                 --------------------
  7855.                                 The MAKETEXT Command
  7856.                                 --------------------
  7857.     
  7858.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  7859.     
  7860.     FORMAT:        MAKETEXT var1 value1 value2
  7861.     
  7862.     PURPOSE:       MAKETEXT converts binary data into text format.
  7863.     
  7864.     PARAMETERS:    var1     is the variable being set
  7865.                    value1   is the data you want to convert
  7866.                    value2   is the predefined data type of value1
  7867.     
  7868.     NOTES:         value1 is normally in binary (i.e. it looks like "garbage
  7869.                    characters" if you output it to a text file).  However, if
  7870.                    value2 specifies the DATE data type, value1 must be in text
  7871.                    form (e.g. "1234").  The reason for this difference is
  7872.                    described in the "Converting Dates" section below.
  7873.     
  7874.     SEE ALSO:      "Predefined Data Types"
  7875.     
  7876.     When reading a binary file (using the CHOP command), you often need to
  7877.     convert binary information to a text representation. MAKETEXT recognizes
  7878.     many standard data formats (see "Predefined Data Types").
  7879.     
  7880.     
  7881.  
  7882.  
  7883.  
  7884.  
  7885.  
  7886.  
  7887.                                                                             134
  7888.     ----------------------
  7889.     Converting Binary Data
  7890.     ----------------------
  7891.     
  7892.     Let us say you have a binary file that contains several WORD values
  7893.     (unsigned integers, each of which is 2 bytes long).  You can read and
  7894.     decode them with the following POM file:
  7895.     
  7896.     CHOP 1-2                            <-- Read the file two bytes at a time
  7897.     MAKETEXT x $FLINE "WORD"            <-- Convert the WORD to text format
  7898.     OUTEND   |{x}                       <-- Output the data to a text file
  7899.     
  7900.     ----------------
  7901.     Converting Dates
  7902.     ----------------
  7903.     
  7904.     MAKETEXT can convert a date serial number (see "The ZeroDate Command") to
  7905.     a formatted date.  Since there is no standard data format for date serial
  7906.     numbers, you must use MAKETEXT to convert the number into text form, and
  7907.     then use MAKETEXT again to format the date.
  7908.     
  7909.     Let us say you have a binary file that contains dates, represented as
  7910.     LONGINTs (4-byte signed integers).  You could convert them to dates with
  7911.     the following POM file:
  7912.     
  7913.     CHOP 1-4                     <-- Read 4 bytes at a time
  7914.     ZERODATE "1936" "1" "1"      <-- Set the "zero date"
  7915.     MAKETEXT x $FLINE "LONGINT"  <-- Convert the binary data to a text number
  7916.     MAKETEXT y x "DATE Y-M-?d"   <-- Convert to text date (e.g. "1998-JUL-01")
  7917.     OUTEND   |{y}                <-- Output the date to a text file
  7918.     
  7919.     ------------------------
  7920.     Practical Considerations
  7921.     ------------------------
  7922.     
  7923.     The examples shown here assume that your input file contains only one kind
  7924.     of data.  In most cases, you will use the CHOP command to obtain complete
  7925.     data records of fixed length, then use SET to extract portions thereof.
  7926.     If you are reading a file with variable-length records, you can use CHOP 0
  7927.     (manual reading) and the GET command.
  7928.     
  7929.     
  7930.     
  7931.  
  7932.  
  7933.  
  7934.  
  7935.  
  7936.  
  7937.  
  7938.  
  7939.  
  7940.  
  7941.  
  7942.                                                                             135
  7943.     ============================================================================
  7944.                                MISCELLANEOUS COMMANDS
  7945.     ============================================================================
  7946.     
  7947.                                  -----------------
  7948.                                  The ERASE Command
  7949.                                  -----------------
  7950.     
  7951.     FORMAT:        ERASE value1
  7952.     
  7953.     PURPOSE:       Deletes a file (if it exists).
  7954.     
  7955.     PARAMETERS:    value1 is the name of the file to be deleted
  7956.     
  7957.     SEE ALSO:      "Long File Names in Win95"
  7958.     
  7959.     Here is an example of the ERASE command:
  7960.     
  7961.     ERASE "C:\XYZ.TXT"
  7962.     
  7963.     This will delete the file C:\XYZ.TXT if it exists.  If it does not exist,
  7964.     nothing is done.
  7965.     
  7966.     You can not delete the current input file, output file, trace file or
  7967.     lookup file.  If you attempt to do so, Parse-O-Matic will terminate with
  7968.     an error.
  7969.     
  7970.     You can not delete a device (e.g. ERASE "LPT1:").  The ERASE command
  7971.     simply ignores such requests.
  7972.     
  7973.     If value1 is preceded by a "+" character, the plus sign is ignored.
  7974.     See "How Parse-O-Matic Opens an Output File" for an explanation of the
  7975.     significance of the plus sign.
  7976.     
  7977.     
  7978.  
  7979.  
  7980.  
  7981.  
  7982.  
  7983.  
  7984.  
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990.  
  7991.  
  7992.  
  7993.  
  7994.  
  7995.  
  7996.  
  7997.                                                                             136
  7998.                                --------------------
  7999.                                The FILESIZE Command
  8000.                                --------------------
  8001.     
  8002.     FORMAT:        FILESIZE var1 value1
  8003.     
  8004.     PURPOSE:       Determines the size of a file, in bytes
  8005.     
  8006.     PARAMETERS:    var1   is the variable being set with the file size
  8007.                    value1 is the name of the file
  8008.     
  8009.     SEE ALSO:      "Long File Names in Win95"
  8010.     
  8011.     The FILESIZE command can be used to obtain the size of a file, or to see
  8012.     if a file exists.
  8013.     
  8014.     If the file does not exist, FILESIZE sets var1 to a null ("") string.
  8015.     
  8016.     If the file exists, FILESIZE sets var1 to the number of bytes in the
  8017.     file (from 0 to 2,147,483,647 bytes).
  8018.     
  8019.     For those rare files that are larger than 2,147,483,647 bytes, FILESIZE will
  8020.     produce an unpredictable result and may even cause Parse-O-Matic to fail.
  8021.     Nevertheless, it is possible to process such large files -- all of the other
  8022.     commands will work normally.
  8023.     
  8024.     
  8025.  
  8026.  
  8027.  
  8028.  
  8029.  
  8030.  
  8031.  
  8032.  
  8033.  
  8034.  
  8035.  
  8036.  
  8037.  
  8038.  
  8039.  
  8040.  
  8041.  
  8042.  
  8043.  
  8044.  
  8045.  
  8046.  
  8047.  
  8048.  
  8049.  
  8050.  
  8051.  
  8052.                                                                             137
  8053.                                  ------------------
  8054.                                  The GETENV Command
  8055.                                  ------------------
  8056.     
  8057.     FORMAT:        GETENV var1 value1
  8058.     
  8059.     PURPOSE:       GETENV obtains a system environment variable
  8060.     
  8061.     PARAMETERS:    var1   is the variable being set
  8062.                    value1 is the name of the system environment variable
  8063.     
  8064.     NOTES:         System environment variables are sometimes referred to as
  8065.                    "DOS Environment Variables" or "SET Variables".
  8066.     
  8067.     SEE ALSO:      Explanations of the SET & PATH commands in your DOS manual,
  8068.                    or "The Environment Area" in your Windows or OS/2 manual.
  8069.     
  8070.     ALTERNATIVES:  See "Command-line Parameters" in the "Command-Line
  8071.                    Techniques" section of this manual.
  8072.     
  8073.     GETENV enables you to access certain important settings that concern your
  8074.     computer's operating system.  To see what settings are available, enter the
  8075.     following command at the DOS prompt:
  8076.     
  8077.     SET
  8078.     
  8079.     This will display the contents of your computer's "environment area".  Two
  8080.     of the most important values in the environment area are COMSPEC and PATH.
  8081.     These are briefly described later, but refer to your operating system
  8082.     manual for full details.
  8083.     
  8084.     GETENV removes all spaces, tabs and equals-signs ("=") from value1,
  8085.     converts it to uppercase, then looks it up in the system environment area.
  8086.     
  8087.     - If it finds it, var1 is set to the corresponding value.
  8088.     - If it does not find it, var1 is set to an empty (null) string.
  8089.     
  8090.     ----------------------------------
  8091.     Disappearing Environment Variables
  8092.     ----------------------------------
  8093.     
  8094.     Sometimes an environment variable disappears for no apparent reason.  There
  8095.     are two likely reasons for this:
  8096.     
  8097.     1)  You ran out of environment space.
  8098.     
  8099.         There is only a limited amount of room in the system environment area
  8100.         (which is located in RAM memory).  If you think this is the problem,
  8101.         type your DOS SET command to save a variable into the system
  8102.         environment, then type SET by itself to review the contents of the
  8103.         environment.  If your variable does not appear, consult your operating
  8104.         system manual to find out how to expand your environment space.
  8105.     
  8106.  
  8107.                                                                             138
  8108.     2)  It was set by a COPY of the operating system.
  8109.     
  8110.         If you are in Windows and you run DOS, then use the DOS SET command, it
  8111.         will only affect the environment area associated with the copy of DOS
  8112.         that you are running.  When you exit this copy and start up another
  8113.         one, it will not contain the variable.  You can address this problem by
  8114.         setting the variable in your AUTOEXEC.BAT file, or by running a batch
  8115.         file that sets the variable before running Parse-O-Matic.
  8116.     
  8117.     --------
  8118.     Examples
  8119.     --------
  8120.     
  8121.     The following command will determine which directories get searched when
  8122.     you are looking for a program or a file:
  8123.     
  8124.     GETENV path "PATH"
  8125.     
  8126.     To find out the name of your command interpreter (usually COMMAND.COM)
  8127.     and where it is located, try this command:
  8128.     
  8129.     GETENV comspec "COMSPEC"
  8130.     
  8131.     You can use GETENV as a simple "input routine" for Parse-O-Matic
  8132.     applications.  For details, see "Controlling a POM File from the Command
  8133.     Line", in the section entitled "Effective Use of Batch Files".
  8134.     
  8135.                                   ---------------
  8136.                                   The LOG Command
  8137.                                   ---------------
  8138.     
  8139.     FORMAT:        LOG value1 [comparator] value2 value3 [value4 [value5]]
  8140.     
  8141.     PURPOSE:       LOG places a message (value3) in the processing log file
  8142.                    (POMLOG.TXT) if the comparison is true.  Both value4 and
  8143.                    value5 are optional; if they are present, they are added
  8144.                    to end of value3.
  8145.     
  8146.     NOTES:         The processing log is described in the section "Logging".
  8147.     
  8148.     ALTERNATIVES:  The SHOWNOTE command
  8149.     
  8150.     
  8151.  
  8152.  
  8153.  
  8154.  
  8155.  
  8156.  
  8157.  
  8158.  
  8159.  
  8160.  
  8161.  
  8162.                                                                             139
  8163.     Here is an example of the LOG command:
  8164.     
  8165.     SET   emplnumb = $FLINE[ 1  9]
  8166.     SET   sales    = $FLINE[10 20]
  8167.     TRIM  sales "B" " "
  8168.     LOG   sales = "0" "WARNING!  Zero sales for employee number:"
  8169.     LOG   sales = "0" emplnumb
  8170.     
  8171.     This adds two warning lines to the processing log if the sales figures is
  8172.     zero.
  8173.     
  8174.     The logging feature lets you run Parse-O-Matic unattended, then come back
  8175.     later to review (via the processing log) any exceptional conditions.  For
  8176.     some additional comments on logging, see "Unattended Operation".
  8177.     
  8178.     The maximum length of a LOG string (value3, plus value4 and value5 if
  8179.     present) is 245 characters.
  8180.     
  8181.                                 -------------------
  8182.                                 The MSGWAIT Command
  8183.                                 -------------------
  8184.     
  8185.     FORMAT:        MSGWAIT value1
  8186.     
  8187.     PURPOSE:       MSGWAIT controls the amount of time that a processing error
  8188.                    message appears on the screen before it times out. (Messages
  8189.                    from the HALT command are treated as error messages.)
  8190.     
  8191.     PARAMETERS:    value1 is the delay time in seconds
  8192.     
  8193.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  8194.     
  8195.     DEFAULTS:      If the MSGWAIT command is not included in the POM file, and
  8196.                    an error occurs, Parse-O-Matic will wait until you press a
  8197.                    key; the message will not time out.
  8198.     
  8199.     NOTES:         If value1 is "0", error messages will not time out.
  8200.                    The maximum value for value1 is 60000 (about 16 hours).
  8201.                    You can set value1 to "1", but one second is usually too
  8202.                    short a delay; a value of "60" (one minute) is better.
  8203.     
  8204.     SEE ALSO:      "The Halt Command", "Unattended Operation", "Quiet Mode"
  8205.     
  8206.     The MSGWAIT command lets you control the behavior of error messages that
  8207.     appear during the processing of an input file.  This is helpful if you
  8208.     have created POM applications that are run unattended.
  8209.     
  8210.     If Parse-O-Matic was invoked by a batch file or application program, you
  8211.     want may error messages to "time out", allowing Parse-O-Matic to terminate,
  8212.     and processing to continue.
  8213.     
  8214.     
  8215.  
  8216.  
  8217.                                                                             140
  8218.     -----------------
  8219.     Standard Behavior
  8220.     -----------------
  8221.     
  8222.     If Parse-O-Matic encounters an error while reading in a POM file (i.e.
  8223.     during the "compile" step), it displays a message on the screen and waits
  8224.     until you press a key.  Parse-O-Matic then terminates.
  8225.     
  8226.     When running the actual POM file (i.e. while processing the input file),
  8227.     Parse-O-Matic will normally behave the same way:  if an error occurs (or
  8228.     if a HALT command is encountered), it will display a message on the screen
  8229.     and wait for you to press a key before it terminates.
  8230.     
  8231.     ------------------------
  8232.     Setting a Time-Out Delay
  8233.     ------------------------
  8234.     
  8235.     You can use the MSGWAIT command to tell Parse-O-Matic to continue ("time
  8236.     out") after a certain number of seconds.  For example:
  8237.     
  8238.     MSGWAIT "60"
  8239.     
  8240.     This tells Parse-O-Matic to wait about 60 seconds if an error is
  8241.     encountered while processing the input file.  Parse-O-Matic will then
  8242.     terminate.  (The actual delay depends on the type of computer you are
  8243.     using; a delay of "60" will typically last between 55 and 65 seconds).
  8244.     
  8245.     ----------
  8246.     Color Cues
  8247.     ----------
  8248.     
  8249.     If you have a color monitor, you can tell if a message will "time out"
  8250.     by the color of the "Press a key to continue" prompt:
  8251.     
  8252.     - If it is magenta (sometimes called "purple") it will NOT time out
  8253.     - If it is blue, if WILL time out
  8254.     
  8255.     ------------
  8256.     Key Stacking
  8257.     ------------
  8258.     
  8259.     To ensure that an error message is not inadvertently bypassed, "stacked"
  8260.     keystrokes are ignored by Parse-O-Matic.  That is to say, if you press
  8261.     several keys before an error message is displayed, Parse-O-Matic gets rid
  8262.     of them before displaying the message.
  8263.     
  8264.     
  8265.  
  8266.  
  8267.  
  8268.  
  8269.  
  8270.  
  8271.  
  8272.                                                                             141
  8273.     ----------
  8274.     Exceptions
  8275.     ----------
  8276.     
  8277.     If Parse-O-Matic is processing an empty input file, it will display the
  8278.     warning "Input file is empty", then continue processing the POM file when
  8279.     you press a key, or after a delay of about 60 seconds.
  8280.     
  8281.     The MSGWAIT command does not affect messages that report errors detected
  8282.     during the compilation (initial read-in) of the POM file.
  8283.     
  8284.     The MSGWAIT command does not affect the "Retry or Cancel" message that
  8285.     appears if you are dealing with a device (see "Sending Output to a
  8286.     Device").
  8287.     
  8288.     -----------------
  8289.     A Word of Caution
  8290.     -----------------
  8291.     
  8292.     A POM file should be thoroughly tested before setting the MSGWAIT time to a
  8293.     value other than "0".  Most error messages are serious enough to justify
  8294.     waiting until the user acknowledges them.
  8295.     
  8296.     If you call Parse-O-Matic from a batch file or application program, you can
  8297.     check the success of the parsing job by checking the return code.  (See
  8298.     "Effective Use of Batch Files" and "Running Parse-O-Matic from Another
  8299.     Program").
  8300.     
  8301.     If there was a processing error and you did not check the parsing job
  8302.     (either by testing the program return code, or by consulting the
  8303.     processing log), the resulting oversight could be serious.
  8304.     
  8305.                                  -----------------
  8306.                                  The PAUSE Command
  8307.                                  -----------------
  8308.     
  8309.     FORMAT:        PAUSE value1
  8310.     
  8311.     PURPOSE:       Delays the specified number of milliseconds
  8312.     
  8313.     PARAMETERS:    value1 is the delay time (between 1 and 65500)
  8314.     
  8315.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  8316.     
  8317.     NOTES:         1     millisecond  = One thousandth of a second
  8318.                    100   milliseconds = One tenth of a second
  8319.                    1000  milliseconds = One second
  8320.                    60000 milliseconds = One minute
  8321.     
  8322.     
  8323.  
  8324.  
  8325.  
  8326.  
  8327.                                                                             142
  8328.     Here are some typical applications of the PAUSE command:
  8329.     
  8330.     - Slow down Parse-O-Matic so you can watch the processing screen
  8331.     - Give a slow laser printer extra time to eject a page after an OUTPAGE
  8332.     - Give you time to remove a page from a dot-matrix printer after an OUTPAGE
  8333.     - Give a communications device time to complete its current operation
  8334.     
  8335.     Here is an example of the latter application:
  8336.     
  8337.     OFILE  "COM1:"             <-- Direct output to the modem on COM1
  8338.     OUTEND |ATZ                <-- Send a modem initialization command
  8339.     PAUSE  "1000"              <-- Wait one second for the command to complete
  8340.     OUTEND |ATDT555-1234       <-- Send a dialing command to the modem
  8341.     
  8342.     If your PAUSE command is 200 milliseconds or longer, Parse-O-Matic displays
  8343.     a "PAUSED" message in the lower right corner of the processing screen.
  8344.     While this appears, you can press any key to end the pause.  (We recommend
  8345.     that you use the spacebar -- and avoid the Esc key.  Parse-O-Matic
  8346.     processing will be terminated if the PAUSE happens to end at the precise
  8347.     moment your finger is coming down on the Esc key!)
  8348.     
  8349.                                  ------------------
  8350.                                  The RANDOM Command
  8351.                                  ------------------
  8352.     
  8353.     FORMAT:        RANDOM var1 value1 value2
  8354.     
  8355.     PURPOSE:       Generates a random integer number
  8356.     
  8357.     PARAMETERS:    var1   is the variable being set
  8358.                    value1 is the minimum number allowed (between 0 and 65534)
  8359.                    value2 is the maximum number allowed (between 0 and 65534)
  8360.     
  8361.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  8362.     
  8363.     The RANDOM command generates a random number in the range specified by
  8364.     value1 and value2.  For example, to simulate the rolling of a six-sided
  8365.     die:
  8366.     
  8367.     RANDOM   roll "1" "6"
  8368.     
  8369.     The first time you call this, it might set the roll variable to "3".  The
  8370.     next time, it might set it to "1".  The roll variable will never be lower
  8371.     than "1" or higher than "6".
  8372.     
  8373.     
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379.  
  8380.  
  8381.  
  8382.                                                                             143
  8383.     The minimum value must always be less than or equal to the maximum value.
  8384.     Thus, the following statement will cause an error:
  8385.     
  8386.     RANDOM   x "100" "1"        <-- This is incorrect
  8387.     
  8388.     If value1 and value2 are the same, RANDOM will always generate the same
  8389.     number.
  8390.     
  8391.     SET      n = "50"
  8392.     RANDOM   z n n
  8393.     
  8394.     This will always set the z variable to 50.
  8395.     
  8396.                                 --------------------
  8397.                                 The SHOWNOTE Command
  8398.                                 --------------------
  8399.     
  8400.     FORMAT:        SHOWNOTE value1 [value2] [value3] [value4] [value5]
  8401.     
  8402.     PURPOSE:       Displays a message on the processing screen
  8403.     
  8404.     PARAMETERS:    value1 to value5 are values that will be displayed
  8405.     
  8406.     ALTERNATIVES:  The LOG command
  8407.     
  8408.     When you are doing especially intense parsing, it is nice to see some kind
  8409.     of indication of what is happening.  The SHOWNOTE command displays a message
  8410.     up to 40 characters long in the lower left corner of the processing screen.
  8411.     For example:
  8412.     
  8413.     SHOWNOTE "Reading employee data"
  8414.     
  8415.     This will display the message "Reading employee data" until the parsing job
  8416.     ends, or until another SHOWNOTE command is encountered.
  8417.     
  8418.     You can remove a note from the processing screen by providing a null value:
  8419.     
  8420.     SHOWNOTE ""
  8421.     
  8422.     This clears a note that is already on the processing screen.
  8423.     
  8424.     You can display up to 5 values in a SHOWNOTE message.  Each value will be
  8425.     separated from the others by a space.  For example:
  8426.     
  8427.     SHOWNOTE "Employee:" empnum " -- Last name:" lastname
  8428.     
  8429.     This would display a note like this:
  8430.     
  8431.     Employee: 314159 -- Last name: Smith
  8432.     
  8433.     
  8434.  
  8435.  
  8436.  
  8437.                                                                             144
  8438.     Bear in mind that you have only 40 characters for the note.  If the lastname
  8439.     variable in the preceding example was "Von Neumann", the display would be
  8440.     truncated to forty characters, and display the note as follows:
  8441.     
  8442.     Employee: 314159 -- Last name: Von Neuma
  8443.     
  8444.     -----------
  8445.     Other Notes
  8446.     -----------
  8447.     
  8448.     There are three kinds of notes that are displayed in the lower right corner
  8449.     of the processing screen:
  8450.     
  8451.       TYPE OF NOTE     COLOR       TEXT                   REASON
  8452.       -------------   ----------   --------------------   --------------------
  8453.       SHOWNOTE        Light Grey   Whatever you specify   The SHOWNOTE command
  8454.       PAUSE           Light Red    PAUSED                 The PAUSE command
  8455.       Error message   Red          TRYING TO PRINT        Printer is offline
  8456.     
  8457.     In most cases, these messages will not interfere with each other.
  8458.     
  8459.     ------------
  8460.     Slowing Down
  8461.     ------------
  8462.     
  8463.     If you are running Parse-O-Matic on a fast machine, your SHOWNOTE messages
  8464.     blaze by so fast that there are not particularly helpful. Here is a POM file
  8465.     that demonstrates one solution:
  8466.     
  8467.     SET      line_counter = line_counter+
  8468.     SET      note_control = note_control+
  8469.     BEGIN    note_control = "100"
  8470.       SET      note_control = "0"
  8471.       SHOWNOTE "Processing line #" line_counter
  8472.     END
  8473.     OUTEND   |{$FLINE}
  8474.     
  8475.     This will perform the SHOWNOTE command on every hundredth input line.
  8476.     
  8477.                                  -----------------
  8478.                                  The SOUND Command
  8479.                                  -----------------
  8480.     
  8481.     FORMAT:        SOUND value
  8482.     
  8483.     PURPOSE:       The SOUND command performs two functions:
  8484.                    1)  It makes a noise, or ...
  8485.                    2)  It sets the noise made when an error occurs
  8486.     
  8487.     
  8488.  
  8489.  
  8490.  
  8491.  
  8492.                                                                             145
  8493.     The SOUND command has a repertoire of nine distinctive noises:
  8494.     
  8495.     BEEP BIP BUZZ EDGE ERROR HUH PIP TRILL WHOOP
  8496.     
  8497.     These sounds are useful for alerting you to unusual situations.  Let's say
  8498.     you wanted to be warned if one of the fields in a file comes up blank.  You
  8499.     could write the code this way:
  8500.     
  8501.     BEGIN lastname = ""
  8502.       SOUND "WHOOP"
  8503.       SET   lastname = "?"
  8504.     END
  8505.     
  8506.     Case is not important; the following commands are all equivalent:
  8507.     
  8508.     SOUND "WHOOP"
  8509.     SOUND "Whoop"
  8510.     SOUND "whoop"
  8511.     
  8512.     ------------------
  8513.     The LISTEN Utility
  8514.     ------------------
  8515.     
  8516.     You can listen to any given sound by using the LISTEN command at the DOS
  8517.     prompt.  To hear what TRILL sounds like, enter this command:
  8518.     
  8519.     LISTEN trill
  8520.     
  8521.     By default, Parse-O-Matic error messages will alert you by playing the
  8522.     ERROR sound.  To hear this sound, enter the following command at the DOS
  8523.     prompt:
  8524.     
  8525.     LISTEN error
  8526.     
  8527.     --------------------------------
  8528.     Changing the Error Message Sound
  8529.     --------------------------------
  8530.     
  8531.     If you find the error message sound noise annoying, you can replace it with
  8532.     one of the other sounds by using the special ERRMSG specification of the
  8533.     SOUND command.  For example, to replace the ERROR sound with the BUZZ
  8534.     sound, place this line at the top of your POM file:
  8535.     
  8536.     SOUND "ERRMSG BUZZ"
  8537.     
  8538.     If you don't want any sound made when an error occurs, use this command:
  8539.     
  8540.     SOUND "ERRMSG QUIET"
  8541.     
  8542.     The ERRMSG specification will only affect errors generated during the
  8543.     actual running of the POM file.  If an error is encountered while
  8544.     Parse-O-Matic is compiling the POM file, it will use the ERROR sound
  8545.     when it reports the problem.
  8546.  
  8547.                                                                             146
  8548.                                  -----------------
  8549.                                  The TRACE Command
  8550.                                  -----------------
  8551.     
  8552.     FORMAT:        TRACE var1
  8553.     
  8554.     PURPOSE:       The TRACE command is an alternative to standard tracing (see
  8555.                    "Tracing", in the "Programming Techniques" section).
  8556.     
  8557.     PARAMETERS:    var1 is the variable being traced.
  8558.     
  8559.     When you include a TRACE command in your POM file, Parse-O-Matic will
  8560.     create a text file, named POM.TRC, and use it to keep a detailed record of
  8561.     POM's processing.  Here is an example of the TRACE command:
  8562.     
  8563.     TRACE PRICE
  8564.     
  8565.     This traces the variable named "PRICE".  After processing, the file POM.TRC
  8566.     will show everything that happened, and give the value of PRICE at the
  8567.     TRACE line.
  8568.     
  8569.     NOTE:  Since trace files are so detailed, they can be very large.  If you
  8570.     are trying to debug a POM file using TRACE, it is a good idea to use a
  8571.     small input file.
  8572.     
  8573.     
  8574.     
  8575.  
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.  
  8585.  
  8586.  
  8587.  
  8588.  
  8589.  
  8590.  
  8591.  
  8592.  
  8593.  
  8594.  
  8595.  
  8596.  
  8597.  
  8598.  
  8599.  
  8600.  
  8601.  
  8602.                                                                             147
  8603.     ============================================================================
  8604.                                        TERMS
  8605.     ============================================================================
  8606.     
  8607.                                        ------
  8608.                                        Values
  8609.                                        ------
  8610.     
  8611.     A value can be specified in the following ways:
  8612.     
  8613.     FORMAT OR SAMPLE   DESCRIPTION
  8614.     ------------------ -----------
  8615.     "text"             A literal text string
  8616.     #number            An ASCII character, in decimal (e.g. #32 = Space)
  8617.     #number#number...  Several ASCII characters (e.g. #32#32 = 2 Spaces)
  8618.     $xx                A byte, in hexadecimal (e.g. $2F = decimal 47)
  8619.     $xx$xx...          Several hex bytes ($ff$ff = binary 1111111111111111)
  8620.     VARNAME            The name of a variable
  8621.     VARNAME[start end] A substring of a variable
  8622.     VARNAME[start]     A single character
  8623.     VARNAME+           Inline incremented variable (explained below)
  8624.     VARNAME-           Inline decremented variable (explained below)
  8625.     (x,@y,z)           Deduced variable name (see "Deduced Variables")
  8626.     x,y                Explictly specified deduced variable
  8627.     
  8628.                                      ---------
  8629.                                      Variables
  8630.                                      ---------
  8631.     
  8632.     A variable is a named spot in your computer's memory that holds some data.
  8633.     
  8634.     Variable names can be up to 12 characters long.  There is no distinction
  8635.     between upper and lower case in the variable name.  A POM file can contain
  8636.     about 2000 variables and literals.
  8637.     
  8638.     In general, variable names should:
  8639.     
  8640.     - Use letters, numbers and the underscore character
  8641.     - Start with a letter
  8642.     
  8643.     It is possible to create variables that do not adhere to these rules, but
  8644.     this may cause you problems later on (particularly in subsequent releases of
  8645.     Parse-O-Matic which may use special characters to denote particular kinds of
  8646.     variables, or operations performed thereon).
  8647.     
  8648.     The # character is used to specify a literal text string of one or more
  8649.     characters.  Follow each # with the decimal value of the ASCII character
  8650.     you want.  Here are some useful values:
  8651.     
  8652.            #10 = Line Feed   #12 = Form Feed   #13 = Carriage Return
  8653.     
  8654.     
  8655.  
  8656.  
  8657.                                                                             148
  8658.                                  -----------------
  8659.                                  Predefined Values
  8660.                                  -----------------
  8661.     
  8662.     Parse-O-Matic predefines several variables.  These are:
  8663.     
  8664.     VARIABLE     DESCRIPTION
  8665.     ------------ ------------------------------------------------------------
  8666.     $FLINE       The line just read from the file (max. length 255 chars) (*)
  8667.     $FLUPC       The line just read from the file, in uppercase           (*)
  8668.     $LASTFLINE   The previous value of $FLINE                             (*)
  8669.     $SPLIT       The CHOP or SPLIT number you are currently processing    (*)
  8670.     $LINECOUNTER The page line to which output will go next               (*)
  8671.     $COMMAND     The current POM command line (see "POM and Wildcards")
  8672.     $BRL         The { character (used in OUT and OUTEND)
  8673.     $BRR         The } character (used in OUT and OUTEND)
  8674.     $TAB         The tab character (Hex $09; ASCII 09)
  8675.     
  8676.     (*) This is discussed in more detail, below.
  8677.     
  8678.     Although these predefined variables start with a dollar sign ($), it does
  8679.     not mean they are in some way "hexadecimal" (as in the case of the hex
  8680.     values mentioned earlier).  In this case, the $ character indicates that the
  8681.     variables are defined by Parse-O-Matic.  In general, you should avoid
  8682.     creating variables that start with anything but a letter.
  8683.     
  8684.     ------
  8685.     $FLINE
  8686.     ------
  8687.     
  8688.     CONTAINS:    The line just read from the input file
  8689.     SEE ALSO:    The READNEXT, GET and GETTEXT commands
  8690.     
  8691.     $FLINE contains the data just read from the input file (exception:  see
  8692.     "DBF Files").  The data can be intelligible (human-readable) text, or it
  8693.     can be binary information -- Parse-O-Matic does not care what $FLINE
  8694.     contains.
  8695.     
  8696.     The maximum length of $FLINE is 255 bytes.  You can use the SETLEN command
  8697.     to determine its actual length.
  8698.     
  8699.     
  8700.  
  8701.  
  8702.  
  8703.  
  8704.  
  8705.  
  8706.  
  8707.  
  8708.  
  8709.  
  8710.  
  8711.  
  8712.                                                                             149
  8713.     ------
  8714.     $FLUPC
  8715.     ------
  8716.     
  8717.     CONTAINS:    The line just read from the input file, in uppercase
  8718.     SEE ALSO:    The PROPER and CVTCASE commands
  8719.     
  8720.     $FLUPC is the same as the $FLINE variable, but in uppercase.  Any changes to
  8721.     $FLINE will affect $FLUPC, since they are simply different "views" of the
  8722.     same data.
  8723.     
  8724.     $FLUPC is useful for checking for text inside the current input line if case
  8725.     is not important, and for obtaining the uppercase version of the data. For
  8726.     example:
  8727.     
  8728.     BEGIN $FLUPC ^ "PART#"            <-- Detect "Part#", "part#" or "PART#"
  8729.       SET  partnum  = $FLUPC[10 15]   <-- Extract the part number, in uppercase
  8730.       SET  partname = $FLINE[16 30]   <-- Extract the part name, as-is
  8731.     END
  8732.     
  8733.     Since $FLUPC is really just a different view of $FLINE, a modification of
  8734.     $FLUPC (for example, using the PEEL command) is transient and usually
  8735.     pointless; the next reference to $FLUPC will simply return the uppercase
  8736.     version of $FLINE.
  8737.     
  8738.     ----------
  8739.     $LASTFLINE
  8740.     ----------
  8741.     
  8742.     CONTAINS:    The previous value of $FLINE
  8743.     SEE ALSO:    The discussion of $FLINE, above
  8744.     
  8745.     When parsing data, we frequently need to refer back to the input line we
  8746.     just saw.  This information is contained in the $LASTFLINE variable.
  8747.     
  8748.     The $LASTFLINE variable is affected by READNEXT, since that updates $FLINE.
  8749.     DBase files do not set $LASTFLINE, since they do not use $FLINE.
  8750.     
  8751.     At the start of parsing, $LASTFLINE is set to null ("").
  8752.     
  8753.     
  8754.  
  8755.  
  8756.  
  8757.  
  8758.  
  8759.  
  8760.  
  8761.  
  8762.  
  8763.  
  8764.  
  8765.  
  8766.  
  8767.                                                                             150
  8768.     ------
  8769.     $SPLIT
  8770.     ------
  8771.     
  8772.     CONTAINS:    The CHOP or SPLIT number you are currently processing
  8773.     SEE ALSO:    The GET and GETTEXT commands
  8774.     
  8775.     Since $FLINE has a maximum length of 255 characters, you will have to use
  8776.     the SPLIT or CHOP command if your input file is wider than that.
  8777.     
  8778.     NOTE:  Use SPLIT for text files
  8779.            Use CHOP for fixed-record-length files
  8780.     
  8781.     The $SPLIT variable reports which segment of a CHOPped or SPLIT input line
  8782.     you are currently processing.  For example, if you use this command...
  8783.     
  8784.     CHOP 1 255, 256 380
  8785.     
  8786.     then $SPLIT will be set to "1" when Parse-O-Matic processes columns 1 to
  8787.     255, and it will be set to "2" when processing columns 256 to 380.
  8788.     
  8789.     ------------
  8790.     $LINECOUNTER
  8791.     ------------
  8792.     
  8793.     CONTAINS:    The page line to which output will go next
  8794.     SEE ALSO:    "How Parse-O-Matic Opens an Output File"
  8795.     
  8796.     The $LINECOUNTER variable lets you know the number of the next output line.
  8797.     Consider this POM file:
  8798.     
  8799.     OUTEND |LINE# {$LINECOUNTER}
  8800.     OUTEND |LINE# {$LINECOUNTER}
  8801.     OUTEND |LINE# {$LINECOUNTER}
  8802.     DONE
  8803.     
  8804.     This will produce the following output:
  8805.     
  8806.     LINE# 1
  8807.     LINE# 2
  8808.     LINE# 3
  8809.     
  8810.     The OUTPAGE command will reset the $LINECOUNTER to "1", since the next
  8811.     output line will be at the top of the page.  OUTHDG commands also affect
  8812.     the $LINECOUNTER variable.
  8813.     
  8814.     The $LINECOUNTER variable is active even if you have not used the PAGELEN
  8815.     command to set the page length.  By default, the page length is "0" (meaning
  8816.     "infinite"), which means that $LINECOUNTER will always be one greater than
  8817.     the total number of output lines.  However, if you specify an explicit page
  8818.     length (e.g. PAGELEN "55"), $LINECOUNTER is reset to "1" after each page
  8819.     eject.
  8820.     
  8821.  
  8822.                                                                             151
  8823.     Using the SET command on $LINECOUNTER has no effect.  In some special cases,
  8824.     however, you may wish to reset $LINECOUNTER to "1".  You can do this -- even
  8825.     though you are not at the top of the page -- with the PAGELEN "0" command.
  8826.     (You can then follow this with another PAGELEN command if you want to
  8827.     restore the actual page length.)
  8828.     
  8829.     Here is a sample POM file that demonstrates why you might want to reset the
  8830.     $LINECOUNTER variable.  It will format a text file which contains a form
  8831.     feed character (ASCII 12) at the end of each page, while placing page numbers
  8832.     at the bottom of each page as a "running footing":
  8833.     
  8834.     PROLOGUE                        <-- Start of prologue
  8835.       MINLEN "0"                    <-- Allow null lines
  8836.       SET pagenum = "1"             <-- Set first page number
  8837.     END                             <-- End of prologue
  8838.     BEGIN $FLINE ^ #12              <-- Does this line have a form feed?
  8839.       BEGIN $LINECOUNTER #<= "54"   <-+
  8840.         OUTEND |                      | Put blank lines to the end of the page
  8841.         AGAIN                       <-+
  8842.       APPEND x pagenum #12          <-- Set up the footer (including form feed)
  8843.       PAD x "L" " " "80"            <-- Format the footer
  8844.       OUTEND |{x}                   <-- Output the footer
  8845.       SET pagenum = pagenum+        <-- Increment the page number
  8846.       PAGELEN "0"                   <-- Reset $LINECOUNTER to "1"
  8847.     ELSE
  8848.       OUTEND |    {$FLINE}          <-- Output a regular line
  8849.     END
  8850.     
  8851.     Note that as far as Parse-O-Matic is concerned, the "actual" output page
  8852.     length is "0" (i.e. "infinite"), but this POM file will output a text file
  8853.     that contains 55 lines per page.  (A POM file similar to the one shown is
  8854.     used, with several others, to format this manual.)
  8855.     
  8856.                     -------------------------------------------
  8857.                     Running Out of Variables, Literals or Lines
  8858.                     -------------------------------------------
  8859.     
  8860.     A POM file can contain 750 lines (not counting comment lines), and about
  8861.     2000 variables and literals.  If you have a very large POM file, this may
  8862.     not be enough, and you will be forced to do the processing with two or more
  8863.     POM files.  You can link these together with a batch file, as follows:
  8864.     
  8865.     @ECHO OFF
  8866.     POM POMFILE1.POM INPUT.TXT TEMP.TXT
  8867.     IF ERRORLEVEL 1 GOTO QUIT
  8868.     POM POMFILE2.POM TEMP.TXT  FINAL.TXT
  8869.     :QUIT
  8870.     
  8871.     
  8872.  
  8873.  
  8874.  
  8875.  
  8876.  
  8877.                                                                             152
  8878.                                      ----------
  8879.                                      Delimiters
  8880.                                      ----------
  8881.     
  8882.     If you need to specify a quotation mark, use "".  For example:
  8883.     
  8884.     IGNORE $FLINE = "He said ""Hello"" to me."
  8885.     
  8886.     This ignores any line containing:  He said "Hello" to me.
  8887.     
  8888.                                  ------------------
  8889.                                  Illegal Characters
  8890.                                  ------------------
  8891.     
  8892.     No POM command can contain these ASCII characters:
  8893.     
  8894.                          HEX    DECIMAL  NAME
  8895.                        -------  -------  --------------------
  8896.                          $00      #00    NULL
  8897.                          $0A      #10    LF (Linefeed)
  8898.                          $0D      #13    CR (Carriage Return)
  8899.     
  8900.     Of course, LF and CR do appear at the end of each line in the POM file,
  8901.     since a POM file is a text file.  If you need to use one of the illegal
  8902.     characters in a POM command, use either the $ or # character to denote
  8903.     hex or decimal literals (e.g. SET linefeed = $0A).
  8904.     
  8905.                                  -----------------
  8906.                                  Using Comparators
  8907.                                  -----------------
  8908.     
  8909.     Several POM command decide what to do by comparing two values. For example:
  8910.     
  8911.     IF $FLINE[1 3] = "XYZ" THEN x = "3" ELSE "4"
  8912.     
  8913.     In this example, if the first three characters of $FLINE are "XYZ", the
  8914.     variable x is set to "3", otherwise it is set to "4".  The first equals
  8915.     sign ("=") is a "comparator", because it defines how two values will be
  8916.     compared.  The second equals sign is not a comparator; it is simply
  8917.     padding, which makes the line easier to understand (see the section
  8918.     "Padding for Clarity" for details).
  8919.     
  8920.     Parse-O-Matic supports several types of comparators:
  8921.     
  8922.       TYPE OF
  8923.       COMPARATOR   WHAT IT DOES
  8924.       ----------   -------------------------
  8925.       Literal      Compares values character by character
  8926.       Numerical    Compares the arithmetic values of real or integer numbers
  8927.       Length       Compares the length of one value with a number
  8928.     
  8929.     
  8930.  
  8931.  
  8932.                                                                             153
  8933.     Whenever a comparator is required, but is omitted, it is assumed to be
  8934.     "literally identical".  Thus, the following lines are equivalent:
  8935.     
  8936.         IF x y z "3" "4"                   (This is very terse, but it works)
  8937.         IF x   y THEN z = "3" ELSE "4"     (The "equals" comparator is omitted)
  8938.         IF x = y THEN z = "3" ELSE "4"     (This is a lot easier to read)
  8939.     
  8940.     -------------------
  8941.     Literal Comparators
  8942.     -------------------
  8943.     
  8944.     Here is a list of literal comparators:
  8945.     
  8946.     
  8947.       COMPARATOR   MEANING                COMMENTS
  8948.       ----------   --------------------   -----------
  8949.       =            Identical
  8950.       <>           Not identical
  8951.       >            Higher                 See NOTE #1
  8952.       >=           Higher, or identical   See NOTE #1
  8953.       <            Lower                  See NOTE #1
  8954.       <=           Lower, or identical    See NOTE #1
  8955.       ^            Contains
  8956.       ~            Does not contain
  8957.       SAMEAS       Basically the same     See NOTE #2
  8958.       LONGER       Length is longer
  8959.       SHORTER      Length is shorter
  8960.       SAMELEN      Length is the same
  8961.     
  8962.     NOTE #1:  Depends on PC-ASCII sort order.  Refer to the section "Literal
  8963.               Comparisons and Sort Order" for details.
  8964.     
  8965.     NOTE #2:  The two variables are considered the same if they contain the same
  8966.               text, regardless of upper or lower case, and any surrounding
  8967.               whitespace.  Thus " CHESHIRE CAT " is the same as "Chesire Cat".
  8968.     
  8969.     With some restrictions (discussed later), literal comparators work on
  8970.     numeric and alphabetic data.  Here are some examples of literal comparisons
  8971.     that are "true":
  8972.     
  8973.       "ABC" <>      "ABCD"      "3" <>      "4"
  8974.       "ABC" <=      "ABCD"      "3" <=      "4"
  8975.       "ABC" <       "ABCD"      "3" <       "4"
  8976.       "ABC" SHORTER "ABCD"      "3" SAMELEN "4"
  8977.       "ABC" >=      "ABC"       "ABC" <>      "CDE"
  8978.       "ABC" <=      "ABC"       "ABC" <=      "CDE"
  8979.       "ABC" =       "ABC"       "ABC" <       "CDE"
  8980.       "ABC" ^       "ABC"       "ABC" SAMELEN "CDE"
  8981.       "ABC" SAMELEN "ABC"       "ABC" ~       "CDE"
  8982.     
  8983.     
  8984.  
  8985.  
  8986.  
  8987.                                                                             154
  8988.     ---------------------
  8989.     Numerical Comparators
  8990.     ---------------------
  8991.     
  8992.     Here is a list of numerical comparators:
  8993.     
  8994.       COMPARATOR   MEANING
  8995.       ----------   --------------------
  8996.       #=           Equal
  8997.       #<>          Not equal
  8998.       #>           Greater
  8999.       #>=          Greater, or equal
  9000.       #<           Less than
  9001.       #<=          Less than, or equal
  9002.     
  9003.     ------------------
  9004.     Length Comparators
  9005.     ------------------
  9006.     
  9007.     Here is a list of length comparators:
  9008.     
  9009.       COMPARATOR   MEANING
  9010.       ----------   --------------------
  9011.       LEN=         Equal
  9012.       LEN<>        Not equal
  9013.       LEN>         Greater
  9014.       LEN>=        Greater, or equal
  9015.       LEN<         Less than
  9016.       LEN<=        Less than, or equal
  9017.     
  9018.     The length of the value on the left side of the comparator is compared with
  9019.     a number on the right side of the comparator. For example:
  9020.     
  9021.     IF $FLINE LEN= "0" THEN NullLine = "YES" ELSE "NO"
  9022.     
  9023.     ----------------------------------
  9024.     Literal Comparisons and Sort Order
  9025.     ----------------------------------
  9026.     
  9027.     Some of the literal comparators compare text according to "PC-ASCII sort
  9028.     order".  For plain English text, this works fine.  However, if your text
  9029.     contains diacritical (accented) characters, you should be aware that
  9030.     some comparisons will not work correctly.  For example, the "A-Umlaut"
  9031.     character appears in the PC-ASCII character set AFTER the PC-ASCII value
  9032.     for "Z".
  9033.     
  9034.     
  9035.  
  9036.  
  9037.  
  9038.  
  9039.  
  9040.  
  9041.  
  9042.                                                                             155
  9043.     -------------------
  9044.     Numeric Comparisons
  9045.     -------------------
  9046.     
  9047.     Some confusion can arise if you use literal comparators on numbers.  For
  9048.     example, this doesn't work as you might expect at first glance:
  9049.     
  9050.     SET count = count+
  9051.     BEGIN count >= "2"
  9052.       OUTEND x = x |{count}
  9053.     END
  9054.     
  9055.     You might expect this POM file to output any number greater than or equal
  9056.     to "2", but in fact, you will get a different result, because the
  9057.     comparison is a literal (text) comparison.  In the example above, "2" to
  9058.     "9" are greater or equal to "2", but "10" (which starts with "1") is less,
  9059.     as is evident when you sort several numbers alphabetically:
  9060.     
  9061.     1
  9062.     10
  9063.     11
  9064.     15
  9065.     100
  9066.     2
  9067.     20
  9068.     200
  9069.     3
  9070.     30
  9071.     
  9072.     As you can see, the values 1, 10, 11 and 15 come before "2" when sorted
  9073.     alphabetically.
  9074.     
  9075.     To compare numbers, you should use the numeric comparators.  The correct
  9076.     way to code the previous example is as follows:
  9077.     
  9078.     SET count = count+
  9079.     BEGIN Count #>= "2"           <-- Note the #>= comparator
  9080.       OUTEND x = x |{count}
  9081.     END
  9082.     
  9083.     Written in this way, numbers greater than or equal to two will be output.
  9084.     
  9085.     
  9086.  
  9087.  
  9088.  
  9089.  
  9090.  
  9091.  
  9092.  
  9093.  
  9094.  
  9095.  
  9096.  
  9097.                                                                             156
  9098.     Here are some examples of numeric comparisons that are "true":
  9099.     
  9100.                     "345" #<>  "567"         "1.23" #<>  "9.87"
  9101.     
  9102.                     "345" #<=  "567"         "1.23" #<=  "9.87"
  9103.     
  9104.                     "567" #>   "345"         "9.87" #>   "1.23"
  9105.     
  9106.                     "3"   #<   "6.2"
  9107.     
  9108.     The last example compares an integer ("3") with a real number ("6.2"). The
  9109.     numeric comparators automatically check if one of the numbers contains a
  9110.     decimal point.  In such case, the comparison is performed in "real number"
  9111.     mode, which imposes the accuracy restrictions described in the section "The
  9112.     CalcReal Command".  This might create a problem if you are comparing a
  9113.     decimal number with a large integer, but this is rarely a cause for worry,
  9114.     since most parsing jobs tend to compare similar types of numbers.
  9115.     
  9116.     -------------------------------
  9117.     Upgrading from Earlier Versions
  9118.     -------------------------------
  9119.     
  9120.     IF YOU USED PARSE-O-MATIC PRIOR TO VERSION 3.00:  Because the comparator
  9121.     defaults to "literally identical" if it is omitted, POM files created
  9122.     before version 3.00 will continue to function normally -- with two notable
  9123.     exceptions. In older versions, the IGNORE and ACCEPT commands defaulted to
  9124.     "contains". If you have POM files that were created for older versions, you
  9125.     should check your IGNORE and ACCEPT commands to ensure that they are doing
  9126.     what you want them to.
  9127.     
  9128.                                ---------------------
  9129.                                Predefined Data Types
  9130.                                ---------------------
  9131.     
  9132.     For certain commands (e.g. MAKEDATA, MAKETEXT, GET and GETTEXT),
  9133.     Parse-O-Matic has internal definitions of certain data representations;
  9134.     these are known as Parse-O-Matic's "predefined data types":
  9135.     
  9136.            DATA TYPE  BYTES  MINIMUM VALUE MAXIMUM VALUE  COMMENTS
  9137.            ---------  -----  ------------- -------------  -----------
  9138.            BYTE         1                0           255
  9139.            INTEGER      2           -32768         32767
  9140.            LONGINT      4      -2147483648    2147483647
  9141.            REAL         6    -9999999999.9  9999999999.9  See NOTE #1
  9142.            SHORTINT     1             -128           127
  9143.            WORD         2                0         65535
  9144.            DATE         -                -             -  See NOTE #2
  9145.            TRIMMED      -          0 chars     255 chars  See NOTE #3
  9146.     
  9147.     NOTE #1:  The minimum and maximum values depend on the number of digits of
  9148.               precision.  See "The CalcReal Command" for details.
  9149.     
  9150.     
  9151.  
  9152.                                                                             157
  9153.     NOTE #2:  The DATE type does not have a specific length.  In some input
  9154.               files, a date serial number might be represented by a numeric
  9155.               format such as INTEGER or LONGINT.  For more information, see
  9156.               the discussions of the MAKETEXT, MAKEDATA and GETTEXT commands.
  9157.     
  9158.     NOTE #3:  The TRIMMED type does not have a specific length.  You can use
  9159.               it with MAKETEXT and GETTEXT commands to remove the spaces, tabs
  9160.               and nulls on either side of a string.  It can also be used with
  9161.               MAKEDATA, but since this can produce a field of indeterminate
  9162.               length, it is rarely useful in such a role.
  9163.     
  9164.     Certain predefined data types can have a qualifier, which provides
  9165.     additional information.  All commands that use predefined data types will
  9166.     accept the qualifier, but only the MAKETEXT command makes use of it.
  9167.     
  9168.     DATA TYPE  QUALIFIER DESCRIPTION     EXAMPLES
  9169.     ---------  ------------------------  -------------------------------------
  9170.     REAL       Number of decimal places  "REAL 2" -> 3.14  "REAL 4" -> 3.1415
  9171.     DATE       Date format               "DATE ?y/?n/?d" -> "96/12/01"
  9172.     
  9173.     -----------------------------------
  9174.     Interpreting Data Formats in a File
  9175.     -----------------------------------
  9176.     
  9177.     When inspecting a hex dump of a binary file, bear in mind that on
  9178.     PC-compatible computers, the bytes that comprise a number are often
  9179.     reversed.  For example, for the INTEGER and WORD data types, the eight most
  9180.     significant bits of numeric values are usually placed AFTER the eight least
  9181.     significant bits.  Thus, the decimal value 5099 will appear as EB 13 in the
  9182.     file, not 13 EB, despite the fact that decimal 5099 equals hex 13EB.
  9183.     
  9184.     If you are dealing with data that treats numbers differently, you can
  9185.     sometimes work around the problem by reversing the order of the bytes
  9186.     before performing the conversion.  For example, if the file contains a WORD
  9187.     data type, but has the most significant byte FIRST, you can switch things
  9188.     around, as demonstrated by this POM file:
  9189.     
  9190.     CHOP     0                      <-- Read the file manually
  9191.     GET      x "WORD"               <-- Get two bytes from the file
  9192.     APPEND   y = x[2] x[1]          <-- Flip the bytes around
  9193.     MAKETEXT z y "WORD"             <-- Convert the number
  9194.     OUTEND   |{z}                   <-- Output the result
  9195.     
  9196.     
  9197.     
  9198.  
  9199.  
  9200.  
  9201.  
  9202.  
  9203.  
  9204.  
  9205.  
  9206.  
  9207.                                                                             158
  9208.     ============================================================================
  9209.                                  DEDUCED VARIABLES
  9210.     ============================================================================
  9211.     
  9212.                                  -----------------
  9213.                                  Deduced Variables
  9214.                                  -----------------
  9215.     
  9216.     ----------
  9217.     Definition
  9218.     ----------
  9219.     
  9220.     "Deduced Variable Names" (generally referred to as "Deduced Variables")
  9221.     provide you with powerful means for organizing and processing data.  This
  9222.     particular approach to handling variable data is not available in most
  9223.     high-level languages (e.g. C, Pascal, Basic) but is extremely helpful for a
  9224.     content-oriented language such as Parse-O-Matic.
  9225.     
  9226.     A deduced variable is a variable for which the actual name is not known when
  9227.     the program is being written.  The name itself is deduced when the actual
  9228.     POM line is run.  It is almost as if you could write a line like this:
  9229.     
  9230.     SET whatever-variable-I-should-be-using-now = "3"
  9231.     
  9232.     There are several rules by which the name is deduced.  By creating similar
  9233.     circumstances later on in the program, you can deduce the same variable name
  9234.     in another spot.
  9235.     
  9236.     Deduced variables are always surrounded by parentheses.  Here are some
  9237.     sample deduced variable names:
  9238.     
  9239.     SAMPLE      PARTS*  DEDUCTIONS  EQUIVALENT VARIABLE NAME
  9240.     ----------  ------  ----------  ------------------------
  9241.     (X)           1       None      X
  9242.     (X,Y)         2       None      X,Y
  9243.     (X,Y,Z)       3       None      X,Y,Z
  9244.     (X,@Y)        2         1       X,something
  9245.     (X,@Y,@Z)     3         2       X,something,something
  9246.     (@X,YYY,@Z)   3         2       something,YYY,something
  9247.     
  9248.     (*) A deduced variable has a maximum of three parts.
  9249.     
  9250.     As you can see:
  9251.     
  9252.     - When part of the deduced variable is NOT preceded by the "@" character,
  9253.       it is taken "as-is".
  9254.     
  9255.     - When part of the deduced variable **IS** preceded by the "@" character,
  9256.       it must be looked up.
  9257.     
  9258.     
  9259.  
  9260.  
  9261.  
  9262.                                                                             159
  9263.     -------------------
  9264.     The Look-Up Process
  9265.     -------------------
  9266.     
  9267.     The look-up process is simple:  Parse-O-Matic looks up the variable following
  9268.     the "@" character and inserts it into the deduced variable name.  For example:
  9269.     
  9270.     SET     Y = "BBB"
  9271.     SET     Z = "CCC"
  9272.     SET     (AAA,@Y,@Z) = "Quick Brown Fox"
  9273.     SET     line = (AAA,BBB,CCC)
  9274.     OUTEND  |{line}
  9275.     
  9276.     ------------
  9277.     Restrictions
  9278.     ------------
  9279.     
  9280.     There are certain limitations that affect the use of deduced variables.
  9281.     
  9282.     - You can not use them in the output picture of an OUT or OUTEND command.
  9283.       For example, the following line will result in an error:
  9284.     
  9285.       OUTEND  |We have {(PRODSTOCK,@PRODNUM} {(PRODNAMES,@PRODNUM)} in stock.
  9286.     
  9287.       The correct way to do this is as follows:
  9288.     
  9289.       SET     prodstock = (PRODSTOCK,@PRODNUM)
  9290.       SET     prodname  = (PRODNAMES,@PRODNUM)
  9291.       OUTEND  |We have {prodstock} {prodname} in stock.
  9292.     
  9293.     - The length of the deduced variable name can not exceed 12 characters.
  9294.       The following lines will result in an error:
  9295.     
  9296.       SET Part2 = "YYYYYYYYYY"
  9297.       SET Part3 = "ZZZZZZZZZZ"
  9298.       SET (XX,@Part2,@Part3) = "99"
  9299.     
  9300.       This causes an error because Parse-O-Matic tries to create a variable
  9301.       named XX,YYYYYYYYYY,ZZZZZZZZZZ -- which is 24 characters long (including
  9302.       the commas).  The maximum length for a Parse-O-Matic variable (of any
  9303.       kind) is 12 characters.  The following lines WOULD work:
  9304.     
  9305.       SET Part2 = "YYYY"
  9306.       SET Part3 = "ZZZZ"
  9307.       SET (XX,@Part2,@Part3) = "99"
  9308.     
  9309.       This would set the variable XX,YYYY,ZZZZ (which is 12 characters long,
  9310.       counting the commas) to "99".
  9311.     
  9312.     
  9313.  
  9314.  
  9315.  
  9316.  
  9317.                                                                             160
  9318.     - Deduced variables can not be used for variable CALL commands.  The
  9319.       following line would not work:
  9320.     
  9321.       CALL (ROUTINE,@RTYPE)
  9322.     
  9323.       You would have to do this as follows:
  9324.     
  9325.       SET  CallTemp = (ROUTINE,@RTYPE)
  9326.       CALL CallTemp
  9327.     
  9328.     ----------------
  9329.     Usage Guidelines
  9330.     ----------------
  9331.     
  9332.     If you know the precise name of the deduced variable you are setting, you
  9333.     can specify it directly, without the parentheses.  Thus, the following
  9334.     two commands are the same:
  9335.     
  9336.       SET (CUST,NAME,1) = "Fred Jones"
  9337.       SET  CUST,NAME,1  = "Fred Jones"
  9338.     
  9339.     In other words, if a deduced variable name does not include a look-up (i.e.
  9340.     the "@" character), it is not actually being deduced.
  9341.     
  9342.     If you use substrings with deduced variables, you must specify the indexes
  9343.     immediately after the closing parenthesis.  Thus:
  9344.     
  9345.       (Data,@Y,@Z)[10 80]               <-- This is okay
  9346.       (Data,@Y,@Z)  [10 80]             <-- This is wrong
  9347.       ( Data, @Y, @Z )[ 10 80 ]         <-- This is okay
  9348.     
  9349.     The third example shows that you can use spaces within the parentheses and
  9350.     the brackets to improve readability.
  9351.     
  9352.     Variables are "persistent" (see "Uninitialized and Persistent Variables").
  9353.     This can be a problem if you are creating variables (particularly arrays)
  9354.     while processing multiple input files:  all variables created for the
  9355.     previous input file are still around.  For this reason, you may find it
  9356.     necessary to create an initializing section (in the PROLOGUE) which ensures
  9357.     that all working variables are "set to zero", so to speak.
  9358.     
  9359.     
  9360.  
  9361.  
  9362.  
  9363.  
  9364.  
  9365.  
  9366.  
  9367.  
  9368.  
  9369.  
  9370.  
  9371.  
  9372.                                                                             161
  9373.                                   ---------------
  9374.                                   Array Variables
  9375.                                   ---------------
  9376.     
  9377.                    NOTE:  For background information, please see
  9378.                           "Deduced Variables - Definition".
  9379.     
  9380.     Array variables are deduced variables that use something distinctive about
  9381.     each input item (e.g. a product number) to allow data for similar input
  9382.     items to be treated in the same way.  Here is an example of array handling:
  9383.     
  9384.     -------------------------
  9385.     Example:  Product Numbers
  9386.     -------------------------
  9387.     
  9388.     A common requirement in data processing is to assign a number to items that
  9389.     are different instances of the same thing.  For example, let's say your
  9390.     input file contained a summary of the number of items sold at your store at
  9391.     various times of the day.  You could assign a "Product Number" to each item,
  9392.     as in the following four-line input file:
  9393.     
  9394.     10:33 AM  101  Oranges    15
  9395.     11:04 AM  102  Lemons      4
  9396.     03:15 PM  104  Bananas    20
  9397.     04:41 PM  102  Lemons     25
  9398.     :         :    :          :
  9399.     :         :    :          :
  9400.     Time   Product Product    Quantity
  9401.     Sold   Code    Name       Sold
  9402.     
  9403.     You could add up the total sales for each item, as follows:
  9404.     
  9405.     SET  ProdCode = $FLINE[11 13]
  9406.     SET  Quantity = $FLINE[27 28]
  9407.     SET  (Name,@ProdCode) = $FLINE[16 22]
  9408.     CALC (Sold,@ProdCode) = (Sold,@ProdCode) "+" Quantity
  9409.     
  9410.     The first three lines obtain the product code (e.g. 101 for Oranges), the
  9411.     quantity sold, and the product name.  The fourth line adds the quantity sold
  9412.     to the appropriate product.  Thus, after all four input lines have been
  9413.     processed, you will have created six deduced variables:
  9414.     
  9415.     VARIABLE         VALUE
  9416.     ---------------  -----
  9417.     Name,101         "Oranges"
  9418.     Name,102         "Lemons "
  9419.     Name,104         "Bananas"
  9420.     Sold,101         "15"
  9421.     Sold,102         "29"         <-- "29" is the total of 2nd and 4th input lines
  9422.     Sold,104         "20"
  9423.     
  9424.     
  9425.  
  9426.  
  9427.                                                                             162
  9428.     There are no variables created for product numbers that did not appear in
  9429.     the input file, so if (for example) you test the value of Sold,103 it will
  9430.     be reported as a null (empty) value.  That is because it was never assigned
  9431.     a value.
  9432.     
  9433.     Now that you have added up the totals, you can output them in the EPILOGUE
  9434.     section of the POM file.  (The EPILOGUE is the last section of POM code run,
  9435.     after all the input lines have been read.)
  9436.     
  9437.     EPILOGUE
  9438.       SET   MaxProdCode = "104"
  9439.       SET   ProdCode = "100"
  9440.       BEGIN
  9441.         IF     (Sold,@ProdCode) <> "" THEN NumSold = (Sold,@ProdCode) ELSE "NONE"
  9442.         PAD    (Name,@ProdCode) "R" " " "7"
  9443.         SET    ProdName = (Name,@ProdCode)
  9444.         OUTEND |Product # {ProdCode} ({ProdName}):  Sold {NumSold}
  9445.         SET    ProdCode = ProdCode+
  9446.       AGAIN ProdCode #<= MaxProdCode
  9447.     END
  9448.     
  9449.     The output from the POM file will look like this:
  9450.     
  9451.     Product # 100 (       ): Sold NONE
  9452.     Product # 101 (Oranges): Sold 15
  9453.     Product # 102 (Lemons ): Sold 29
  9454.     Product # 103 (       ): Sold NONE
  9455.     Product # 104 (Bananas): Sold 20
  9456.     
  9457.     There is no data for products 100 and 103, since they did not appear in the
  9458.     input file, so they do not show any data in the output.
  9459.     
  9460.     -----------------------
  9461.     Multidimensional Arrays
  9462.     -----------------------
  9463.     
  9464.     The example given above used "two dimensional arrays", which is to say that
  9465.     each array has two parts (e.g. Sold,101 has the parts Sold and 101).  Since
  9466.     deduced variables can have up to three parts, you can create arrays of up to
  9467.     three dimensions.
  9468.     
  9469.     
  9470.  
  9471.  
  9472.  
  9473.  
  9474.  
  9475.  
  9476.  
  9477.  
  9478.  
  9479.  
  9480.  
  9481.  
  9482.                                                                             163
  9483.                                 -------------------
  9484.                                 Eponymous Variables
  9485.                                 -------------------
  9486.     
  9487.                    NOTE:  For background information, please see
  9488.                           "Deduced Variables - Definition".
  9489.     
  9490.     Sometimes you do not have a convenient number (such as a product number) to
  9491.     organize your arrays.  In such cases, you can use the input item itself as
  9492.     the name of the variable.  This technique is known as "eponymous variables".
  9493.     (Eponymous means "self-naming".)
  9494.     
  9495.     Let us say your store sells only two items -- dogs and cats -- and you do
  9496.     not have a product number for each.   Your input file may look like this:
  9497.     
  9498.     10:00  Cat    1
  9499.     10:30  Dog    2
  9500.     11:00  Cat   10
  9501.     11:30  Cat    1
  9502.     12:00  Dog    1
  9503.     
  9504.     You can add up the items with the following POM file:
  9505.     
  9506.     SET   type  = $FLINE[ 8 10]
  9507.     SET   quant = $FLINE[14 15]
  9508.     CALC  (@type) = (@type) "+" quant
  9509.     
  9510.     After all of the input lines are read, you will have created two eponymous
  9511.     variables, as follows:
  9512.     
  9513.     VARIABLE         VALUE
  9514.     ---------------  -----
  9515.     Cat              "12"     <-- Total of input lines 1, 3 and 4
  9516.     Dog              "3"      <-- Total of input lines 2 and 5
  9517.     
  9518.     The totals can then be output in the EPILOGUE, using the following POM code:
  9519.     
  9520.     EPILOGUE
  9521.       OUTEND |Cats sold:  {Cat}
  9522.       OUTEND |Dogs sold:  {Dog}
  9523.     END
  9524.     
  9525.     If you decide to add cows to your product line-up, you need only add a
  9526.     single line to your EPILOGUE:
  9527.     
  9528.       OUTEND |Cows sold:  {Cow}
  9529.     
  9530.     Eponymous techniques can be more complicated than the example shown.  For
  9531.     example, you could create sub-categories such as Dog,Beagle,Large.
  9532.     
  9533.     
  9534.     
  9535.  
  9536.  
  9537.                                                                             164
  9538.     ------------------------
  9539.     Drawbacks and Advantages
  9540.     ------------------------
  9541.     
  9542.     The main drawback of eponymous variables is that the POM file must "know"
  9543.     all the possible variable names in order to output them.  If you have a
  9544.     small number of items (e.g. Cat, Dog, Cow) this is not a serious problem.
  9545.     If you DO have a large number of items, you can build an array -- "on the
  9546.     fly" as it were -- that adds each new eponymous variable name as it is
  9547.     created. You could then loop through this array, during output, to obtain
  9548.     the names.
  9549.     
  9550.     This may sound complex, but it is enormously powerful.  It means that you
  9551.     can create a parsing application that can handle input files containing
  9552.     items whose names are unknown to you.  A properly constructed POM file would
  9553.     handle new items without any modifications to the POM code.
  9554.     
  9555.     
  9556.     
  9557.  
  9558.  
  9559.  
  9560.  
  9561.  
  9562.  
  9563.  
  9564.  
  9565.  
  9566.  
  9567.  
  9568.  
  9569.  
  9570.  
  9571.  
  9572.  
  9573.  
  9574.  
  9575.  
  9576.  
  9577.  
  9578.  
  9579.  
  9580.  
  9581.  
  9582.  
  9583.  
  9584.  
  9585.  
  9586.  
  9587.  
  9588.  
  9589.  
  9590.  
  9591.  
  9592.                                                                             165
  9593.     ============================================================================
  9594.                                   VALUE TECHNIQUES
  9595.     ============================================================================
  9596.     
  9597.                 This section describes useful techniques you can use
  9598.                      when dealing with variables and literals.
  9599.     
  9600.                        --------------------------------------
  9601.                        Uninitialized and Persistent Variables
  9602.                        --------------------------------------
  9603.     
  9604.     Even before a variable is assigned a value (using the SET command, for
  9605.     example), you can use it in a POM command.  An uninitialized variable has a
  9606.     null value ("") and is treated normally by all commands.
  9607.     
  9608.     EXCEPTION:  To help you catch coding errors, the OUT and OUTEND commands
  9609.     do not allow you to output an uninitialized variable.  If you attempt to
  9610.     do so, Parse-O-Matic issues a warning, and processing is terminated.
  9611.     
  9612.     Variables are "persistent":  once you have assigned a value to a variable,
  9613.     it retains that value until it is changed.  Even if you open a new input
  9614.     file (see "POM and Wildcards") or a new output file (see "The OFile
  9615.     Command"), all variables will retain their values; they will not be "reset"
  9616.     back to null.  (Of course, when Parse-O-Matic ends, all variables
  9617.     disappear; they are not retained between separate runs of POM.)
  9618.     
  9619.     -------
  9620.     Example
  9621.     -------
  9622.     
  9623.     Here is an example which illustrates why persistent variables are useful:
  9624.     
  9625.     PAGELEN "55"                       <-- Set page length
  9626.     SET partnum = $FLINE[ 1 10]        <-- Extract the part number
  9627.     SET descrip = $FLINE[12 60]        <-- Extract the description
  9628.     BEGIN lastpart <> partnum          <-- Is this a new part number?
  9629.       OUTPAGE                          <-- Generate a page eject
  9630.       OUTHDG |PartNumber Description   <-- Output a heading
  9631.       OUTHDG |---------- -----------   <-- Output a heading
  9632.       SET    lastpart = partnum        <-- Remember the current part number
  9633.     END                                <-- End of BEGIN block
  9634.     OUTEND |{partnum} {descrip}        <-- Output the part number
  9635.     
  9636.     The first time a line is read from the input file, the lastpart variable
  9637.     will be null ("") because it has not yet been initialized.  As a result,
  9638.     the BEGIN block will be executed.  (The OUTPAGE command will be ignored
  9639.     in this first instance, since no data has been sent to the output file.)
  9640.     The BEGIN block also sets the lastpart variable, which will retain that
  9641.     value until it is changed.
  9642.     
  9643.     
  9644.  
  9645.  
  9646.  
  9647.                                                                             166
  9648.     When the second input line is read (and the POM code is run again from the
  9649.     top), the BEGIN block will be run only if the current part number is
  9650.     different from the previous one (which we saved in the lastpart variable).
  9651.     However, if the partnum variable is different, the BEGIN block will be run,
  9652.     outputting the page eject and headings, and once again saving the partnum
  9653.     in the lastpart variable, so we can check it during the third input line --
  9654.     and so on.
  9655.     
  9656.                         ------------------------------------
  9657.                         Inline Incrementing and Decrementing
  9658.                         ------------------------------------
  9659.     
  9660.     You can add "1" to a variable in a command.  For example:
  9661.     
  9662.     SET x = "3"
  9663.     SET x = x+
  9664.     
  9665.     After the second statement, x would have the value "4".  Here are some
  9666.     additional examples:
  9667.     
  9668.     - Incrementing "1" gives you "2"
  9669.     - Incrementing "9" gives you "10"
  9670.     - Incrementing "99" gives you "100"
  9671.     
  9672.     The first time a variable is referenced, it has a null value (unless you
  9673.     SET it yourself).  If you increment a null variable, it will be changed
  9674.     from "" (i.e. null) to "1".
  9675.     
  9676.     You can also subtract "1" from a variable in a command:
  9677.     
  9678.     SET x = "3"
  9679.     SET x = x-
  9680.     
  9681.     After the second statement, x would have the value "2".  Here are some
  9682.     additional examples:
  9683.     
  9684.     - Decrementing "0" gives you "-1"
  9685.     - Decrementing "1" gives you "0"
  9686.     - Decrementing "99" gives you "98"
  9687.     
  9688.     When you do an inline increment or decrement, the variable itself is not
  9689.     changed.  (C programmers take note!)  For example:
  9690.     
  9691.     SET y = "3"
  9692.     SET x = y-
  9693.     
  9694.     After the second line, the x variable will equal "2", while the y variable
  9695.     will still equal "3".
  9696.     
  9697.     
  9698.  
  9699.  
  9700.  
  9701.  
  9702.                                                                             167
  9703.     You can use inline incrementing or decrementing with substrings:
  9704.     
  9705.     SET y = "X23X"
  9706.     SET x = y[2 3]+
  9707.     
  9708.     After the second line, the x variable will equal "24", while the y variable
  9709.     will still equal "X23X".
  9710.     
  9711.     Only integer numeric values can be incremented or decremented.  If you
  9712.     attempt to increment or decrement another type of variable (e.g. text or a
  9713.     decimal number), Parse-O-Matic will halt, and report an error.
  9714.     
  9715.                                    -------------
  9716.                                    Line Counters
  9717.                                    -------------
  9718.     
  9719.     If your input record is divided over several lines (due to its original
  9720.     format or perhaps because you used the SPLIT or CHOP command), it is
  9721.     helpful to set up a line counter.  The following example extracts the first
  9722.     six characters of the second line of input records that span three lines
  9723.     (designated lines 0, 1 & 2):
  9724.     
  9725.     IF     LineCntr = "1" THEN MyField = $FLINE[1 6]
  9726.     OUTEND LineCntr = "1" |{MyField}
  9727.     IF     LineCntr = "2" THEN LineCntr = "" ELSE LineCntr+
  9728.     
  9729.     For an alternative to line counters, see "The ReadNext Command".
  9730.     
  9731.                                 -------------------
  9732.                                 The SHOWNUM Utility
  9733.                                 -------------------
  9734.     
  9735.     The ShowNum program (SHOWNUM.EXE in the standard Parse-O-Matic package) is a
  9736.     small utility which converts a hex number to decimal and vice-versa. It can
  9737.     also convert a character to its ASCII equivalent value in decimal or hex.
  9738.     
  9739.     ShowNum is helpful when you are working on a task that forces you to deal
  9740.     with data in hex or decimal form.  It is a handy tool if you are working
  9741.     with binary input or output files.
  9742.     
  9743.     You can probably find fancier conversion-reference utilities than SHOWNUM,
  9744.     but this one comes ready-to-go with Parse-O-Matic -- and it is free.  You
  9745.     may give unaltered copies of SHOWNUM to anybody without paying royalties.
  9746.     
  9747.     ----------------------
  9748.     Quick Reference Screen
  9749.     ----------------------
  9750.     
  9751.     To display a quick-reference help screen, enter the following command at
  9752.     the DOS prompt:
  9753.     
  9754.     SHOWNUM /?
  9755.     
  9756.  
  9757.                                                                             168
  9758.     If you are calling SHOWNUM from Windows, you can add the /P (Pause) option
  9759.     to make it wait for a keypress before terminating:
  9760.     
  9761.     SHOWNUM /? /P
  9762.     
  9763.     -------------------
  9764.     Converting a Number
  9765.     -------------------
  9766.     
  9767.     To find out what the decimal number 123 is in hexadecimal, enter the
  9768.     following command at the DOS prompt:
  9769.     
  9770.     SHOWNUM #123
  9771.     
  9772.     The # character tells ShowNum that the number is in decimal.  The program
  9773.     will display:
  9774.     
  9775.     #123 = $7B
  9776.     
  9777.     To find out what hex 400F is in decimal, enter the following command at
  9778.     the DOS prompt:
  9779.     
  9780.     SHOWNUM $400F
  9781.     
  9782.     The $ character tells ShowNum that the number is in hexadecimal.  The
  9783.     program will display:
  9784.     
  9785.     $400F = #16399
  9786.     
  9787.     ShowNum can handle numbers between -2,147,483,648 (hex $80000000) and
  9788.     2,147,483,647 (hex $7FFFFFFF).
  9789.     
  9790.     ----------------------
  9791.     Converting a Character
  9792.     ----------------------
  9793.     
  9794.     To find out a character's ASCII equivalent value in decimal and hex, use
  9795.     the SHOWNUM utility this way:
  9796.     
  9797.     SHOWNUM A
  9798.     
  9799.     This will display:
  9800.     
  9801.     A = #65 $41
  9802.     
  9803.     In other words, the letter "A" is ASCII decimal 65, which is hex 41.
  9804.     
  9805.     
  9806.  
  9807.  
  9808.  
  9809.  
  9810.  
  9811.  
  9812.                                                                             169
  9813.     You can enclose the character in quotes if you wish.  This is strictly
  9814.     necessary only if you are trying to remember the values for "space":
  9815.     
  9816.     SHOWNUM " "
  9817.     
  9818.     This will display:
  9819.     
  9820.     " " = #32 $20
  9821.     
  9822.     Character conversion works only one character at a time:
  9823.     
  9824.     SHOWNUM "ABCD"       <-- This is incorrect
  9825.     
  9826.     This would display:
  9827.     
  9828.     "ABCD" = #65 $41
  9829.     
  9830.     As you can see, only the first character ("A") is being converted.
  9831.     
  9832.     ----------------------
  9833.     Windows Considerations
  9834.     ----------------------
  9835.     
  9836.     If you call SHOWNUM.EXE from Windows, your answer will vanish when the program
  9837.     ends and the window closes.  For this reason, the file SHOWNUM.BAT has been
  9838.     included in the standard Parse-O-Matic package.  You can use this exactly
  9839.     like SHOWNUM.EXE, but it pauses after the answer is displayed.
  9840.     
  9841.     For additional details, see "Installing the SHOWNUM Utility" in the "Running
  9842.     Under Windows" section of this manual.
  9843.     
  9844.     
  9845.     
  9846.  
  9847.  
  9848.  
  9849.  
  9850.  
  9851.  
  9852.  
  9853.  
  9854.  
  9855.  
  9856.  
  9857.  
  9858.  
  9859.  
  9860.  
  9861.  
  9862.  
  9863.  
  9864.  
  9865.  
  9866.  
  9867.                                                                             170
  9868.     ============================================================================
  9869.                                PROGRAMMING TECHNIQUES
  9870.     ============================================================================
  9871.     
  9872.                     This section describes techniques that will
  9873.                         help you create and debug POM files.
  9874.     
  9875.                                       -------
  9876.                                       Tracing
  9877.                                       -------
  9878.     
  9879.     By setting the DOS variable POM to ALL, you can generate a trace file,
  9880.     named POM.TRC.  This is helpful if you have trouble understanding why your
  9881.     file isn't being parsed properly.  But be sure to test it with a SMALL
  9882.     input file; the trace is quite detailed, and it can easily generate a huge
  9883.     output file.
  9884.     
  9885.     To save space, you can specify a particular list of variables to be traced,
  9886.     rather than tracing everything.  For example, to trace only the variable
  9887.     PRICE, enter this DOS command:
  9888.     
  9889.     SET POM=PRICE
  9890.     
  9891.     To trace several variables, separate the variable names by slashes, as in
  9892.     this example:
  9893.     
  9894.     SET POM=PRICE/BONUS/NAME
  9895.     
  9896.     This traces the three variables PRICE, BONUS and NAME.
  9897.     
  9898.                                       -------
  9899.                                       Logging
  9900.                                       -------
  9901.     
  9902.     Every time Parse-O-Matic runs, it creates a "processing log".  This is a
  9903.     text file named POMLOG.TXT, which is placed in Parse-O-Matic's home
  9904.     directory.  (For example, if POM.EXE is located in C:\POM, the file will
  9905.     be C:\POM\POMLOG.TXT even if you run POM from another directory.)  If the
  9906.     file POMLOG.TXT already exists, it is renamed to POMLOG.BAK.
  9907.     
  9908.     The processing log file POMLOG.TXT contains a report of what happened
  9909.     during the last run of Parse-O-Matic.  Usually, the file will be quite
  9910.     short and look something like this:
  9911.     
  9912.         COMMAND: POM TEST.POM TEST.TXT TEMP.TXT
  9913.         DATE:    AUG 01 1997
  9914.     
  9915.         17:50:10 TEST.TXT opened for processing
  9916.         17:50:14 TEST.TXT processing completed
  9917.     
  9918.     The first line gives the DOS command line, while the second gives the
  9919.     date.  Subsequent lines give the time (Hours:Minutes:Seconds) and a
  9920.     progress or error message.
  9921.  
  9922.                                                                             171
  9923.     If you encounter an error during processing, the text of the warning
  9924.     message is saved in the processing log.  It might look something like this:
  9925.     
  9926.         COMMAND: POM TEST.POM TEST.TXT TEMP.TXT
  9927.         DATE:    AUG 01 1997
  9928.     
  9929.         17:50:10 TEST.TXT opened for processing
  9930.         17:50:10 Execution error in line number 3 of POM file TEST.POM
  9931.         17:50:11 Required parameter is missing in OUT
  9932.     
  9933.     If you process multiple input files, POMLOG.TXT might look something
  9934.     like this:
  9935.     
  9936.         COMMAND: POM EXAMPL15.POM DATA*.TXT TEMP.TXT
  9937.         DATE:    AUG 01 1997
  9938.     
  9939.         14:21:27 DATA01.TXT opened for processing
  9940.         14:21:28 DATA01.TXT processing completed
  9941.     
  9942.         14:21:28 DATA02.TXT opened for processing
  9943.         14:21:28 DATA02.TXT processing completed
  9944.     
  9945.         14:21:28 DATA03.TXT opened for processing
  9946.         14:21:28 DATA03.TXT processing completed
  9947.     
  9948.         14:21:28 3 files processed
  9949.     
  9950.     If for some reason the processing log can not be created, Parse-O-Matic
  9951.     will continue to run; it will not terminate.  For some additional comments
  9952.     on logging, see "Unattended Operation".
  9953.     
  9954.     
  9955.     
  9956.  
  9957.  
  9958.  
  9959.  
  9960.  
  9961.  
  9962.  
  9963.  
  9964.  
  9965.  
  9966.  
  9967.  
  9968.  
  9969.  
  9970.  
  9971.  
  9972.  
  9973.  
  9974.  
  9975.  
  9976.  
  9977.                                                                             172
  9978.     ============================================================================
  9979.                               COMMAND-LINE TECHNIQUES
  9980.     ============================================================================
  9981.     
  9982.                      This section describe the various options
  9983.                            available at the command line.
  9984.     
  9985.                                      ----------
  9986.                                      Quiet Mode
  9987.                                      ----------
  9988.     
  9989.     Sometimes you don't want the user to see the Parse-O-Matic processing
  9990.     screen.  In such cases, you can use the "Quiet Mode" switch (/Q) on the
  9991.     command line.  For example:
  9992.     
  9993.     POM XYZ.POM MYFILE.TXT TEMP.TXT /Q
  9994.     
  9995.     The /Q switch suppresses the display of the processing screen.  The only
  9996.     time a user will see anything is if there is a problem (for example:  the
  9997.     input file was not found).  In such case, Parse-O-Matic will make a noise
  9998.     via the PC speaker, then display a message (see "Unattended Operation" and
  9999.     "The MSGWAIT Command" for some background information).
  10000.     
  10001.                        --------------------------------------
  10002.                        User-Specified Command-Line Parameters
  10003.                        --------------------------------------
  10004.     
  10005.     Some POM applications are easier to use if you can pass a value on the
  10006.     command line.  For example, let us say you have created a POM file that will
  10007.     search a text file for a particular word, and output all the lines that
  10008.     contain that word.  You could manually change the POM file each time, but
  10009.     this is not a practical solution if many people will be using the
  10010.     application.
  10011.     
  10012.     The alternative is to use user-defined command line parameters to pass the
  10013.     value.  Consider this POM file, which we will name FINDWORD.POM:
  10014.     
  10015.     ACCEPT $FLINE ^ $CMDLINEX
  10016.     OUTEND |{$FLINE}
  10017.     
  10018.     This will output any lines that contain (^) the value of $CMDLINEX.  This
  10019.     variable is set if you use the /X command line parameter.  Thus, you would
  10020.     call the POM file as follows:
  10021.     
  10022.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /Xadministration
  10023.     
  10024.     This would read the file INPUT.TXT and send any lines containing the word
  10025.     "administration" (in lowercase) to the file OUTPUT.TXT.
  10026.     
  10027.     
  10028.  
  10029.  
  10030.  
  10031.  
  10032.                                                                             173
  10033.     There are three user-specified command line parameters:
  10034.     
  10035.     PARAMETER   SETS VARIABLE
  10036.     ---------   -------------
  10037.        /X         $CMDLINEX
  10038.        /Y         $CMDLINEY
  10039.        /Z         $CMDLINEZ
  10040.     
  10041.     Like all variables, the $CMDLINEx variables can be in uppercase, lowercase
  10042.     or mixed case (e.g. $CmdLineX).
  10043.     
  10044.     -------------------
  10045.     Case Considerations
  10046.     -------------------
  10047.     
  10048.     The parameter letter (e.g. /X) can be in uppercase or lowercase.  The
  10049.     following two command lines are equivalent:
  10050.     
  10051.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /Xadministration
  10052.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /xadministration
  10053.     
  10054.     The value following the parameter letter is passed on "as-is"; it is not
  10055.     converted to uppercase or changed in any way.  You could modify the FINDWORD
  10056.     file (described earlier) to ignore case, as follows:
  10057.     
  10058.     CVTCASE $CMDLINEX $CMDLINEX   <-- Convert the /X value to uppercase
  10059.     ACCEPT  $FLUPC ^ $CMDLINEX    <-- Compare to the uppercase version of $FLINE
  10060.     OUTEND  |{$FLINE}             <-- Output the line if the value was found
  10061.     
  10062.     ----------------
  10063.     Spaces in Values
  10064.     ----------------
  10065.     
  10066.     Since command-line parameters are separated by spaces, you must enclose your
  10067.     parameter value in quotes if it contains one or more spaces.  For example:
  10068.     
  10069.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"Mr. Jones"
  10070.     
  10071.     If the parameter value contains quotes, they must be doubled-up.  Thus, if
  10072.     you were using the FINDWORD application to find
  10073.     
  10074.     The "King" of American Jazz
  10075.     
  10076.     the command would look like this:
  10077.     
  10078.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"The ""King"" of American Jazz"
  10079.     
  10080.     
  10081.  
  10082.  
  10083.  
  10084.  
  10085.  
  10086.  
  10087.                                                                             174
  10088.     ---------------------
  10089.     Command-Line Switches
  10090.     ---------------------
  10091.     
  10092.     Sometimes you want a command-line parameter to simply mean "do something".
  10093.     If it is missing from the command line, it would mean "don't do it".  You
  10094.     could specify /ZY (for "Yes, do it") and /ZN (for "No, don't do it"), but
  10095.     there is an easier way.
  10096.     
  10097.     If a command-line parameter is missing, Parse-O-Matic sets its corresponding
  10098.     $CMDLINEx variable to "N" (meaning, "No, it's not there").  If the parameter
  10099.     is present -- with no value following it -- Parse-O-Matic sets the $CMDLINEx
  10100.     variable to "Y" (meaning "Yes, it's there").  We can use this method to
  10101.     refine the FINDWORD application described earlier...
  10102.     
  10103.     BEGIN $CMDLINEZ = "Y"
  10104.       CVTCASE $CMDLINEX $CMDLINEX
  10105.       ACCEPT  $FLUPC ^ $CMDLINEX
  10106.     ELSE
  10107.       ACCEPT  $FLINE ^ $CMDLINEX
  10108.     END
  10109.     OUTEND  |{$FLINE}
  10110.     
  10111.     In this case, the /X value (the word we are looking for) will be tested
  10112.     without regard to case (i.e. uppercase or lowercase letters) if /Z is
  10113.     present on the command line.  If /Z is missing, we will look for an exact
  10114.     match.  Here are two sample command lines:
  10115.     
  10116.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"Mr. Jones"
  10117.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"Mr. Jones" /Z
  10118.     
  10119.     The first command would not match "Mr. Jones" with "mr. jones".  The second
  10120.     command would consider the two strings equivalent.
  10121.     
  10122.     ----------------------------
  10123.     Hex and Decimal Code Strings
  10124.     ----------------------------
  10125.     
  10126.     You can specify precise values either as a decimal ("ASCII") value, or as
  10127.     hexadecimal.  For example, the following three commands are equivalent:
  10128.     
  10129.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X" 01"
  10130.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X$20$30$31
  10131.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X#32#45#49
  10132.     
  10133.     All three specify the search string " 01".  The second one uses decimal
  10134.     notation for the characters, while the third one uses hexadecimal codes
  10135.     for the characters.
  10136.     
  10137.     
  10138.  
  10139.  
  10140.  
  10141.  
  10142.                                                                             175
  10143.     You can not mix the decimal, hex and literal representations.  Here are
  10144.     two examples:
  10145.     
  10146.     /X#32"22"#32     is not permitted
  10147.     /X" 22 "         could be used instead
  10148.     /X#32#50#50#32   could also be used
  10149.     
  10150.     /X$30#50         is not permitted
  10151.     /X02             could be used instead
  10152.     /X"02"           could also be used
  10153.     
  10154.                                       -------
  10155.                                       Summary
  10156.                                       -------
  10157.     
  10158.                SAMPLE COMMAND LINE                 VALUE OF $CMDLINEX
  10159.                ----------------------------------  ------------------
  10160.                POM A.POM B.TXT C.TXT /XHarry       Harry
  10161.                POM A.POM B.TXT C.TXT /X"The King"  The King
  10162.                POM A.POM B.TXT C.TXT /X            Y
  10163.                POM A.POM B.TXT C.TXT /XY           Y
  10164.                POM A.POM B.TXT C.TXT /XN           N
  10165.                POM A.POM B.TXT C.TXT               N
  10166.                POM A.POM B.TXT C.TXT /X$30$31      01
  10167.                POM A.POM B.TXT C.TXT /X#48#50      02
  10168.     
  10169.     
  10170.     
  10171.  
  10172.  
  10173.  
  10174.  
  10175.  
  10176.  
  10177.  
  10178.  
  10179.  
  10180.  
  10181.  
  10182.  
  10183.  
  10184.  
  10185.  
  10186.  
  10187.  
  10188.  
  10189.  
  10190.  
  10191.  
  10192.  
  10193.  
  10194.  
  10195.  
  10196.  
  10197.                                                                             176
  10198.     ============================================================================
  10199.                                    FILE HANDLING
  10200.     ============================================================================
  10201.     
  10202.                        -------------------------------------
  10203.                        How Parse-O-Matic Searches for a File
  10204.                        -------------------------------------
  10205.     
  10206.     When Parse-O-Matic needs to read a file, it follows this procedure:
  10207.     
  10208.     1)  Parse-O-Matic tidies up the file name in the following ways:
  10209.     
  10210.         - It removes spaces and tabs
  10211.         - It converts the file name to uppercase
  10212.         - As per DOS convention, slashes (/) are converted to backslashes (\)
  10213.         - If this type of file has a default extension, and if the file name
  10214.           does not have a period (i.e. dot) in the name, the extension is
  10215.           added.
  10216.     
  10217.     2)  If the file name is fully qualified (i.e. drive and path, or both),
  10218.         Parse-O-Matic tries to open that file.  If it can not, it terminates
  10219.         with an error message.
  10220.     
  10221.     3)  If the file name is not fully qualified, Parse-O-Matic follows this
  10222.         procedure:
  10223.     
  10224.         - It first looks for the file in the current directory.
  10225.         - If then looks in the directory where the Parse-O-Matic program
  10226.           (POM.EXE) is located.
  10227.         - It then searches the DOS PATH for the file.  (For information
  10228.           about the PATH command, refer to your operating system manual.)
  10229.         - If none of these steps locate the file, Parse-O-Matic terminates
  10230.           with an error message.
  10231.     
  10232.     The following types of files are affected...
  10233.     
  10234.     TYPE OF FILE            DEFAULT EXTENSION  REFER TO MANUAL SECTION
  10235.     ----------------------  -----------------  -----------------------
  10236.     POM (Control) File            .POM         "The POM File"
  10237.     POJ (Job) File                .POJ         "Parse-O-Matic Job (POJ) Files"
  10238.     Date Information File      See NOTE #1     "The POMDATE.CFG File"
  10239.     Lookup File                See NOTE #2     "The LookFile Command"
  10240.     Properization Exception    See NOTE #2     "The Proper Command"
  10241.     Map File                      .MPF         "The MAPFILE Command"
  10242.     
  10243.     NOTE #1:  The Date Information File is always called POMDATE.CFG.  You can
  10244.               put your standard version in the Parse-O-Matic directory. If you
  10245.               wish to override it, you should place the modified copy in your
  10246.               current (logged) directory.
  10247.     
  10248.     NOTE #2:  This type of file does not have a default extension.  However, we
  10249.               recommend "TBL" (i.e. "Table") for Lookup files and "PEF" for
  10250.               Properization Exception Files.
  10251.  
  10252.                                                                             177
  10253.     Parse-O-Matic does NOT search for input and output files.  They must be
  10254.     in the current directory, or must have a fully qualified path.  If the
  10255.     input file is missing an extension, it is assumed to be TXT.  If the
  10256.     output file is not specified in the POM command, it is assumed to be
  10257.     Output File")
  10258.     
  10259.     Since Parse-O-Matic searches for files, you can place frequently-used
  10260.     Lookup and POM files in a directory in your DOS path.
  10261.     
  10262.                        --------------------------------------
  10263.                        How Parse-O-Matic Opens an Output File
  10264.                        --------------------------------------
  10265.     
  10266.     Parse-O-Matic opens an output file the first time one of the output
  10267.     commands (e.g. OUT, OUTEND, OUTHDG) has something to send to the file.
  10268.     When opening an output file, Parse-O-Matic follows this procedure:
  10269.     
  10270.     1)  Normally, the name of the output file is specified on the POM command
  10271.         line or (if it is omitted there), it is specified in an OFILE command
  10272.         within the POM file.
  10273.     
  10274.         If no output file name was given using either method, the name is set
  10275.         to POMOUT.TXT (in the current directory).
  10276.     
  10277.     2)  Parse-O-Matic tidies up the file name in the following ways:
  10278.     
  10279.         - It removes spaces and tabs
  10280.         - It converts the file name to uppercase
  10281.         - As per DOS convention, slashes (/) are converted to backslashes (\)
  10282.         - If the file name does not have an extension, and it does not end in
  10283.           a period or a colon, the extension TXT is added.  Thus:
  10284.     
  10285.           C:\XYZ      becomes C:\XYZ.TXT
  10286.           C:\XYZ.     stays the same
  10287.           C:\XYZ.DAT  stays the same
  10288.           LPT2:       stays the same (see "Sending Output to a Device")
  10289.     
  10290.     3)  The output file name is compared to the input file name.  If they are
  10291.         the same, Parse-O-Matic terminates with an error.  You can not send
  10292.         output to the input file, nor can you read input from the output file.
  10293.     
  10294.     4A) If the file name is preceded by a plus sign ("+"), Parse-O-Matic will
  10295.         append output to the file.  Here are some examples:
  10296.     
  10297.         +C:\XYZ.TXT   output will be appended to the file
  10298.         +LPT1:        this refers to a device, so the "+" is ignored
  10299.     
  10300.         If the file to which you are appending does not already exist, it is
  10301.         first created, as an empty file.
  10302.     
  10303.     
  10304.  
  10305.  
  10306.  
  10307.                                                                             178
  10308.     4B) If the file name is NOT preceded by a plus sign, the following
  10309.         procedure takes place:
  10310.     
  10311.         - If a file with the specified name already exists, it is renamed
  10312.           with a .BAK extension (replacing any previous file with that name).
  10313.         - The file is created, as an empty file
  10314.     
  10315.         For example, if you run Parse-O-Matic as follows:
  10316.     
  10317.         POM MYPOM.POM INPUT.TXT C:\XYZ.TXT
  10318.     
  10319.         then if C:\XYZ.TXT already exists, it is renamed to C:\XYZ.BAK.
  10320.     
  10321.     5)  Output is directed to the output file until Parse-O-Matic ends or a new
  10322.         output file name is specified by the OFILE command.
  10323.     
  10324.     REMINDER:  Parse-O-Matic does not open the output file until it is time to
  10325.     send it some data from the output commands (OUT, OUTEND etc.).  If no data
  10326.     is sent to the output file, it will contain its original data (assuming it
  10327.     already existed).  If this is a problem, you can either delete the output
  10328.     file before running Parse-O-Matic, or place the following commands in the
  10329.     PROLOGUE:
  10330.     
  10331.     ERASE "OUTPUT.TXT"      <-- Delete the output file
  10332.     OFILE "OUTPUT.TXT"      <-- Specify the output file
  10333.     
  10334.     If you do this, and no data is sent to the output file, the file will not
  10335.     exist.  You can check if POM failed by consulting the DOS ERRORLEVEL.
  10336.     (See your operating system manual for an explanation of ERRORLEVEL.)
  10337.     
  10338.     - If the ERRORLEVEL is 0 and the file does not exist, it means that POM
  10339.       ran successfully, but no output was sent to the file.
  10340.     
  10341.     - If the ERRORLEVEL is 1 or higher, and the file does not exist, it
  10342.       means that POM failed, or you used the HALT command before any output
  10343.       was sent to the file.
  10344.     
  10345.     If you are calling Parse-O-Matic from a program (rather than a batch file),
  10346.     you can check the error level using the facilities built in to the language
  10347.     in which the program was written.  For example, Turbo Pascal lets you
  10348.     run another program with the EXEC command, after which you can extract the
  10349.     ERRORLEVEL from the low byte of the DosExitCode variable.
  10350.     
  10351.     
  10352.  
  10353.  
  10354.  
  10355.  
  10356.  
  10357.  
  10358.  
  10359.  
  10360.  
  10361.  
  10362.                                                                             179
  10363.                             ---------------------------
  10364.                             Appending to an Output File
  10365.                             ---------------------------
  10366.     
  10367.     If you want to add data to the end of the output file, you have three
  10368.     alternatives:
  10369.     
  10370.     1)  Use wildcards, as explained in "POM and Wildcards".  In such case,
  10371.         the output file is empty when the first output line is generated
  10372.         (although see method #2 for an exception).  When processing with
  10373.         wildcards, all output is sent to the same file, unless you change
  10374.         the file with the OFILE command (see "The OFile Command").
  10375.     
  10376.     2)  Prefix the output file name with a plus sign.  This tells Parse-O-
  10377.         Matic that you want to add data to the end of the file, rather than
  10378.         starting with an empty file.  You can use this method on the command
  10379.         line:
  10380.     
  10381.         POM MYPOM.POM INPUT.TXT +C:\MYFILES\OUTPUT.TXT
  10382.     
  10383.         You can also use this method in the OFILE command:
  10384.     
  10385.         OFILE "+C:\MYFILES\OUTPUT.TXT"
  10386.     
  10387.         In these examples, we provided the full path name to the output file.
  10388.         If you do not specify a path name (e.g. OFILE "+OUTPUT.TXT"), the
  10389.         output file is placed in the current directory.
  10390.     
  10391.     3)  Use a batch file and the DOS COPY command to control the concatenation
  10392.         of output files.  This method is less convenient, but it allows you to
  10393.         bypass the addition of the new output if there is a processing error.
  10394.         Here is a sample batch file (comments appear after the arrows):
  10395.     
  10396.         @ECHO OFF                               <-- Turn batch echoing off
  10397.         IF EXIST OUTPUT.TXT DELETE OUTPUT.TXT   <-- Get rid of old output file
  10398.         POM MYPOM.POM INPUT.TXT OUTPUT.TXT      <-- Parse the input file
  10399.         IF ERRORLEVEL 1 GOTO QUIT               <-- Quit if there was an error
  10400.         IF NOT EXIST OUTPUT.TXT GOTO QUIT       <-- Quit if no output generated
  10401.         IF EXIST SAFETY.TXT DELETE SAFETY.TXT   <-- Get rid of old safety file
  10402.         RENAME MAINFILE.TXT SAFETY.TXT          <-- Backup the original file
  10403.         COPY SAVE.TXT+OUTPUT.TXT MAINFILE.TXT   <-- Add the new output
  10404.         :QUIT                                   <-- Batch file label for GOTO
  10405.     
  10406.         This method has the added advantage of creating a backup copy of the
  10407.         original output file.  If the data in the file is particularly
  10408.         important, you could place the file SAFETY.TXT on another hard drive.
  10409.     
  10410.     
  10411.  
  10412.  
  10413.  
  10414.  
  10415.  
  10416.  
  10417.                                                                             180
  10418.                              --------------------------
  10419.                              Sending Output to a Device
  10420.                              --------------------------
  10421.     
  10422.     Parse-O-Matic recognizes that an "output file" is actually a device if it
  10423.     has a colon (":") at the end of the name.  You can direct Parse-O-Matic's
  10424.     output to a standard device such as COM1: or LPT2: by specifying the device
  10425.     name accordingly. For example:
  10426.     
  10427.     POM XYZ.POM INPUT.TXT LPT1:
  10428.     
  10429.     This directs the output to the LPT1 printer.
  10430.     
  10431.     Parse-O-Matic can detect a "Not Ready" condition in most cases.  A printer
  10432.     is Not Ready when it is offline, out of paper, or its print buffer is full.
  10433.     
  10434.     If a Not Ready condition occurs, the following happens:
  10435.     
  10436.     - If you are running in Quiet Mode (/Q on the POM command line), a Not
  10437.       Ready condition terminates Parse-O-Matic with a DOS ERRORLEVEL of 243.
  10438.     
  10439.     - If you are not running in Quiet Mode, a message box gives you the option
  10440.       of trying again, or canceling processing.  If you cancel, Parse-O-Matic
  10441.       terminates with a DOS ERRORLEVEL of 244.
  10442.     
  10443.     ---------
  10444.     COM Ports
  10445.     ---------
  10446.     
  10447.     If you are sending output to a COM port (e.g. COM1:) you should first set
  10448.     the baud rate with the DOS MODE command, or Pinnacle Software's MODEM
  10449.     program (available on our BBS and Web site).
  10450.     
  10451.     The MODEM program is particularly useful if your COM port is driving a
  10452.     modem.  Parse-O-Matic talks to the operating system's COM device driver
  10453.     rather than the modem itself, so before you send data to a modem, it is a
  10454.     good idea to use the MODEM program to check that the modem is online and
  10455.     functioning properly.
  10456.     
  10457.     If you are using a high-speed modem (9600 bps or higher) and you find that
  10458.     you sometimes lose some characters, the operating system or the modem may
  10459.     not be handling a "Not Ready" condition properly during handshaking.  In
  10460.     such case, you may find it necessary to turn off buffering (locked DTE
  10461.     speed) and run at a maximum speed of 9600 bps.  For a quick course in
  10462.     high-speed modems and buffering, see the Trouble-Shooting Guide included
  10463.     with Pinnacle Software's Sapphire Bulletin Board System (also available on
  10464.     our BBS and Web site).
  10465.     
  10466.     For an example of sending output to a COM port, see "The Pause Command".
  10467.     
  10468.     
  10469.  
  10470.  
  10471.  
  10472.                                                                             181
  10473.                                      ---------
  10474.                                      DbF Files
  10475.                                      ---------
  10476.     
  10477.     If Parse-O-Matic notices that the input file is a "DBase" file (i.e. it has
  10478.     a DBF extension -- for example:  MYFILE.DBF), it will change the way it
  10479.     processes the data.  For instance, the variable $FLINE is not defined.
  10480.     Rather, each of the fields in the database are pre-parsed.  Thus, if you
  10481.     have a DBF file containing three fields (EMPNUM, NAME, PHONE), your entire
  10482.     POM file might look like this:
  10483.     
  10484.     IGNORE DELETED "Y"
  10485.     OUTEND |{EMPNUM} {NAME} {PHONE}
  10486.     
  10487.     The DELETED variable is created automatically for each record.  If it is
  10488.     set to "Y", it means the record has been deleted from the database and is
  10489.     probably not valid.  In most cases, you will want to ignore such records.
  10490.     
  10491.     If you do not know what the field names are, you can obtain the list with
  10492.     the following POM file:
  10493.     
  10494.     TRACE DELETED
  10495.     
  10496.     Afterwards, when you inspect the trace file (POM.TRC), you will see a
  10497.     summary of all the fields.  Since there are no output commands (e.g. OUTEND
  10498.     and OUTHDG), the output file will be empty.
  10499.     
  10500.     NOTE:  Parse-O-Matic does not currently support DBF "Memo" fields.
  10501.     
  10502.                                  -----------------
  10503.                                  POM and Wildcards
  10504.                                  -----------------
  10505.     
  10506.     You can process multiple input files with the same POM file by specifying a
  10507.     DOS "wildcard" at the DOS command prompt.  All output is then directed to
  10508.     the same output file.  For example:
  10509.     
  10510.     POM XYZ.POM *.TXT OUTPUT.TXT
  10511.     
  10512.     This runs the XYZ POM file on each file in the current directory with a TXT
  10513.     extension and sends all output to the file OUTPUT.TXT.
  10514.     
  10515.     The POM file can determine which file it is reading by using the predefined
  10516.     variable $COMMAND, which contains the current POM command line.
  10517.     
  10518.     
  10519.  
  10520.  
  10521.  
  10522.  
  10523.  
  10524.  
  10525.  
  10526.  
  10527.                                                                             182
  10528.     Consider the following scenario:
  10529.     
  10530.     - You have installed POM.EXE in the directory path C:\UTILITY\POM
  10531.     - The current directory contains ABC.POM, MARK.TXT, MARY.TXT and JOHN.TXT
  10532.     - You enter the command POM ABC *.DAT OUT.TXT
  10533.     
  10534.     Parse-O-Matic runs ABC.POM against the three TXT files.  On the first input
  10535.     file, $COMMAND will look like this:
  10536.     
  10537.     C:\UTILITY\POM.EXE ABC.POM MARK.TXT OUT.TXT
  10538.     
  10539.     On the next two input files, it looks like this:
  10540.     
  10541.     C:\UTILITY\POM.EXE ABC.POM MARY.TXT OUT.TXT
  10542.     C:\UTILITY\POM.EXE ABC.POM JOHN.TXT OUT.TXT
  10543.     
  10544.     Note that the file OUT.TXT is NOT processed, even though it has a TXT
  10545.     extension.  POM will always avoid processing the output file.
  10546.     
  10547.     Let's say you wanted to concatenate both MARK.TXT and MARY.TXT, and put the
  10548.     file name at the top.  You could do it with this POM file, named ABC.POM:
  10549.     
  10550.     SET cmd = $COMMAND                <-- Get the command line
  10551.     BEGIN cmd <> lastcmd              <-- Has it changed?
  10552.       PARSE  fname cmd "2* " "3* "    <-- Extract the input file name
  10553.       SETLEN flen  fname              <-- Get length of input file name
  10554.       SET    uline = ""               <-- Initialize underline
  10555.       PAD    uline "L" "-" flen       <-- Set underline
  10556.       OUTEND lastcmd <> "" |          <-- Output a linefeed unless
  10557.       OUTEND lastcmd <> "" |          <-- this is the first file
  10558.       OUTEND |{fname}                 <-- Output the file name
  10559.       OUTEND |{uline}                 <-- Output the underline
  10560.       OUTEND |                        <-- Output a linefeed
  10561.       SET    lastcmd = $COMMAND       <-- Remember this command line
  10562.     END                               <-- End of code block
  10563.     OUTEND |{$FLINE}                  <-- Output a line from the input
  10564.     
  10565.     You could then process MARK.TXT and MARY.TXT with this command line:
  10566.     
  10567.     POM ABC M*.TXT OUT.TXT
  10568.     
  10569.     This processes any file starting with an "M" that has a TXT extension.
  10570.     
  10571.     Another way to run the command is as follows:
  10572.     
  10573.     POM ABC M???.TXT OUT.TXT
  10574.     This processes any four-letter TXT file that starts with "M".
  10575.     
  10576.     For details about DOS wildcards, consult your operating system manual.
  10577.     
  10578.     
  10579.     
  10580.     
  10581.  
  10582.                                                                             183
  10583.     ============================================================================
  10584.                                OPERATIONAL TECHNIQUES
  10585.     ============================================================================
  10586.     
  10587.                            -----------------------------
  10588.                            Parse-O-Matic Job (POJ) Files
  10589.                            -----------------------------
  10590.     
  10591.     As explained earlier, a standard Parse-O-Matic command line looks like this:
  10592.     
  10593.     Format:   POM pom-file input-file output-file [optional parameters]
  10594.     Example:  POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  10595.     
  10596.     You can save the command specifications in a Parse-O-Matic job (.POJ) file
  10597.     so that you do not have to type them over and over again.  A POJ file is
  10598.     essentially a single-line text file that contains the specifications.
  10599.     
  10600.     ------------
  10601.     Simple Usage
  10602.     ------------
  10603.     
  10604.     Let's say you create a text file named MYJOB.POJ which contains the
  10605.     following line:
  10606.     
  10607.       POMFILE.POM REPORT.TXT OUTPUT.TXT
  10608.     
  10609.     You can then run the parsing job with the following command:
  10610.     
  10611.       POM MYJOB.POJ
  10612.     
  10613.     This would be the same as typing:
  10614.     
  10615.       POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  10616.     
  10617.     NOTE:  Do NOT include the POM command in the job file.  For example:
  10618.     
  10619.       XYZ.POM ABC.TXT DEF.TXT      <-- Correct
  10620.       POM XYZ.POM ABC.TXT DEF.TXT  <-- Incorrect; the initial POM is not needed
  10621.     
  10622.     
  10623.  
  10624.  
  10625.  
  10626.  
  10627.  
  10628.  
  10629.  
  10630.  
  10631.  
  10632.  
  10633.  
  10634.  
  10635.  
  10636.  
  10637.                                                                             184
  10638.     ---------------------
  10639.     Commenting a Job File
  10640.     ---------------------
  10641.     
  10642.     The POJ file can contain explanatory comments so you can document its
  10643.     purpose:  null lines and lines that start with a semi-colon are ignored.
  10644.     Thus, the MYJOB.POJ example (described above) could also have been
  10645.     written this way:
  10646.     
  10647.       ; Sample JOB file
  10648.       POMFILE.POM REPORT.TXT OUTPUT.TXT
  10649.     
  10650.     This first line is ignored, so as far as Parse-O-Matic is concerned, the
  10651.     job file contains only one line -- the command specifications.
  10652.     
  10653.     (The sample PBJ files are indented here to offset them from the descriptive
  10654.     text, but a semi-colon must appear in column one to be recognized as a
  10655.     comment.)
  10656.     
  10657.     ------------------------
  10658.     Prompting for File Names
  10659.     ------------------------
  10660.     
  10661.     Job files are especially helpful when you don't know in advance which files
  10662.     will be processed, and you would like to prompt for a file name.  This lets
  10663.     you use one POM command-line to handle different situations.
  10664.     
  10665.     Let's say you create a text file named MYJOB2.POJ, which contains the
  10666.     following lines:
  10667.     
  10668.       ; Sample prompted job file
  10669.       POMFILE.POM % OUTPUT.TXT
  10670.     
  10671.     You can then run this job with the following DOS command:
  10672.     
  10673.       POM MYJOB2.POJ
  10674.     
  10675.     or simply:
  10676.     
  10677.       POM MYJOB2
  10678.     
  10679.     Since a single command-line parameter is assumed to refer to a POJ file.
  10680.     
  10681.     The % character means "Ask the user for this file".  Since, in this example,
  10682.     the % is in the second position, Parse-O-Matic will prompt you for the name
  10683.     of the input file or mask.  (If you press Esc or enter a null name,
  10684.     processing is terminated with a warning message.)
  10685.     
  10686.     
  10687.  
  10688.  
  10689.  
  10690.  
  10691.  
  10692.                                                                             185
  10693.     Here is another example:
  10694.     
  10695.       ; Sample prompted job file
  10696.       POMFILE.POM % %
  10697.     
  10698.     This will prompt for both the input file and output file names.
  10699.     
  10700.     Now consider this example:
  10701.     
  10702.       ; Sample prompted job file
  10703.       % % %
  10704.     
  10705.     This will prompt for the POM, input and output file names -- which is not
  10706.     particularly helpful!
  10707.     
  10708.     ---------------------
  10709.     Suggesting File Names
  10710.     ---------------------
  10711.     
  10712.     A % prompt will open a box on the screen to ask you for a file name (with an
  10713.     appropriate explanation of what it required) but it will not suggest a name.
  10714.     You can "feed" Parse-O-Matic a suggested name, which you can then accept by
  10715.     hitting Enter, or modify by typing a new one.
  10716.     
  10717.     To provide this default value, place the suggested file name after the %
  10718.     character.  For example:
  10719.     
  10720.       ; Sample prompted job file, with recommended file names
  10721.       POMFILE.POM %INPUT.TXT %OUTPUT.TXT
  10722.     
  10723.     When you are asked to specify the input file name, the name INPUT.TXT will
  10724.     appear in the prompt box.  It can be accepted as-is, or changed.
  10725.     
  10726.     Incidentally, if you do not provide a suggested file name for the output
  10727.     file, Parse-O-Matic will automatically suggest the name POMOUT.TXT.
  10728.     
  10729.     -------------------
  10730.     Optional Parameters
  10731.     -------------------
  10732.     
  10733.     You can include optional parameters in your job file line.  For example:
  10734.     
  10735.       POMFILE.POM ABC.TXT XYZ.TXT /Q
  10736.     
  10737.     Because of the /Q parameter, this will parse ABC.TXT in "Quiet mode"
  10738.     (i.e. the processing screen will not be displayed).
  10739.     
  10740.     You can not prompt for optional parameters.
  10741.     
  10742.     
  10743.  
  10744.  
  10745.  
  10746.  
  10747.                                                                             186
  10748.     Because the output file name is optional in the POM command (defaulting to
  10749.     POMOUT.TXT if it is omitted, which can then be altered in the POM file
  10750.     itself with the OFILE command), it is possible to leave out the output file
  10751.     name (or prompt) in the job file:
  10752.     
  10753.       POMFILE.POM ABC.TXT /Q
  10754.     
  10755.     This assumes that the output file name is POMOUT.TXT, just as if you had
  10756.     typed the following command at the DOS prompt:
  10757.     
  10758.       POM POMFILE.POM ABC.TXT /Q
  10759.     
  10760.     --------
  10761.     Examples
  10762.     --------
  10763.     
  10764.     The standard Parse-O-Matic package contains two sample job files, named
  10765.     SAMPJOB1.POJ and SAMPJOB2.POJ, which demonstrate simple and prompted
  10766.     usage of job files.  Both files are self-documenting, so view or print
  10767.     them out to find out how to use them.
  10768.     
  10769.                           -------------------------------
  10770.                           Encrypted (Scrambled) POM Files
  10771.                           -------------------------------
  10772.     
  10773.     Parse-O-Matic comes with a simple encryption program (named SCRAMBLE) which
  10774.     renders a POM file unreadable to humans yet still usable by Parse-O-Matic.
  10775.     
  10776.     --------------------
  10777.     The SCRAMBLE Utility
  10778.     --------------------
  10779.     
  10780.     The format of the SCRAMBLE command (entered at the DOS prompt) is as
  10781.     follows:
  10782.     
  10783.     SCRAMBLE filename password
  10784.     
  10785.     The filename is the name of your POM file, which will be "scrambled" into
  10786.     a seemingly meaningless jumble of characters.  The original POM file is
  10787.     renamed with a BAK extension, so if you scramble MYFILE.POM, as in this
  10788.     command:
  10789.     
  10790.     SCRAMBLE MYFILE.POM PRIVATE
  10791.     
  10792.     then two files will be created:
  10793.     
  10794.     MYFILE.POM    The scrambled POM file
  10795.     MYFILE.BAK    The original POM file
  10796.     
  10797.     
  10798.  
  10799.  
  10800.  
  10801.  
  10802.                                                                             187
  10803.     The password is a code word of six letters or more that you can use to
  10804.     unscramble the file.  To do this, simply enter the SCRAMBLE command again,
  10805.     using the same password.
  10806.     
  10807.     SCRAMBLE ignores case, so the password "SECRET" is equivalent to "Secret".
  10808.     
  10809.     If the wrong password is entered, SCRAMBLE issues a warning message, pauses
  10810.     briefly, then terminates without doing anything else.
  10811.     
  10812.     For a brief summary of SCRAMBLE, enter the following command at the DOS
  10813.     prompt:
  10814.     
  10815.     SCRAMBLE /?
  10816.     
  10817.     ------------------------
  10818.     Why Scramble a POM File?
  10819.     ------------------------
  10820.     
  10821.     If you are distributing a POM application, you may not want the end-users to
  10822.     be able to tamper with the POM file.  If they alter a scrambled POM file,
  10823.     they will almost certainly render it inoperable.
  10824.     
  10825.     The encryption scheme used by SCRAMBLE (and Parse-O-Matic) is not highly
  10826.     sophisticated, so there are no export restrictions on the technology.  The
  10827.     encryption could probably be "cracked" by a professional cryptologist within
  10828.     a day.  However, it should confound regular users sufficiently that they
  10829.     will not alter, excerpt or modify your POM code.
  10830.     
  10831.     When Parse-O-Matic notices that the POM file is encrypted, it disables
  10832.     tracing.  This prevents the user from using the trace facility to get a
  10833.     listing of the POM file.
  10834.     
  10835.     ----------------------
  10836.     Support Considerations
  10837.     ----------------------
  10838.     
  10839.     The SCRAMBLE program does NOT have to be present in the Parse-O-Matic
  10840.     directory for Parse-O-Matic to read scrambled files.
  10841.     
  10842.     If you are shipping a scrambled POM file to a user, you might consider
  10843.     sending along a copy of SCRAMBLE if you think the user might have to make
  10844.     some on-site changes to the POM file.  However, in order to do this, the
  10845.     user would have to know your POM file's scrambling password. In most cases
  10846.     it is probably better to provide the user with a fresh file (direct from
  10847.     you) when changes are needed.
  10848.     
  10849.     Scrambled POM files can be used with unregistered evaluation copies of
  10850.     Parse-O-Matic, although the legal requirement remains: continued use of
  10851.     Parse-O-Matic beyond 90 days requires a license (see "Licensing").  This
  10852.     lets your client try out your Parse-O-Matic solution without paying for
  10853.     Parse-O-Matic OR seeing your POM code.
  10854.     
  10855.     
  10856.  
  10857.                                                                             188
  10858.                                     -----------
  10859.                                     Batch Files
  10860.                                     -----------
  10861.     
  10862.     The built-in batch (BAT) capability of DOS and Windows is often overlooked,
  10863.     even by seasoned computer professionals.  You can use batch files to make
  10864.     Parse-O-Matic easier to use.  Batch files are created with a text editor
  10865.     (such as DOS EDIT, or Windows Notepad).
  10866.     
  10867.     --------------------------------------
  10868.     Example #1:  Save Yourself Some Typing
  10869.     --------------------------------------
  10870.     
  10871.     Here is a simple batch file (comments appear after the arrows):
  10872.     
  10873.     @ECHO OFF                               <-- Turn off command-line echoing
  10874.     POM MYPOM.POM INPUT.TXT OUTPUT.TXT      <-- Run Parse-O-Matic
  10875.     IF ERRORLEVEL 1 GOTO QUIT               <-- Quit if an error occurred
  10876.     SEE OUTPUT.TXT                          <-- View the output file
  10877.     :QUIT                                   <-- Batch file label
  10878.     
  10879.     The advantage of this batch file is that it saves you the trouble of typing
  10880.     in the entire POM command line each time you want to parse the file.
  10881.     
  10882.     ----------------------------------------
  10883.     Example #2:  Streamline Your Development
  10884.     ----------------------------------------
  10885.     
  10886.     Here is a batch file which is useful during the development of a POM file.
  10887.     
  10888.     @ECHO OFF
  10889.     DEVELOP 50 MYPOM.POM IN.TXT C:\MYFILES\OUT.TXT
  10890.     
  10891.     This batch file calls DEVELOP.BAT (included with Parse-O-Matic), which
  10892.     displays a menu with the following options:
  10893.     
  10894.     INPUT ------ View input file
  10895.     EDIT ------- Edit POM file
  10896.     PARSE ------ Run parsing job
  10897.     OUTPUT ----- View output file
  10898.     QUIT ------- Finished
  10899.     
  10900.     This lets you do the parsing, view the result, make changes to the POM file
  10901.     if necessary, then parse again.  You will find that this technique makes
  10902.     development proceed quickly.
  10903.     
  10904.     Here is an explanation of the second line of the batch file:
  10905.     
  10906.     
  10907.  
  10908.  
  10909.  
  10910.  
  10911.  
  10912.                                                                             189
  10913.     DEVELOP 50 MYPOM.POM IN.TXT C:\MYFILES\OUT.TXT
  10914.     :       :  :         :      :
  10915.     :       :  :         :      :
  10916.     :       :  :         :      Name of output file  <-----
  10917.     :       :  :         :                                |
  10918.     :       :  :         Name of input file          <-------- See NOTE #1
  10919.     :       :  :                                          |
  10920.     :       :  Name of POM file                      <-----
  10921.     :       :
  10922.     :       Save position for menu                   <-------- See NOTE #2
  10923.     :
  10924.     Invokes the batch file DEVELOP.BAT
  10925.     
  10926.     NOTE #1:  You must provide the full path to the files (unless they are in
  10927.               the current directory) and the extension.
  10928.     
  10929.     NOTE #2:  The "save position" remembers where you were in the menu.  You
  10930.               may use values 49 to 99 to provide a "memory" for 50 different
  10931.               batch files that call DEVELOP.BAT.  (The other values are
  10932.               reserved for the Parse-O-Matic installation and tutorial
  10933.               procedures.)  If 50 is not enough, you can place additional
  10934.               batch files in another directory; the menu save file (POM.MSV)
  10935.               is always placed in the current directory.
  10936.     
  10937.     In order for DEVELOP.BAT to work correctly when you are in a directory
  10938.     other than the Parse-O-Matic directory, you must place the Parse-O-Matic
  10939.     directory in your DOS PATH (see your operating system manual for details).
  10940.     Your PATH must also include the directory to a text editor.  (In the
  10941.     original Parse-O-Matic package, DEVELOP.BAT calls up DOS EDIT.)
  10942.     
  10943.     You may find it instructive to study the file DEVELOP.BAT by loading it
  10944.     into a text editor.  The batch file contains some comments which explain
  10945.     how it works.  As mentioned in one of the comments, you may wish to change
  10946.     the text editor that the batch file calls for editing the POM file.
  10947.     
  10948.     You may also find the program PSMENU.EXE useful.  For a brief description,
  10949.     type PSMENU /? at the DOS prompt.  To study a typical menu definition file,
  10950.     enter the command SEE POM.MNU at the DOS prompt.
  10951.     
  10952.     ----------------------------------
  10953.     Example #3:  Automatic Batch Files
  10954.     ----------------------------------
  10955.     
  10956.     Let's say that each day you have a text file, named DELLIST.TXT, which
  10957.     lists the names of the files that need to be deleted:
  10958.     
  10959.     FRED.TXT
  10960.     MARY.TXT
  10961.     JOHN.TXT
  10962.     HARRY.TXT
  10963.     
  10964.     You could write a POM file (we'll call it MAKEDEL.POM) to write a batch
  10965.     file to delete the files.  It would look like this:
  10966.  
  10967.                                                                             190
  10968.     PROLOGUE
  10969.       OUTEND |@ECHO OFF
  10970.     END
  10971.     IGNORE $FLINE = "COMMAND.COM"           <-- An example of a safety feature!
  10972.     OUTEND $FLINE <> "" |DEL {$FLINE}
  10973.     
  10974.     You could automate the entire procedure with the following batch file
  10975.     (which we'll call DAILYDEL.BAT):
  10976.     
  10977.     @ECHO OFF                               <-- Turn off command-line echoing
  10978.     POM MAKEDEL.POM DELLIST.TXT TEMP.BAT    <-- Create the batch file TEMP.BAT
  10979.     IF ERRORLEVEL 1 GOTO QUIT               <-- Quit if an error occurred
  10980.     TEMP.BAT                                <-- Run the batch file
  10981.     DEL TEMP.BAT                            <-- Delete it
  10982.     :QUIT                                   <-- Batch file label
  10983.     
  10984.     The second line of DAILYDEL.BAT runs Parse-O-Matic to create a batch file
  10985.     named TEMP.BAT.  Given the input file shown earlier, TEMP.BAT would look
  10986.     like this:
  10987.     
  10988.     @ECHO OFF
  10989.     DEL FRED.TXT
  10990.     DEL MARY.TXT
  10991.     DEL JOHN.TXT
  10992.     DEL HARRY.TXT
  10993.     
  10994.     After TEMP.BAT is created, DAILYDEL.BAT runs TEMP.BAT (thus deleting all
  10995.     the files listed in DELLIST.TXT).
  10996.     
  10997.     This is only a simple example.  Parse-O-Matic's ability to create batch
  10998.     files based on input data provides you with a very powerful tool for
  10999.     automating daily administrative tasks.
  11000.     
  11001.     When you write automatic applications, you should be careful to include
  11002.     routines in both the batch files and the POM files to handle any unusual
  11003.     conditions.  In MAKEDEL.POM, we checked the file to be sure that it wasn't
  11004.     "COMMAND.COM", because if that file is deleted, your system will probably
  11005.     stop working!
  11006.     
  11007.     
  11008.  
  11009.  
  11010.  
  11011.  
  11012.  
  11013.  
  11014.  
  11015.  
  11016.  
  11017.  
  11018.  
  11019.  
  11020.  
  11021.  
  11022.                                                                             191
  11023.     ---------------------------------------------------------
  11024.     Example #4:  Controlling a POM File from the Command Line
  11025.     ---------------------------------------------------------
  11026.     
  11027.     Consider the following batch file, which we will call SELECT.BAT:
  11028.     
  11029.     @ECHO OFF                          <-- Turn off command-line echoing
  11030.     IF (%1) == () GOTO ERROR           <-- Make sure we have a parameter
  11031.     SET XYZ=;1                         <-- Set the environment variable XYZ
  11032.     POM SELECT.POM INPUT.TXT OUT.TXT   <-- Run the POM file SELECT.POM
  11033.     GOTO QUIT                          <-- Jump to the QUIT label
  11034.     :ERROR                             <-+
  11035.     ECHO Missing parameter               | Error-handling routine
  11036.     PAUSE                              <-+
  11037.     :QUIT                              <-- Batch file label
  11038.     SET XYZ=                           <-- Get rid of the environment variable
  11039.     
  11040.     SELECT.BAT can be used with this POM file, which will we name SELECT.POM:
  11041.     
  11042.     PROLOGUE
  11043.       GETENV xyz "XYZ"
  11044.     END
  11045.     OUTEND $FLINE ^ xyz |{$FLINE}
  11046.     
  11047.     You can use SELECT.BAT to output only those lines that contain the variable
  11048.     that you specify.  For example, you can enter the following command at the
  11049.     DOS prompt:
  11050.     
  11051.     SELECT MARY
  11052.     
  11053.     This will output only those lines (from INPUT.TXT) that contain "MARY".
  11054.     If you wish to ignore distinctions between uppercase and lowercase, change
  11055.     the last line of SELECT.POM accordingly:
  11056.     
  11057.     OUTEND $FLUPC ^ xyz |{$FLINE}
  11058.     
  11059.     Batch file parameters are separated by spaces on the command line, so the
  11060.     following command would not work as you might expect:
  11061.     
  11062.     SELECT MARY FRED JOHN
  11063.     
  11064.     This would set the batch variable %1 to MARY, ;2 to FRED and ;3 to JOHN.
  11065.     
  11066.     One way to deal with this is to eliminate the spaces when you run the
  11067.     batch file:
  11068.     
  11069.     SELECT MARY/FRED/JOHN
  11070.     
  11071.     
  11072.  
  11073.  
  11074.  
  11075.  
  11076.  
  11077.                                                                             192
  11078.     You can then replace the OUTEND command in SELECT.POM with these lines:
  11079.     
  11080.     APPEND x xyz "/"               <-- Set the x variable to "MARY/FRED/JOHN/"
  11081.     BEGIN x <> ""                  <-- We will loop through all of the names
  11082.       PEEL y x "" "/"              <-- Move a name to the y variable
  11083.       OUTEND $FLUPC ^ y |{$FLINE}  <-- Output a line if it contains the name
  11084.     AGAIN                          <-- Go back to the BEGIN
  11085.     
  11086.     Bear in mind that the system environment space is limited.  If you have
  11087.     problems with an application like this one, refer to "The GETENV Command",
  11088.     in the section entitled "Disappearing Environment Variables".
  11089.     
  11090.                                 --------------------
  11091.                                 Unattended Operation
  11092.                                 --------------------
  11093.     
  11094.     You can design applications that run themselves while you are not there.
  11095.     There are two reasons why you might want to do this:
  11096.     
  11097.     - You can run long processing jobs just before leaving work at night
  11098.     - Parse-O-Matic is useful, but it isn't very interesting to watch!
  11099.     
  11100.     Several features of Parse-O-Matic facilitate "unattended operation".
  11101.     
  11102.     - The SOUND command can alert you if something unusual happens; you don't
  11103.       have to stare at the screen to make sure that everything is working.
  11104.     
  11105.     - All error messages (which say "Press a key to continue") make a noise
  11106.       via the PC speaker (see "The Sound Command").
  11107.     
  11108.     - You can use the MSGWAIT command to let processing continue if there is
  11109.       an error (see "The MSGWAIT Command").
  11110.     
  11111.     - The processing log (see "Logging") can be used to check processing.
  11112.     
  11113.     Let's say you wanted to concatenate (add together) several enormous text
  11114.     files.  You could start with the following POM file (named ADD.POM):
  11115.     
  11116.     SET    cmd = $COMMAND
  11117.     BEGIN  cmd <> lastcmd
  11118.       SOUND  "BEEP"
  11119.       SET     lastcmd = cmd
  11120.     END
  11121.     OUTEND |{$FLINE}
  11122.     
  11123.     You could then enter the command POM ADD.POM *.TXT ALL.TXT and walk away.
  11124.     Whenever a new file is started, you will hear a beep.  When you come back,
  11125.     you can check the file POMLOG.TXT (which will be located in the same
  11126.     directory as POM.EXE).  It might look something like this:
  11127.     
  11128.     
  11129.  
  11130.  
  11131.  
  11132.                                                                             193
  11133.     COMMAND: POM ADD.POM *.TXT ALL.TXT
  11134.     DATE:    AUG 01 1997
  11135.     
  11136.     16:39:12 JOHN.TXT opened for processing
  11137.     16:45:28 JOHN.TXT processing completed
  11138.     
  11139.     16:45:29 MARY.TXT opened for processing
  11140.     16:52:10 MARY.TXT processing completed
  11141.     
  11142.     16:52:11 FRED.TXT opened for processing
  11143.     17:03:33 FRED.TXT processing completed
  11144.     
  11145.     If you are processing multiple files, and each one uses a different POM
  11146.     file (and hence requires a separate run of Parse-O-Matic) you can write
  11147.     your batch file so that it renames the log files.  This lets you review
  11148.     each log file later.  For example:
  11149.     
  11150.     @ECHO OFF
  11151.     POM JOHN.POM JOHN.TXT JOHN.LST
  11152.     RENAME C:\POM\POMLOG.TXT JOHN.LOG
  11153.     POM MARY.POM MARY.TXT MARY.LST
  11154.     RENAME C:\POM\POMLOG.TXT MARY.LOG
  11155.     POM FRED.POM FRED.TXT FRED.LST
  11156.     RENAME C:\POM\POMLOG.TXT FRED.LOG
  11157.     
  11158.     When processing is complete, the files JOHN.LOG, MARY.LOG and FRED.LOG
  11159.     will be available in the directory C:\POM for your inspection.
  11160.     
  11161.     Here is a slightly more sophisticated version of the batch file:
  11162.     
  11163.     @ECHO OFF
  11164.     POM JOHN.POM JOHN.TXT JOHN.LST
  11165.     IF ERRORLEVEL 1 GOTO QUIT
  11166.     RENAME C:\POM\POMLOG.TXT JOHN.LOG
  11167.     POM MARY.POM MARY.TXT MARY.LST
  11168.     IF ERRORLEVEL 1 GOTO QUIT
  11169.     RENAME C:\POM\POMLOG.TXT MARY.LOG
  11170.     POM FRED.POM FRED.TXT FRED.LST
  11171.     IF ERRORLEVEL 1 GOTO QUIT
  11172.     RENAME C:\POM\POMLOG.TXT FRED.LOG
  11173.     :QUIT
  11174.     
  11175.     The IF ERRORLEVEL lines jump to the end of the batch file if Parse-O-Matic
  11176.     generates an error of 1 or higher.  When coding batch files, remember that
  11177.     the IF ERRORLEVEL command is considered "True" if the error is the
  11178.     specified value or higher.  This means you should always test the higher
  11179.     value first.  See your operating system manual for details.
  11180.     
  11181.     
  11182.  
  11183.  
  11184.  
  11185.  
  11186.  
  11187.                                                                             194
  11188.                                       --------
  11189.                                       Examples
  11190.                                       --------
  11191.     
  11192.     Many of the techniques described in this manual are demonstrated by the
  11193.     examples provided with the standard Parse-O-Matic package.  To see these
  11194.     examples, switch to your Parse-O-Matic directory, type INFO at the DOS
  11195.     prompt, or run INFO.BAT from Windows or OS/2, then select TUTORIAL.
  11196.     
  11197.     
  11198.     
  11199.  
  11200.  
  11201.  
  11202.  
  11203.  
  11204.  
  11205.  
  11206.  
  11207.  
  11208.  
  11209.  
  11210.  
  11211.  
  11212.  
  11213.  
  11214.  
  11215.  
  11216.  
  11217.  
  11218.  
  11219.  
  11220.  
  11221.  
  11222.  
  11223.  
  11224.  
  11225.  
  11226.  
  11227.  
  11228.  
  11229.  
  11230.  
  11231.  
  11232.  
  11233.  
  11234.  
  11235.  
  11236.  
  11237.  
  11238.  
  11239.  
  11240.  
  11241.  
  11242.                                                                             195
  11243.     ============================================================================
  11244.                              OPERATIONAL CONSIDERATIONS
  11245.     ============================================================================
  11246.     
  11247.                   -----------------------------------------------
  11248.                   Running Parse-O-Matic on 8088 and 8086 Machines
  11249.                   -----------------------------------------------
  11250.     
  11251.     Parse-O-Matic is designed to run on 80286 machines and higher, in "protected
  11252.     mode".  If you have a pressing need to run it on an old 8088 or 8086-class
  11253.     "real mode" machine (e.g. PC or XT), we may be able to prepare a custom copy
  11254.     for you.  Contact us for details.
  11255.     
  11256.                      ------------------------------------------
  11257.                      Running Parse-O-Matic from Another Program
  11258.                      ------------------------------------------
  11259.     
  11260.     If you are calling Parse-O-Matic from a program written in a high-level
  11261.     language (such as Pascal, Delphi, C or Basic), you can check its success or
  11262.     failure by consulting the "DOS Error Level".  Most languages have built-in
  11263.     facilities to test this value.
  11264.     
  11265.     For example, Turbo Pascal lets you run another program with the EXEC
  11266.     command, after which you can extract the ERRORLEVEL from the low byte of
  11267.     the DosExitCode variable.  You can also check the DOSERROR return code
  11268.     to check for invocation errors.  Some typical errors include:
  11269.     
  11270.     Program not found, Path not found, Access denied, Not enough memory.
  11271.     
  11272.     On long parsing jobs (taking 3 seconds or more on your slowest machine),
  11273.     it is perhaps best to let the user see the processing screen rather than
  11274.     running in Quiet Mode (see "Quiet Mode").  If nothing else, it gives him
  11275.     or her something to look at, and provides assurance that the machine has
  11276.     not stopped working.
  11277.     
  11278.                               -----------------------
  11279.                               Solving Memory Problems
  11280.                               -----------------------
  11281.     
  11282.     Parse-O-Matic does all of its work in standard memory; it does not use
  11283.     Extended or Expanded memory.  This is rarely a problem, but if you do
  11284.     somehow run out of memory, there are some steps you can take...
  11285.     
  11286.     You can often free up some extra memory by unloading unused device drivers
  11287.     and DOS TSR ("Terminate and Stay Resident") programs.  (TSR's are sometimes
  11288.     called "DOS Pop-Ups")
  11289.     
  11290.     Alternatively, most drivers and TSR's can be safely moved into high memory,
  11291.     using the LOADHIGH function in your AUTOEXEC.BAT, or the DEVICEHIGH
  11292.     function in CONFIG.SYS.  Some older drivers and TSR's will not tolerate
  11293.     this kind of relocation.
  11294.     
  11295.     
  11296.  
  11297.                                                                             196
  11298.     ============================================================================
  11299.                                RUNNING UNDER WINDOWS
  11300.     ============================================================================
  11301.     
  11302.                                    -------------
  11303.                                    Compatibility
  11304.                                    -------------
  11305.     
  11306.     Parse-O-Matic is a DOS program, which has a few advantages and a few minor
  11307.     disadvantages for Windows users.
  11308.     
  11309.     The primary advantage is that a Parse-O-Matic application can run on any
  11310.     PC-compatible machine, whether it is running DOS, Windows, or OS/2.
  11311.     Emulators are also available which will let you run Parse-O-Matic (and
  11312.     other DOS software) on Macintosh, Unix, Linux and other computers.
  11313.     
  11314.     Since Parse-O-Matic has no user interface to speak of, Windows' wonderful
  11315.     graphical environment is not particularly important.  The only operational
  11316.     difference is that to interrupt Parse-O-Matic processing, you press the Esc
  11317.     key instead of clicking on a Cancel button.
  11318.     
  11319.     Performance is a consideration if you are running Parse-O-Matic at the same
  11320.     time as 32-bit applications under Windows; it will slow them down slightly.
  11321.     However, unless you are multi-tasking heavily, performance is not an issue
  11322.     because the usual bottleneck is the responsiveness and transfer speed of the
  11323.     hard disk, not the speed at which the Parse-O-Matic program runs.
  11324.     
  11325.                              -------------------------
  11326.                              Setting Up for Windows 95
  11327.                              -------------------------
  11328.     
  11329.     To use Parse-O-Matic under Windows, you need the following items, which are
  11330.     included in the standard Parse-O-Matic package:
  11331.     
  11332.     1)  The POM file (icon file POM_FILE.ICO)
  11333.     2)  A batch file (icon file BAT.ICO)
  11334.     
  11335.     These two icon files are included in the standard Parse-O-Matic package.
  11336.     You may find it helpful to copy them to your main Windows directory so
  11337.     that the associations you set for them are not lost if you install
  11338.     a new version of Parse-O-Matic and then delete the original POM directory.
  11339.     
  11340.     ------------------------------------------
  11341.     Setting Up an Association for the POM File
  11342.     ------------------------------------------
  11343.     
  11344.     When you click on a POM file, it should call up a text editor.  To configure
  11345.     this, follow these steps:
  11346.     
  11347.     1)  Double-click on "My Computer"
  11348.     
  11349.     2)  From the pull-down menu, select View/Options
  11350.     
  11351.  
  11352.                                                                             197
  11353.     3)  Dialog Box:  Options
  11354.         Click on the File Types tab
  11355.         Click on the New Type button
  11356.     
  11357.     4)  Dialog Box:  Add New File Type
  11358.         Description:  Parse-O-Matic Control File
  11359.         Associated extension:  POM
  11360.         Click on the New button
  11361.     
  11362.     5)  Dialog Box:  New Action
  11363.         Action:  &Edit
  11364.         Application used:  NOTEPAD.EXE (or the path to your favorite editor)
  11365.         Click on the OK button
  11366.     
  11367.     6)  Dialog Box:  Add New File Type
  11368.         Click on the Change Icon button
  11369.         Click on the Browse button
  11370.         File name: The full path to POM_FILE.ICO (e.g. C:\POM\POM_FILE.ICO)
  11371.         Press Enter
  11372.     
  11373.     7)  Dialog Box:  Change Icon
  11374.         Click the OK button
  11375.     
  11376.     8)  Dialog Box:  Add New File Type
  11377.         Click the Close button
  11378.     
  11379.     9)  Dialog Box: Options
  11380.         Click the Close button
  11381.     
  11382.     Once you have followed these steps, you can double-click on the POM file
  11383.     icon when you are in Windows Explorer or a file folder, and it will be
  11384.     opened with the file editor you specified in step 5.
  11385.     
  11386.     ----------------------------------------------
  11387.     Setting Up an Association for a POJ (Job) File
  11388.     ----------------------------------------------
  11389.     
  11390.     When you click on a POJ file, it should call up Parse-O-Matic.  To configure
  11391.     this, follow these steps:
  11392.     
  11393.     1)  Double-click on "My Computer"
  11394.     
  11395.     2)  From the pull-down menu, select View/Options
  11396.     
  11397.     3)  Dialog Box:  Options
  11398.         Click on the File Types tab
  11399.         Click on the New Type button
  11400.     
  11401.     4)  Dialog Box:  Add New File Type
  11402.         Description:  Parse-O-Matic Control File
  11403.         Associated extension:  POJ
  11404.         Click on the New button
  11405.     
  11406.  
  11407.                                                                             198
  11408.     5)  Dialog Box:  New Action
  11409.         Action:  &Open
  11410.         Application used:  The path to POM.EXE  (e.g. C:\POM\POM.EXE)
  11411.         Click on the OK button
  11412.     
  11413.     6)  Dialog Box:  Add New File Type
  11414.         Click on the Change Icon button
  11415.         Click on the Browse button
  11416.         File name: The path to POJ_FILE.ICO (e.g. C:\POM\POJ_FILE.ICO)
  11417.         Press Enter
  11418.     
  11419.     7)  Dialog Box:  Change Icon
  11420.         Click the OK button
  11421.     
  11422.     8)  Dialog Box:  Add New File Type
  11423.         Click the Close button
  11424.     
  11425.     9)  Dialog Box: Options
  11426.         Click the Close button
  11427.     
  11428.     Once you have followed these steps, you can double-click on the POJ file
  11429.     icon when you are in Windows Explorer or a file folder, and it will start
  11430.     up Parse-O-Matic and run to specified job (POJ) file.
  11431.     
  11432.     -----------------------------------------------------
  11433.     Setting Up an Association for the BAT File (Optional)
  11434.     -----------------------------------------------------
  11435.     
  11436.     Windows 95 is already set up to process batch (BAT) files.  However,
  11437.     Parse-O-Matic comes with an alternative icon which is more distinctive than
  11438.     the one supplied with Windows.  (The Parse-O-Matic icon looks like a bat --
  11439.     a sonar-equipped flying critter with an undeserved bad reputation).
  11440.     
  11441.     To change the icon, follow these steps:
  11442.     
  11443.     1)  Double-click on "My Computer"
  11444.     
  11445.     2)  From the pull-down menu, select View/Options
  11446.     
  11447.     3)  Dialog Box:  Options
  11448.         On the list box, find and double-click on MS-DOS Batch File
  11449.     
  11450.     4)  Dialog Box:  Edit File Type
  11451.         Click on the Change Icon button
  11452.     
  11453.     5)  Dialog Box:  Change Icon
  11454.         Click the Browse button
  11455.         File name: The full path to BAT.ICO (e.g. C:\POM\BAT.ICO)
  11456.         Press Enter
  11457.     
  11458.     6)  Dialog Box:  Change Icon
  11459.         Click the OK button
  11460.     
  11461.  
  11462.                                                                             199
  11463.     7)  Dialog Box:  Edit File Type
  11464.         Click the Close button
  11465.     
  11466.     8)  Dialog Box: Options
  11467.         Click the Close button
  11468.     
  11469.     After following this procedure, your batch (BAT) file icons will be much
  11470.     more noticeable when they appear in Windows Explorer or a file folder.  To
  11471.     edit the batch file, right-click on the icon and select Edit.  To run the
  11472.     batch file, simply double-click the icon.
  11473.     
  11474.     For a discussion of batch files, see "Batch Files".
  11475.     
  11476.                         -----------------------------------
  11477.                         Setting Up for Windows 98, Me, 2000
  11478.                         -----------------------------------
  11479.     
  11480.     Under Windows, when you click on file types that are not recognized (which
  11481.     will initially be the case for .POM and .POJ files), Windows offers to
  11482.     assign them to a particular program.  You need to associate .POM files with
  11483.     your favorite text editor, and .POJ files with POM.EXE.
  11484.     
  11485.     When you double-click an unrecognized file type, Windows will ask you what
  11486.     program you want to use to open that file.  You should start by typing in a
  11487.     description for the file type (e.g. "POM Job File" for .POJ files and "POM
  11488.     Script File" for .POM files).  You then point to the appropriate program.
  11489.     In the case of .POJ files, you will click on the "Other..." button to point
  11490.     to the program POM.EXE.
  11491.     
  11492.     ----------------------------------
  11493.     Additional Associations (Optional)
  11494.     ----------------------------------
  11495.     
  11496.     After associating .POJ files with POM.EXE and .POM files with your favorite
  11497.     text editor, you can provide additional, right-clickable options (such as
  11498.     opening a .POJ file with a text editor).  Under WinMe, you do this as
  11499.     follows:
  11500.     
  11501.     - Double-click "My Computer" (located on your desktop)
  11502.     - Select "Tools", then "Folder Options"
  11503.     - Click on the "File Types" tab
  11504.     - Click on the file type you want to enhance (POM or POJ)
  11505.     - Click on "Advanced"
  11506.     
  11507.     
  11508.  
  11509.  
  11510.  
  11511.  
  11512.  
  11513.  
  11514.  
  11515.  
  11516.  
  11517.                                                                             200
  11518.                            ------------------------------
  11519.                            Installing the ShowNum Utility
  11520.                            ------------------------------
  11521.     
  11522.     The ShowNum program is a small utility which converts a hex number to
  11523.     decimal and vice-versa, or displays the ASCII value of a character (see "The
  11524.     ShowNum Utility").
  11525.     
  11526.     To install ShowNum as a Windows shortcut:
  11527.     
  11528.     1)  Select "File/New/Shortcut" from the pull-down menu of any folder.
  11529.     
  11530.     2)  Specify the path name to SHOWNUM.BAT, followed by a question mark.
  11531.         For example:  C:\POM\SHOWNUM.BAT ?
  11532.         The ? means "Prompt for input before calling the batch file".
  11533.     
  11534.     3)  After you have finished defining the shortcut, right-click on the icon,
  11535.         select "Properties", then the "Program" tab, and make sure the "Close
  11536.         on exit" box is checked off.
  11537.     
  11538.     You can then use ShowNum by double-clicking its icon.  You will be prompted
  11539.     to enter a number, and the answer will be displayed.
  11540.     
  11541.                              --------------------------
  11542.                              Long File Names in Windows
  11543.                              --------------------------
  11544.     
  11545.     Although Parse-O-Matic runs under Windows, it will only recognize standard
  11546.     "8.3" DOS file names; it does not use the long file names supported by
  11547.     Windows. You can determine the underlying DOS name of a file by checking its
  11548.     "Properties" in Windows Explorer, or by using the DIR command while in DOS
  11549.     mode.
  11550.     
  11551.                                 -------------------
  11552.                                 The WINUTIL Utility
  11553.                                 -------------------
  11554.     
  11555.     The WinUtil program (WINUTIL.EXE in the standard Parse-O-Matic package) is
  11556.     a small utility which provides some Windows functions if you are running
  11557.     in a DOS window.
  11558.     
  11559.     WinUtil can detect if Windows is running, and lets you copy a file to
  11560.     the Windows clipboard, or create a file from the contents of the clipboard.
  11561.     
  11562.     
  11563.  
  11564.  
  11565.  
  11566.  
  11567.  
  11568.  
  11569.  
  11570.  
  11571.  
  11572.                                                                             201
  11573.     -----------
  11574.     Limitations
  11575.     -----------
  11576.     
  11577.     WinUtil does not work with Windows 3.1 or earlier.  It has been tested under
  11578.     Windows 95, 98 and Me.
  11579.     
  11580.     WinUtil requires the use of 8.3 style file names.  That is to say, it can
  11581.     not handle the long file names that were introduced by Windows 95.
  11582.     
  11583.     WinUtil can handle clipboard data up to 65535 bytes. Attempts to process a
  11584.     larger amount of data will cause an error.
  11585.     
  11586.     ----------------------
  11587.     Quick Reference Screen
  11588.     ----------------------
  11589.     
  11590.     To display a quick-reference help screen, enter the following command at
  11591.     the DOS prompt:
  11592.     
  11593.     WINUTIL /?
  11594.     
  11595.     -----------------
  11596.     Sample Batch File
  11597.     -----------------
  11598.     
  11599.     You will usually use WinUtil in a batch file.  For example:
  11600.     
  11601.     @ECHO OFF                        <-- Turn off echo
  11602.     WINUTIL CHECK                    <-- See if Windows is running
  11603.     IF ERRORLEVEL 1 GOTO OKWIN       <-- Skip ahead if Windows is running
  11604.     ECHO Windows is not running!     <-- Display warning
  11605.     GOTO QUIT                        <-- Skip ahead to end of batch file
  11606.     :OKWIN                           <-- Batch file label
  11607.     WINUTIL CLIP WRITE work.txt      <-- Copy the clipboard to a text file
  11608.     POM editwork.pom in.txt out.txt  <-- Modify the text file with POM
  11609.     IF ERRORLEVEL 1 GOTO OOPS        <-- Stop if there's an error
  11610.     WINUTIL CLIP READ out.txt        <-- Copy the text file to the clipboard
  11611.     DEL in.txt                       <-- Erase work file
  11612.     DEL out.txt                      <-- Erase work file
  11613.     GOTO QUIT                        <-- Skip ahead to end of batch file
  11614.     :OOPS                            <-- Batch file label
  11615.     ECHO Parsing job failed          <-- Display warning
  11616.     PAUSE                            <-- Wait for a key to be pressed
  11617.     :QUIT                            <-- Batch file label
  11618.     
  11619.     
  11620.  
  11621.  
  11622.  
  11623.  
  11624.  
  11625.  
  11626.  
  11627.                                                                             202
  11628.     -------------------------------
  11629.     Detecting if Windows is Running
  11630.     -------------------------------
  11631.     
  11632.     To check if Windows is running, use the following command format on the DOS
  11633.     command line, or in a batch file:
  11634.     
  11635.     FORMAT:   WINUTIL CHECK [V]
  11636.     EXAMPLE:  WINUTIL CHECK
  11637.     
  11638.     The V parameter is optional.  If it is included, WinUtil will operate in
  11639.     "verbose" mode.  That is to say, it will display one of the following
  11640.     messages:
  11641.     
  11642.       Windows is running
  11643.       Windows is NOT running
  11644.     
  11645.     If the V parameter is omitted, WinUtil does not display a message.
  11646.     
  11647.     If Windows is running, WinUtil sets the DOS return code to 1.  If Windows is
  11648.     not running, WinUtil sets the DOS return code to 0.  You can test the return
  11649.     code using the IF ERRORLEVEL batch file function.  (See "Sample Batch File",
  11650.     above, for an example.)
  11651.     
  11652.     ------------------------------------
  11653.     Copying the Clipboard to a Text File
  11654.     ------------------------------------
  11655.     
  11656.     To copy the Windows clipboard to a text file, use the following command
  11657.     format on the DOS command line, or in a batch file:
  11658.     
  11659.     FORMAT:   WINUTIL CLIP WRITE filename
  11660.     EXAMPLE:  WINUTIL CLIP WRITE clip.txt
  11661.     
  11662.     The DOS return code is set as follows:
  11663.     
  11664.     0    The operation was successfully carried out
  11665.     1    The clipboard did not contain any text
  11666.     255  A processing error occurred
  11667.     
  11668.     If the file you are writing to already exists, it is renamed with a .BAK
  11669.     extension.
  11670.     
  11671.     
  11672.  
  11673.  
  11674.  
  11675.  
  11676.  
  11677.  
  11678.  
  11679.  
  11680.  
  11681.  
  11682.                                                                             203
  11683.     ------------------------------------
  11684.     Copying a Text File to the Clipboard
  11685.     ------------------------------------
  11686.     
  11687.     To copy a text file to the Windows clipboard, use the following command
  11688.     format on the DOS command line, or in a batch file:
  11689.     
  11690.     FORMAT:   WINUTIL CLIP READ filename
  11691.     EXAMPLE:  WINUTIL CLIP READ clip.txt
  11692.     
  11693.     The DOS return code is set as follows:
  11694.     
  11695.     0    The operation was successfully carried out
  11696.     1    The text file did not contain any text
  11697.     255  A processing error occurred
  11698.     
  11699.                                   ---------------
  11700.                                   The SEE Utility
  11701.                                   ---------------
  11702.     
  11703.     Parse-O-Matic comes with a file view/print/extract utility known as SEE
  11704.     (SEE.EXE).  The copy included in the standard package is for single-user
  11705.     operation with an evaluation or registered copy of Parse-O-Matic.  It
  11706.     may not be distributed (even if you have purchased a Distribution License
  11707.     for Parse-O-Matic).
  11708.     
  11709.     You may purchase a registered copy of SEE (including the full manual and
  11710.     walk-through).  Multi-copy and Distribution Licenses are available.  For
  11711.     more information: please phone us at +1-416-287-8892.
  11712.  
  11713.  
  11714.  
  11715.  
  11716.  
  11717.  
  11718.  
  11719.  
  11720.  
  11721.  
  11722.  
  11723.  
  11724.  
  11725.  
  11726.  
  11727.  
  11728.  
  11729.  
  11730.  
  11731.  
  11732.  
  11733.  
  11734.  
  11735.  
  11736.  
  11737.                                                                             204
  11738.