home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / qtawk / qtawk.doc < prev    next >
Text File  |  1990-11-10  |  345KB  |  9,614 lines

  1. I
  2.  
  3.  
  4.  
  5.  
  6.  
  7.         
  8.         
  9.         
  10.         
  11.         
  12.         
  13.         
  14.         
  15.         
  16.         
  17.         
  18.         
  19.         
  20.         
  21.         
  22.         -EQTAwkF-Ç
  23.         -EUtility Creation ToolF-Ç
  24.         
  25.         
  26.         For PC/MS-DOS
  27.         Version 4.20 10-10-90
  28.         
  29.         
  30.         
  31.         
  32.         
  33.         
  34.         
  35.         
  36.         Saturday, November 10, 1990
  37.         
  38.         
  39.         
  40.         
  41.         
  42.         -E(c) Copyright 1989, 1990 Pearl BoldtF-Ç
  43.         
  44.         Darnestown, MD 20878
  45.         
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.         QTAwk License
  62.         Utility Creation Program
  63.         Version 4.20 10-10-90
  64.         (c) Copyright 1988 -  1990  Pearl  Boldt.  All  Rights  Reserved.
  65.         
  66.         Pearl Boldt
  67.         Quik Trim
  68.         13012 Birdale Lane
  69.         Darnestown, MD 20878
  70.             CompuServe ID: 72040.434
  71.         
  72.          Registration Information
  73.         
  74.          QTAwk  is  a  copyrighted  program  protected  by  both U.S. and
  75.         international  copyright  law.  If  you  obtained  QTAwk  from  a
  76.         shareware  disk  vendor,  an on-line computer service or bulletin
  77.         board, a friend or colleague, or another similar source, you have
  78.         an  unregistered  (trial)  copy.  You  may  use this copy without
  79.         charge for a limited period of time under the terms of the  QTAwk
  80.         license  agreement  (below).  After  this  time  is  up, you must
  81.         register and pay for QTAwk to continue using it.
  82.         
  83.          This method of distribution is known as shareware. It allows you
  84.         to  determine  whether  QTAwk meets your needs before you pay for
  85.         it.
  86.         
  87.          The registration fee for a single copy of QTAwk is $50.  Payment
  88.         of this fee entitles you to:
  89.         
  90.         *  A  disk  with  the latest version of QTAwk, registered to you.
  91.         
  92.         * One copy of the printed QTAwk manual.
  93.         
  94.         * An upgrade to the next release of QTAwk.
  95.         
  96.         * Technical support via electronic mail or telephone.
  97.         
  98.          If you prefer, you may register for $35  and  receive  only  the
  99.         disk and notices of future upgrades. Network, site, and corporate
  100.         licenses are also available; contact  the  copyright  holder  for
  101.         more information.
  102.         
  103.          Upgrade Information
  104.         
  105.          If you purchased QTAwk version 4.02 or later at the $50 rate, or
  106.         a site license for version 4.02 or later, you are entitled  to  a
  107.         free  upgrade  to version 4.20. If you are not entitled to a free
  108.         upgrade, or you wish to order a version 4.20 manual use the order
  109.  
  110.  
  111.         QTAwk                        - iii -                        QTAwk
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.         form following the License Agreement.
  119.         
  120.          QTAwk License Agreement
  121.         
  122.         1.  Copyright:  The  QTAwk  program  and  all  other programs and
  123.             documentation distributed or shipped with  it  are  Copyright
  124.             1988  -  1990  Pearl  Boldt  and  are  protected  by U.S. and
  125.             International Copyright law. In the rest  of  this  document,
  126.             this collection of programs is referred to simply as "QTAwk".
  127.             You are granted a license to use  your  copy  of  QTAwk  only
  128.             under  the  terms  and  conditions  specified in this license
  129.             agreement.
  130.             
  131.         2.  Definitions:  QTAwk  is   distributed   in   two   forms.   A
  132.             "registered" copy of QTAwk is a copy distributed on diskette,
  133.             purchased from the copyright holder. A  "shareware"  copy  of
  134.             QTAwk  is a copy distributed on diskette or via an electronic
  135.             bulletin board, on-line service, or other  electronic  means,
  136.             obtained  from  a  shareware  disk  vendor,  or obtained from
  137.             another individual.
  138.             
  139.         3.  Shareware Copies: Shareware copies of QTAwk  are  distributed
  140.             to  allow  you to try the program before you pay for it. They
  141.             are Copyright 1988 - 1990, Pearl Boldt and do not  constitute
  142.             "free"  or  "public domain" software. You may use a shareware
  143.             copy of QTAwk at no charge for a trial period  of  up  to  21
  144.             days.  If you wish to continue using QTAwk after that period,
  145.             you must purchase a registered copy. If  you  choose  not  to
  146.             purchase a registered copy, you must stop using QTAwk, though
  147.             you may keep copies and pass them along to  others.  You  may
  148.             give QTAwk to others for noncommercial use IF:
  149.             
  150.                  => All Files And Documentation Accompany The Programs.
  151.                  => The Files Are Not Modified In Any Way.
  152.             
  153.         4.  Registered   Copies:   Registered   copies   of   QTAwk   are
  154.             distributed  to  those  who  have  purchased  them  from  the
  155.             copyright holder.
  156.             
  157.         5.  Use  of  One  Copy on Two Computers: If you have a registered
  158.             copy of QTAwk which is licensed for use on a single computer,
  159.             you  may  install  it  on two computers used at two different
  160.             locations (for example, at work and at home), provided  there
  161.             is  no  possibility  that the two computers will be in use at
  162.             the same time, and provided that you yourself have  purchased
  163.             QTAwk,  or  if QTAwk was purchased by your employer, that you
  164.             have your employer's explicit permission to install QTAwk  on
  165.             two  systems  as  described  in  this paragraph. The right to
  166.  
  167.  
  168.         QTAwk                        - iv -                         QTAwk
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.             install one copy of QTAwk on  two  computers  is  limited  to
  176.             copies  originally licensed for use on a single computer, and
  177.             may not be used to expand the number of systems covered under
  178.             a multi-system license.
  179.             
  180.         6.  Use  of  QTAwk  on  Networks  or  Multiple  Systems:  You may
  181.             install your registered copy of QTAwk on a computer  attached
  182.             to  a  network, or remove it from one computer and install it
  183.             on a different one, provided there  is  no  possibility  that
  184.             your copy will be used by more users than it is licensed for.
  185.             A "user" is defined as one keyboard which is connected  to  a
  186.             computer  on  which QTAwk is installed or used, regardless of
  187.             whether or not the user of  the  keyboard  is  aware  of  the
  188.             installation or use of QTAwk in the system.
  189.             
  190.         7.  Making  Copies:  You may copy any version of QTAwk for normal
  191.             backup purposes, and you may give  copies  of  the  shareware
  192.             version  to other individuals subject to paragraph (4) above.
  193.             You may not give copies of  the  registered  version  to  any
  194.             other  person  for  any  purpose,  without  explicit  written
  195.             permission from the copyright holder.
  196.             
  197.         8.  Distribution  Restrictions:  You  may  NOT  distribute  QTAwk
  198.             other than through individual copies of the shareware version
  199.             passed  to  friends  and  associates  for  their  individual,
  200.             non-commercial  use. Specifically, you may not place QTAwk or
  201.             any part of the QTAwk package in any user group or commercial
  202.             library,  or  distribute  it  with any other product or as an
  203.             incentive to purchase  any  other  product,  without  express
  204.             written  permission from the copyright holder and you may not
  205.             distribute for a fee, or in any way sell copies of  QTAwk  or
  206.             any  part  of  the QTAwk package. If you are a shareware disk
  207.             vendor approved by the Association of Shareware Professionals
  208.             (ASP),  you  may  place  QTAwk  in your library without prior
  209.             written permission, provided you notify the copyright  holder
  210.             within  15 days of doing so and provided your application has
  211.             been fully approved in writing by the ASP, and is not  simply
  212.             submitted or awaiting review.
  213.             
  214.         9.  Use  of  QTAwk:  QTAwk  is  a powerful program. While we have
  215.             attempted to build in reasonable safeguards, if  you  do  not
  216.             use  QTAwk  properly  you  may  destroy  files or cause other
  217.             damage to your computer software and data.  You  assume  full
  218.             responsibility  for the selection and use of QTAwk to achieve
  219.             your intended results. As stated below, the warranty on QTAwk
  220.             is  limited to replacement of a defective program diskette or
  221.             manual.
  222.             
  223.  
  224.  
  225.         QTAwk                         - v -                         QTAwk
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.         10.  LIMITED  WARRANTY:  All  warranties  as  to  this  software,
  233.             whether express or implied, are disclaimed, including without
  234.             limitation any implied warranties of merchantability, fitness
  235.             for  a particular purpose, functionality or data integrity or
  236.             protection are disclaimed.
  237.             
  238.         11.  Satisfaction Guarantee:  If  you  are  dissatisfied  with  a
  239.             registered  copy  of QTAwk for any reason (whether or not you
  240.             find a software error or defect), you may return  the  entire
  241.             package  at  any time up to 90 days after purchase for a full
  242.             refund of your original registration fee.
  243.         
  244.         Questions may be sent to:
  245.         
  246.         Pearl Boldt
  247.         Quik Trim
  248.         13012 Birdale Lane
  249.         Darnestown, MD 20878
  250.             CompuServe ID: 72040.434
  251.         
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.         QTAwk                        - vi -                         QTAwk
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.         QTAwk 4.20 Order Form
  290.         Utility Creation Program
  291.         Version 4.20 10-10-90
  292.         (c) Copyright 1988 -  1990  Pearl  Boldt.  All  Rights  Reserved.
  293.         
  294.         Return to:
  295.         Pearl Boldt
  296.         Quik Trim
  297.         13012 Birdale Lane
  298.         Darnestown, MD 20878
  299.         
  300.         Make all Checks Payable to: Pearl Boldt
  301.         
  302.         Name:
  303.         Company:
  304.         Address:
  305.         
  306.         Phone:
  307.         
  308.         Register QTAwk to: Company (___) or Individual (___)
  309.         Send  information on: Site Licenses (___), Reseller Pricing (___)
  310.         
  311.         I have read and agree to abide by the  QTAwk  license  agreement,
  312.         
  313.         Signature:
  314.         
  315.         Where did you hear about QTAwk?
  316.         
  317.         
  318.                                Quantity    Price
  319.         
  320.         Disk, manual, next update ($50/copy):  ________  $ ________.____
  321.         Disk only, no update ($35/copy):       ________  $ ________.____
  322.         
  323.         Disk size:   ___ 5.25" acceptable   ___ 3.5" required
  324.         
  325.         Subtotal                     $ ________.____
  326.         
  327.         Shipping charges, per copy:             $ ________.____
  328.         
  329.         Disk, manual, next update:      │ Disk only:
  330.           US standard       - included      │   US standard      - included
  331.           US 2-day       - $8.00 (US)   │   US 2-day           - $8.00 (US)
  332.           Canada (air)       - $5.00 (US)   │   Canada  (air)    - $3.00 (US)
  333.           All Others (air) - $10.00 (US)  │   All Others (air) - $5.00 (US)
  334.         
  335.         Total enclosed:                  $ ________.____
  336.  
  337.  
  338.  
  339.         QTAwk                        - vii -                        QTAwk
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.               ===> Please read the following before ordering! <===       
  347.         
  348.          Order Information
  349.         
  350.          International Orders:
  351.         
  352.          Orders  from  outside  the U.S. must be paid by a check or money
  353.         order in  U.S.  funds  and  drawn  on  a  U.S.  bank;  or  by  an
  354.         international  postal  money  order in U.S. dollars. Checks which
  355.         are not in U.S. funds and drawn on a U.S. bank will  be  returned
  356.         due  to  extremely  high charges imposed by U.S. banks to collect
  357.         the funds. Purchase orders (minimum $200) can  be  accepted  from
  358.         outside the U.S., but you must contact us before ordering.
  359.         
  360.          Company Purchase Orders:
  361.         
  362.          Purchase  orders  for amounts of $100 and over are accepted from
  363.         established U.S. companies; orders under $100  are  accepted  but
  364.         must  be  prepaid. Have your purchasing agent contact Pearl Boldt
  365.         for terms. Credit references will be required for new  customers.
  366.         
  367.          Multi-System Licenses:
  368.         
  369.          Multi-system  licensing  arrangements are available for network,
  370.         site, and corporate use of QTAwk. Check the  line  on  the  order
  371.         form  or  con- tact us for more information. A sample schedule of
  372.         license fees is below; contact us for pricing on the exact number
  373.         of  systems  you  wish  to  license.  The  fee  includes a master
  374.         diskette and one manual; addi- tional manuals are $10 each  (less
  375.         for over 100 copies).
  376.         
  377.         
  378.         Systems  Price      Systems  Price       Systems  Price          
  379.         2         85.00     15       425.00      50       1,150.00       
  380.         3        120.00     20       550.00      60       1,160.00       
  381.         4        155.00     25       675.00      70       1,320.00       
  382.         5        190.00     30       750.00      80       1,480.00       
  383.         10       330.00     40       950.00      100      1,800.00       
  384.         
  385.         Return to:
  386.         Pearl Boldt
  387.         Quik Trim
  388.         13012 Birdale Lane
  389.         Darnestown, MD 20878
  390.         
  391.         Make all Checks Payable to: Pearl Boldt
  392.         
  393.  
  394.  
  395.  
  396.         QTAwk                       - viii -                        QTAwk
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.                               QTAwk Update History                       
  404.         
  405.          ==>  QTAwk  Version  4.02.  This  version contains two additions
  406.         from the previous versions:
  407.         
  408.         1.  The  command  line  argument,  double  hyphen,  "--",   stops
  409.             further  scanning of the command line for options. The double
  410.             hyphen argument is not passed to the  QTAwk  utility  in  the
  411.             ARGV  array or counted in the ARGC variable. Since QTAwk only
  412.             recognizes two command options, this has been included to  be
  413.             compatible with the latest Unix(tm) conventions.
  414.             
  415.         2.  The  built-in  array  ENVIRON  has  been  added.  This  array
  416.             contains the environment strings passed to QTAwk. Changing  a
  417.             string  in  ENVIRON  will  have  no effect on the environment
  418.             strings passed  in  the  QTAwk  "system"  built-in  function.
  419.             Environment strings are set with the PC/MS-DOS "SET" command.
  420.             The strings are of the form:
  421.             
  422.                                     name = string                        
  423.             
  424.              where the blanks on either side of the equal sign, '=',  are
  425.             optional  and depend on the particular form used in the "SET"
  426.             command. The QTAwk utility may scan the elements  of  ENVIRON
  427.             for a particular name or string as desired.
  428.         
  429.         
  430.          ==>  QTAwk Version 4.10. This version contains one addition from
  431.         the previous versions:
  432.         
  433.         1.  In previous versions, the GROUP pattern keyword could  accept
  434.             patterns  consisting  only  of a regular expression constant.
  435.             For version 4.10, The GROUP pattern keyword has been expanded
  436.             to accept {re] constants, string constants and variables. The
  437.             variables are evaluated at the time the  GROUP  patterns  are
  438.             first  utilized  to  scan  an  input  record.  The  value  is
  439.             converted  to  string  form  and  interpreted  as  a  regular
  440.             expression.
  441.             
  442.             GROUP /regular expression constant/ { ... }
  443.             GROUP "string constant" { ... }
  444.             GROUP Variable_name { ... }
  445.             
  446.              GROUP patterns are still converted into an internal form for
  447.             regular expressions only once, when the pattern is first used
  448.             to  scan an input line. Any variables in a GROUP pattern will
  449.             be evaluated, converted to  string  form  and  interpreted  a
  450.             regular expression.
  451.  
  452.  
  453.         QTAwk                        - ix -                         QTAwk
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.          ==>  QTAwk  Version  4.20, dated 10/11/90. This version contains
  461.         three additions from the previous versions:
  462.         
  463.         1.  The  behavior  of  the  RS  pre-defined  variable  has   been
  464.             changed.  It  is  now  similar  to  the  behavior  of  the FS
  465.             variable. If RS is assigned a value, which when converted  to
  466.             a  string  value,  is a single character in length, then that
  467.             character becomes the record  separator.  If  the  string  is
  468.             longer  in length than a single character, then it is treated
  469.             as a regular expression.  The  string  matching  the  regular
  470.             expression  is  treated as a record separator. As for FS, the
  471.             string value is converted to the internal regular  expression
  472.             form when the assignment is made.
  473.             
  474.         2.  Two new functions have been added:
  475.             getc()  -->  reads  a single character from the current input
  476.                 file. The character is returned by the function.
  477.             fgetc(file) -->  reads  a  single  character  from  the  file
  478.                 'file'. The character is returned by the function.
  479.             
  480.              These  functions  allow  the user to naturally obtain single
  481.             characters from any file including the  standard  input  file
  482.             (which  would  be  the  keybord  if not redirected or piped).
  483.             
  484.         3.  Error messages  now  have  a  numerical  value  displayed  in
  485.             addition  to  the short error message. The error messages are
  486.             listed in numerical order in the QTAwk documentation  with  a
  487.             short explanation of the error. In some cases, an attempt has
  488.             been made to provide guidance as to what may have caused  the
  489.             error  and  possible  remedies.  Since the error messages are
  490.             generated at fixed points within QTAwk and may be  caused  by
  491.             different    reasons    in    different    utilities   during
  492.             interpretation or during execution on data files, it  is  not
  493.             possible to list every possible reason for the display of the
  494.             error messages. The line number within the QTAwk  utility  on
  495.             which the error was discovered and the input data file record
  496.             number are provided in the error message to provide some help
  497.             to  the  user  in attempting to ascertain the real reason for
  498.             the error.
  499.         
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.         QTAwk                         - x -                         QTAwk
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.         Introduction
  518.         
  519.          QTAwk is called a Utility Creation Tool and  not  a  programming
  520.         language  because it is intended for the average computer user as
  521.         well as the more experienced user and programmer. QTAwk has  been
  522.         designed  to  make  it  easy for the average user to create those
  523.         small, or maybe not so  small,  utilities  needed  to  accomplish
  524.         small,  or  not  so  small, everyday jobs. The jobs which are too
  525.         small to justify the time  and  cost  of  using  the  traditional
  526.         computer  programming  language  and  maybe hiring a professional
  527.         programmer to accomplish.
  528.         
  529.          This paper presents a description of the QTAwk utility  creation
  530.         tool  and  its  use. Most computer users have many small tasks to
  531.         accomplish that are usually left undone for lack  of  the  proper
  532.         tool.  Typically  these tasks require finding one or more records
  533.         within a file and executing some action depending on  the  record
  534.         located.
  535.         
  536.          In  order  to accomplish these tasks the user needs a tool which
  537.         will allow the following to be accomplished easily:
  538.         
  539.         1.  reading files record by record,
  540.             
  541.         2.  spliting (parsing) the records read  into  words  or  fields,
  542.             
  543.         3.  determining    if   a   record,   or   records,   satisfy   a
  544.             pre-determined match  criteria,  i.e.  finding  the  "proper"
  545.             record(s),
  546.             
  547.         4.  when  the  proper records are found, executing some action or
  548.             actions on the records or fields of the records.
  549.         
  550.          QTAwk supplies the user with all of these features in an easy to
  551.         use manner. Specifying the name of a file is all the user need do
  552.         to open the file and read it  record  by  record.  The  user  may
  553.         easily  change  what  a "record" is or let it default to an ASCII
  554.         text line as used by all text editors and which can be written by
  555.         all  word  processors.  QTAwk  will  automatically  split (parse)
  556.         records into fields. Initially a field is a word or a sequence of
  557.         non-blank  characters.  The  user  may change the definition of a
  558.         field easily to adapt to the needs  of  a  particular  situation.
  559.         
  560.          Arithmetic   expressions,   logical   expressions   or   regular
  561.         expressions may be used to  define  the  criteria  for  selecting
  562.         records  for  action. Regular expressions are a powerful means of
  563.         describing the criteria for selecting, i.e matching, the text  of
  564.         records.  Arithmetic  expressions utilize the ordinary arithmetic
  565.  
  566.  
  567.         QTAwk                        - xi -                         QTAwk
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.         operators  (addition,  subtraction,  multiplication,  etc.)   for
  575.         describing   the  criteria  for  selecting  records  and  logical
  576.         expressions utilize the logical operators (less than,  equal  to,
  577.         greater than, etc.) for selecting records.
  578.         
  579.          Of  all the operators available in QTAwk, the regular expression
  580.         operators may be only ones most readers are  not  familiar  with.
  581.         Regular  expressions  are  a powerful and useful tool for working
  582.         with text. Yet for all their power, they are surprisingly  simple
  583.         and  easy  to  use  when  learned.  Chapter  Two explains regular
  584.         expressions fully, in a manner that will make them  usable  by  a
  585.         person totally unfamiliar with them.
  586.         
  587.          QTAwk  is patterned after The Awk Programming Language by Alfred
  588.         V. Aho, Brian W. Kernighan  and  Peter  J.  Weinberger.  The  Awk
  589.         program implementing The Awk Programming Language is available on
  590.         most Unix (tm) systems. Aho, Kernighan  and  Weinberger  invented
  591.         the  automatic  input  loop  and the pattern-action pairs used in
  592.         QTAwk and are to be heartily congratulated for this. Without Awk,
  593.         QTAwk would not exist. QTAwk is an extensive expansion of The Awk
  594.         Programming Language in many important aspects. In addition, some
  595.         of  the  admitted  shortcommings  of The Awk Programming Language
  596.         have been corrected.
  597.         
  598.          A short summary of the major differences between QTAwk  and  Awk
  599.         is  given  below. Appendix II contains a more detailed listing of
  600.         the differences.
  601.         
  602.         1.  Expanded set of regular expression operators,
  603.         2.  Use of "named expression"s in regular expressions to simplify
  604.             construction of complicated regular expressions,
  605.         3.  Expanded arithmetic operator set,
  606.         4.  Expanded  set  of pre-defined patterns giving more control in
  607.             the sequence of utility execution,
  608.         5.  True multi-dimensional arrays
  609.         6.  Integration  of  the  multi-dimensional   arrays   with   the
  610.             arithmetic operators allowing the assignment of and operation
  611.             on entire arrays.
  612.         7.  Integration of the multi-dimensional arrays with user-defined
  613.             functions  allowing  the  use  of  arrays  in  functions in a
  614.             natural and intuitive manner,
  615.         8.  Expanded  set   of   keywords   allowing   local   variables,
  616.             'switch'/'case'  flow  control,  and premature closure of the
  617.             current input file,
  618.         9.  Expanded set of arithmetic and string built-in  functions,  a
  619.             new array function, and new variable access functions,
  620.         10.  Corrected input function syntax,
  621.         11.  Added new Input/Output functions,
  622.  
  623.  
  624.         QTAwk                        - xii -                        QTAwk
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.         12.  Expanded formatted I/O capability,
  632.         13.  Expanded  user-defined functions allowing variable number of
  633.             arguments,
  634.         14.  New user  controlled  utility  execution  trace  capability,
  635.         15.  Expanded  list of built-in variables giving more control and
  636.             access to QTAwk utility execution.
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.         QTAwk                       - xiii -                        QTAwk
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.         QTAwk                       - 0-16 -                        QTAwk
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.         Section 1.0                                              Tutorial
  747.  
  748.  
  749.         E-1.0 TUTORIALF-Ç
  750.         
  751.         E1.1 DataF
  752.         
  753.          QTAwk is designed to be used to search data or text files  using
  754.         short  user  created  utilities. The types of files that QTAwk is
  755.         designed to work with are "text"  files,  commonly  called  ASCII
  756.         files. The files contain user readable text and numbers. The text
  757.         is contained in lines and the  lines  end  with  carriage-return,
  758.         new-line  character  pairs  or  single  new-line characters. Text
  759.         files are written by application programs and word processors and
  760.         text editors.
  761.         
  762.          The  information  in  the files is grouped by fields on a single
  763.         line or by  lines  separated  by  a  blank  line  or  some  other
  764.         "special"  characters.  For  example,  the  following  lines list
  765.         information on various states:
  766.         
  767.         US # 10461 # 4375 # MD # Annapolis ( Maryland )
  768.         US # 40763 # 5630 # VA # Richmond ( Virgina )
  769.         US # 2045 # 620 # DE # Dover ( Delaware )
  770.         US # 24236 # 1995 # WV # Charleston ( West Virginia )
  771.         US # 46047 # 12025 # PA # Harrisburg ( Pennsylvania )
  772.         US # 7787 # 7555 # NJ # Trenton ( New Jersey )
  773.         US # 52737 # 17895 # NY # Albany ( New York )
  774.         US # 9614 # 535 # VT # Montpelier ( Vermont )
  775.         US # 9278 # 975 # NH # Concord ( New Hampshire )
  776.         US # 33265 # 1165 # ME # Augusta ( Maine )
  777.         
  778.          Each line, or record in QTAwk, consists  of  12  words.  The  12
  779.         words of the first record are:
  780.         
  781.         1: US
  782.         2: #
  783.         3: 10461
  784.         4: #
  785.         5: 4375
  786.         6: #
  787.         7: MD
  788.         8: #
  789.         9: Annapolis
  790.         10: (
  791.         11: Maryland
  792.         12: )
  793.         
  794.          The first word lists the country, the third word lists the state
  795.  
  796.  
  797.         QTAwk                        - 1-1 -                        QTAwk
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.         Section 1.1                                              Tutorial
  805.  
  806.  
  807.         area in square miles, the fifth word lists the  state  population
  808.         in  thousands. the seventh word lists the state abbreviation, the
  809.         nineth word lists the state capital, and the eleventh word  lists
  810.         the state name. The second, fourth, sixth, eighth, tenth and last
  811.         words are word separators. The word separators are not  necessary
  812.         for  QTAwk,  but make each line easier for people to read. A copy
  813.         of this entire file, states.dta, is given in Appendix IV.
  814.         
  815.          This information could be manipulated in various ways. A few  of
  816.         the ways in which this could be done are:
  817.         1.  the manner of listing changed, or
  818.         2.  only lines meeting certain criteria listed:
  819.             a)  those states with a minimum area,
  820.             b)  those states with a minimum population,
  821.             c)  population  greater  than  a  minimum  and  less  than  a
  822.                 maximum,
  823.             d)  area less than a maximum and population  greater  than  a
  824.                 minimum,
  825.             e)  population  density  (population  /  area)  less  than  a
  826.                 maximum.
  827.         3.  the list could be sorted
  828.             a)  alphabetically by
  829.                 1:  state capital,
  830.                 2:  state name,
  831.                 3:  state abbreviation.
  832.             b)  by area,
  833.             c)  by population.
  834.         4.  some Information could be deleted from the list such  as  the
  835.             capital.
  836.         
  837.          There are many more ways to manipulate the information. In order
  838.         to do so the information in the list must first be read record by
  839.         record and each record split into its constituent parts. Once the
  840.         parts for each record have been determined, the  information  can
  841.         be easily manipulated, changed, or rearranged.
  842.         
  843.         E1.2 Running QTAwkF
  844.         
  845.          QTAwk  is  started from the DOS command prompt, giving the QTAwk
  846.         utility to run and the files to search. The QTAwk utility may  be
  847.         written  directly on the command line or contained in one or more
  848.         files named on the command line. If given on the command line, it
  849.         is usually enclosed in double quotes:
  850.         
  851.         QTAwk "$5 > 50000 {print;}" states.dta
  852.         
  853.  
  854.  
  855.         QTAwk                        - 1-2 -                        QTAwk
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.         Section 1.2                                              Tutorial
  863.  
  864.  
  865.          This  QTAwk  utility  will  print the record for every state for
  866.         which the area is greater than 50,000 square miles.
  867.         
  868.          The example shows the form of QTAwk  utilities,  a  sequence  of
  869.         patterns and actions in the form:
  870.         
  871.         pattern1 { action1 }
  872.         pattern2 { action2 }
  873.         pattern3 { action3 }
  874.         .
  875.         .
  876.         .
  877.         
  878.          QTAwk opens the files named on the command line, reads a record,
  879.         splits (parses) each record into the individual words  or  fields
  880.         and  compares  the record with each pattern in the order in which
  881.         they have been written  in  the  QTAwk  utility.  If  the  record
  882.         matches  a  pattern, the corresponding action contained in braces
  883.         is executed.
  884.         
  885.          Patterns may be  arithmetic  expressions,  logical  expressions,
  886.         regular  expressions  or  combinations  of  all  three  types  of
  887.         expressions. The example above has a logical expression  pattern.
  888.         
  889.          Under  DOS,  programs  indicate  the  end of text lines in ASCII
  890.         files with a  Carriage  Return,  Newline  character  pair.  QTAwk
  891.         follows  the  practice  of  converting all such pairs to a single
  892.         newline when reading the file. In writing files,  QTAwk  converts
  893.         single  Newline  characters  to  a Carriage Return, Newline pair.
  894.         
  895.          For the data in the "states" data file, a question that  may  be
  896.         asked  is  the total population of Canada. The first field can be
  897.         used to identify the data for Canada and the fifth field contains
  898.         population  data.  The  following utility will sum the population
  899.         data for Canada:
  900.         
  901.         $1 == "Canada" { Total += $5 }
  902.         END { print Total; }
  903.         
  904.          In this example, when the first field of a record  is  equal  to
  905.         "Canada", the fifth field is accumulated into the variable Total.
  906.         When all records have  been  processed,  Total  is  printed.  The
  907.         printing  of  Total is accomplished in the action associated with
  908.         the pattern 'END'. 'END' is a pre-defined pattern, the associated
  909.         action is executed after closing the input file.
  910.         
  911.  
  912.  
  913.         QTAwk                        - 1-3 -                        QTAwk
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.         Section 1.2                                              Tutorial
  921.  
  922.  
  923.          The  remaining  chapters  explain  QTAwk  expressions, patterns,
  924.         action statements and more. All of  these  are  combined  into  a
  925.         QTAwk  utility.  In  using and creating QTAwk utilities, the user
  926.         needs to remember  the  fundamental  QTAwk  processing  sequence:
  927.         
  928.         1.  QTAwk  opens  each  input  file  and reads the file record by
  929.             record,
  930.         2.  as each record is read, it is split into fields,
  931.         3.  the record is then compared against the patterns for matches,
  932.         4.  When  a  match  is  found, the associated action is executed.
  933.         
  934.          Keeping this fundamental loop in mind will make using QTAwk very
  935.         simple indeed.
  936.         
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.         QTAwk                        - 1-4 -                        QTAwk
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.         Section 2.0                                    Regular Expression
  979.  
  980.  
  981.         E-2.0 REGULAR EXPRESSIONSF-Ç
  982.         
  983.          Regular  expressions  are  a  means  of  describing sequences of
  984.         "characters". In the discussion of  QTAwk,  "character"  will  be
  985.         taken  to  mean any character from the extended ASCII sequence of
  986.         characters from ASCII '1' to ASCII '255'. Appendix I  contains  a
  987.         listing  of  the  ASCII  characters  with  both their decimal and
  988.         hexadecimal equivalent.
  989.         
  990.          A string is a finite sequence of characters.  The  length  of  a
  991.         string  is  the  number  of characters contained in the string. A
  992.         special string is the empty string, also called the null  string,
  993.         which  is  of  zero  length,  i.e., it contains no characters. We
  994.         shall use the symbol 'ε' below  to  refer  to  the  null  string.
  995.         
  996.          Another  way  to  think of a string is as the concatenation of a
  997.         sequence of characters. Two strings may be concatenated  to  form
  998.         another string. Concatenating the two strings:
  999.         
  1000.                                     "abcdef"                             
  1001.         
  1002.          and
  1003.         
  1004.                                    "ghijklmn"                            
  1005.         
  1006.          forms the third string:
  1007.         
  1008.                                 "abcdefghijklmn"                         
  1009.         
  1010.          In  many  instances,  it  is desirable to describe a string with
  1011.         several alternatives for one or more of the characters.  Thus  we
  1012.         may wish to find the strings:
  1013.         
  1014.                                       FRED                               
  1015.         
  1016.          or
  1017.         
  1018.                                        TED                               
  1019.         
  1020.          A  convenient  manner  of  describing both strings with the same
  1021.         regular expression is
  1022.         
  1023.                                    /(FR|T)ED/                            
  1024.         
  1025.          Strings in QTAwk are enclosed in double quotes, ",  and  regular
  1026.         expressions are enclosed in slashes, '/'.
  1027.  
  1028.  
  1029.         QTAwk                        - 2-1 -                        QTAwk
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.         Section 2.1                                    Regular Expression
  1037.  
  1038.  
  1039.         E2.1 'OR' OperatorF
  1040.         
  1041.          The  symbol  '|'  means "or" and so the above regular expression
  1042.         would be read as: The string "FR" or the string "T"  concatenated
  1043.         with  the  string "ED". The parenthesis are used to group strings
  1044.         into equivalent positions in the resultant regular expression. In
  1045.         this  manner  it  is  possible  to build a regular expression for
  1046.         several alternative strings.
  1047.         
  1048.          In  many  instances  it  is  also  desirable  to  build  regular
  1049.         expressions  that  contain  many  alternatives for one character,
  1050.         i.e., one character strings. For example, we may want to find all
  1051.         instances  of  the  words  "doing" or "going". We could build the
  1052.         regular expression:
  1053.         
  1054.                                    /(d|g)oing/                           
  1055.         
  1056.         E2.2 Character ClassesF
  1057.         
  1058.          Although the last regular expression is a fairly simple example,
  1059.         it  serves  to  introduce  the notion of "character class". If we
  1060.         define the notation:
  1061.         
  1062.                                   [dg] = (d|e)                           
  1063.         
  1064.          then we may write the regular expression as:
  1065.         
  1066.                                    /[dg]oing/                            
  1067.         
  1068.          The character class notation saves us from having to  explicitly
  1069.         write  the  "or"  symbols  in the regular expression. The "or" is
  1070.         implied between each character of the class.
  1071.         
  1072.          Now suppose that we wanted to expand  our  search  to  all  five
  1073.         letter  words  ending  in  "ing" and starting with any lower-case
  1074.         letter and having any lower-case letter as the second  character.
  1075.         We would write the regular expression:
  1076.         
  1077.                    /(a|b|c|d|...|x|y|z)(a|b|c|d|...|x|y|z)ing/           
  1078.         
  1079.          or
  1080.         
  1081.                           /[abcd...xyz][abcd...xyz]ing/                  
  1082.         
  1083.          Regular  expressions  in these cases can not only get very long,
  1084.         but can be very tedious to write and are very prone to error.  We
  1085.  
  1086.  
  1087.         QTAwk                        - 2-2 -                        QTAwk
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.         Section 2.2                                    Regular Expression
  1095.  
  1096.  
  1097.         introduce  the notion of a range of characters into the character
  1098.         class and define:
  1099.         
  1100.                    [a-z] = [abcd...xyz] = (a|b|c|d|...|x|y|z)            
  1101.         
  1102.          The above regular expression can now be written:
  1103.         
  1104.                                  /[a-z][a-z]ing/                         
  1105.         
  1106.          a considerable savings and less error prone. The hyphen, '-', is
  1107.         recognized  as  expressing  a  range  of  characters only when it
  1108.         occurs within a character class. Within  character  classes,  the
  1109.         hyphen  loses  this  significance  in  the following three cases:
  1110.         
  1111.         1.  when it is the first character of the character class,  e.g.,
  1112.             
  1113.                                     [-b] = (-|b)                         
  1114.             
  1115.         2.  when  it  is the last character of the character class, e.g.,
  1116.             
  1117.                                     [b-] = (b|-)                         
  1118.             
  1119.         3.  when the first character of the indicated  range  is  greater
  1120.             in  the ASCII collating sequence than the second character of
  1121.             the indicated range, e.g.,
  1122.             
  1123.                                         [z-a]                            
  1124.             
  1125.              would be recognized as:
  1126.             
  1127.                                        (z|-|a)                           
  1128.         
  1129.          In interpreting the range notation in character  classes,  QTAwk
  1130.         uses the ASCII collating sequence.
  1131.         
  1132.                                       [0-Z]                              
  1133.         
  1134.          is equivalent to:
  1135.         
  1136.                              [0123456789:;<=>?@A-Z]                      
  1137.         
  1138.          Continuing  the  last  example,  if we did not want to limit the
  1139.         first character to lower-case, but also  wanted  to  include  the
  1140.         possibility  of  upper-case  letters,  we could use the following
  1141.         regular expression:
  1142.         
  1143.  
  1144.  
  1145.         QTAwk                        - 2-3 -                        QTAwk
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.         Section 2.2                                    Regular Expression
  1153.  
  1154.  
  1155.                              /([A-Z]|[a-z])[a-z]ing/                     
  1156.         
  1157.          This regular expression  allows  the  first  letter  to  be  any
  1158.         character  in  the range from A to Z or in the range from a to z.
  1159.         But the "or" is implied  in  character  classes,  shortening  the
  1160.         above regular expression to:
  1161.         
  1162.                                /[A-Za-z][a-z]ing/                        
  1163.         
  1164.          If  we  now  wish to expand the above from all five letter words
  1165.         ending in "ing" to all six letter words ending in "ing", we could
  1166.         write the regular expression as:
  1167.         
  1168.                              /[A-Za-z][a-z][a-z]ing/                     
  1169.         
  1170.          In  general,  if  we  did  not  want  to  specify  the number of
  1171.         characters between the first letter  and  the  "ing"  ending,  we
  1172.         could specify an regular expression as:
  1173.         
  1174.                    /[A-Za-z](ε|[a-z])(ε|[a-z])...(ε|[a-z])ing/           
  1175.         
  1176.          By  specifying  the  null string in the 'or' regular expression,
  1177.         the regular expression allows a character in the range a to z  or
  1178.         no  character  to  match.  The  shortest  string  matched by this
  1179.         regular expression would be a single upper or lower  case  letter
  1180.         followed  by  "ing".  The regular expression would also match any
  1181.         string starting with an upper  or  lower  case  letter  with  any
  1182.         number  of  lower  case  letters  following  and ending in "ing".
  1183.         
  1184.         E2.3 ClosureF
  1185.         
  1186.          What we need to describe this regular expression is  a  notation
  1187.         for  specifying  "zero  or more" copies of a character or string.
  1188.         Such a notation exists and is written as:
  1189.         
  1190.                                /[A-Za-z][a-z]*ing/                       
  1191.         
  1192.          where the notation
  1193.         
  1194.                                      [a-z]*                              
  1195.         
  1196.          means zero or more occurrences of  the  character  class  [a-z].
  1197.         This  operation  is  called  closure  and  the  '*' is called the
  1198.         closure operator. In general, the notation may be  used  for  any
  1199.         regular expression within a regular expression. The following are
  1200.         valid regular expressions  using  the  notion  of  zero  or  more
  1201.  
  1202.  
  1203.         QTAwk                        - 2-4 -                        QTAwk
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.         Section 2.3                                    Regular Expression
  1211.  
  1212.  
  1213.         occurrences  of  an  regular  expression  within  another regular
  1214.         expression:
  1215.         
  1216.                                     /mis*ion/                            
  1217.         
  1218.          would   match   "miion",   "mision",   "mission",    "misssion",
  1219.         "missssion", etc.
  1220.         
  1221.                                     /bot*om/                             
  1222.         
  1223.          would  match  "boom",  "botom",  "bottom", "botttom", "bottttom,
  1224.         etc.
  1225.         
  1226.                                    /(Fr|T)*ed/                           
  1227.         
  1228.          would match "ed", "Fred", "Ted", "FrFred",  "TTed",  "FrFrFred",
  1229.         "TTTed", "FrTFred", "FrFrTed", "TFrFred", etc.
  1230.         
  1231.          As an extension to the '*' operator, we frequently would want to
  1232.         search for one or more occurrences of a  regular  expression.  As
  1233.         above we would write this as:
  1234.         
  1235.                             /[A-Za-z][a-z][a-z]*ing/                     
  1236.         
  1237.          The  [a-z][a-z]* construct would ensure that at least one letter
  1238.         occurred between the initial letter and the  string  "ing".  This
  1239.         occurs often enough that the notation
  1240.         
  1241.                               [a-z]+ = [a-z][a-z]*                       
  1242.         
  1243.          has been adopted to handle this situation. Thus use the operator
  1244.         '*' for zero or more occurrences and the operator '+' for one  or
  1245.         more occurrences. The '+' operator is called the positive closure
  1246.         operator.
  1247.         
  1248.          In many cases it is desirable to search for either zero  or  one
  1249.         regular  expression. For example, it would be desirable to search
  1250.         for names preceded by either Mr or Mrs  The  regular  expression:
  1251.         
  1252.                                      /Mrs*/                              
  1253.         
  1254.          would  find:  Mr  and Mrs and Mrss and Mrsss, etc. The following
  1255.         regular expression will accomplish what we really  want  in  this
  1256.         case:
  1257.         
  1258.                                     /Mr(ε|s)/                            
  1259.  
  1260.  
  1261.         QTAwk                        - 2-5 -                        QTAwk
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.         Section 2.3                                    Regular Expression
  1269.  
  1270.  
  1271.          This  regular expression would find 'Mr' followed by zero or one
  1272.         's'.
  1273.         
  1274.          The operator '?' has been selected to denote 'zero  or  one'  of
  1275.         the preceding regular expression. Thus,
  1276.         
  1277.                                /Mrs?/ = /Mr(ε|s)/                        
  1278.         
  1279.         E2.4 Repetition OperatorF
  1280.         
  1281.          In  some  cases  we wish to specify a minimum and maximum repeat
  1282.         count for a regular  expression.  For  example,  suppose  it  was
  1283.         desirable  for a regular expression to contain a minimum of 2 and
  1284.         a maximum of 4 copies of "abc". We could specify this as:
  1285.         
  1286.                               /abcabc(abc)?(abc)?/                       
  1287.         
  1288.          The notation {2,4} has been adopted  for  expressing  this.  The
  1289.         general form of the repetition operator is {n1,n2}. n1 and n2 are
  1290.         integers, with n1 greater than or equal to 1 and n2 greater  than
  1291.         or  equal  to  n1,  1  <=  n1  <= n2. A repetition count would be
  1292.         specified as:
  1293.         
  1294.         /r{n1,n2}/ = /rrrrrrrrrrrrrr?r?r?r?r?r?/
  1295.                   │<─── n1 ───>│         │
  1296.                   │<──────── n2 ────────>│
  1297.         
  1298.          The above could be expressed as:
  1299.         
  1300.                      /(abc){2,4}/ = /(abc)(abc)(abc)?(abc)?/             
  1301.         
  1302.          Since the repetition operator repeats the immediately  preceding
  1303.         regular expression, the parenthesis around "abc" are necessary to
  1304.         repeat the whole string.  Without  the  parenthesis  the  regular
  1305.         expression would expand as:
  1306.         
  1307.                              /abc{2,4}/ = /abccc?c?/                     
  1308.         
  1309.          The  repetition  operator  can  be  used to repeat either single
  1310.         characters, groups of characters,  character  classes  or  quoted
  1311.         strings.  The  use  of the operator is illustrated below for each
  1312.         case:
  1313.         
  1314.         1.  Single characters:
  1315.             
  1316.                                /abc{2,4}/ = /abccc?c?/                   
  1317.  
  1318.  
  1319.         QTAwk                        - 2-6 -                        QTAwk
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.         Section 2.4                                    Regular Expression
  1327.  
  1328.  
  1329.         2.  Groups of regular expressions:
  1330.             
  1331.                        /(abc){2,4}/ = /(abc)(abc)(abc)?(abc)?/           
  1332.             
  1333.         3.  character classes:
  1334.             
  1335.                        /[abc]{2,4}/ = /[abc][abc][abc]?[abc]?/           
  1336.             
  1337.         4.  quoted string:
  1338.             
  1339.                         /"abc"{2,4}/ = /"abcabc(abc)?(abc)?"/            
  1340.             
  1341.              For quoted strings, the whole of the string contained within
  1342.             quotes  is  repeated,  with all repetitions maintained within
  1343.             the quotes.
  1344.             
  1345.         5.  named expressions (described later):
  1346.             
  1347.                       /{abc}{2,4}/ = /{abc}{abc}{abc}?{abc}?"/           
  1348.         
  1349.          A special case exists for character classes in which  the  class
  1350.         of  characters to exclude is greater than the class of characters
  1351.         to include. For example, suppose that  we  wanted  in  a  certain
  1352.         character   position  to  include  all  characters  that  weren't
  1353.         numerics. We could build a character class of all characters  and
  1354.         leave   the  numerics  out.  An  easier  method  is  to  use  the
  1355.         "complemented" or "negated" character class. A  special  operator
  1356.         has  been  introduced  for  this purpose. The logical NOT symbol,
  1357.         '!', occurring as the  first  character  in  a  character  class,
  1358.         negates  the  class,  i.e.,  any  character  NOT  in the class is
  1359.         recognized at the character position.
  1360.         
  1361.          Thus, to define the negated character class  of  all  characters
  1362.         which are not numerics, we would specify:
  1363.         
  1364.                                      [!0-9]                              
  1365.         
  1366.          To  define  all  characters  except  the  semi-colon,  we  would
  1367.         specify:
  1368.         
  1369.                                       [!;]                               
  1370.         
  1371.          Note that the symbol '!' has this special meaning  only  as  the
  1372.         FIRST  character  in a character class. The caret symbol, '^', as
  1373.         the FIRST character in a character class  may  also  be  used  to
  1374.         negate  a character class. Traditionally, the caret been used for
  1375.  
  1376.  
  1377.         QTAwk                        - 2-7 -                        QTAwk
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.         Section 2.4                                    Regular Expression
  1385.  
  1386.  
  1387.         this purpose, but QTAwk allows  the  logical  NOT  operator,  '!'
  1388.         also.
  1389.         
  1390.          Utilizing the above concepts for building regular expressions by
  1391.         concatenating characters, concatenating  regular  expressions  to
  1392.         build  more complicated regular expressions, using parenthesis to
  1393.         nest  regular  expressions  within  regular  expressions,   using
  1394.         character  classes to denote constructs with implied "or"s, using
  1395.         the closure operators, '*',  '+'  and  '?',  and  the  repetition
  1396.         operator,   {n1,n2},   for   expressing   multiple  copies,  very
  1397.         complicated regular expressions may be built  for  searching  for
  1398.         strings in files.
  1399.         
  1400.         E2.5 Escape SequencesF
  1401.         
  1402.          To  round  out  the ability for building regular expressions for
  1403.         searching, we need only a few more tools. In some  cases  we  may
  1404.         wish  for  the  regular  expression  to  contain  blanks  or  tab
  1405.         characters. In addition, other non-printable  characters  may  be
  1406.         included  in  regular  expressions.  These characters are defined
  1407.         with  "escape  sequences".  Escape  sequences  are  two  or  more
  1408.         characters used to denote a single character. The first character
  1409.         is  always  the  backslash,  '\'.  The  second  character  is  by
  1410.         convention a letter as follows:
  1411.         
  1412.         \a   == bell (alert)           ( \x07 )                          
  1413.         \b   == backspace              ( \x08 )                          
  1414.         \f   == formfeed               ( \x0c )                          
  1415.         \n   == newline                ( \x0a )                          
  1416.         \r   == carriage return        ( \x0d )                          
  1417.         \s   == space                  ( \x20 )                          
  1418.         \t   == horizontal tab         ( \x09 )                          
  1419.         \v   == vertical tab           ( \x0b )                          
  1420.         \c   == c [ \\ == \ ]                                            
  1421.         \ooo == character represented by octal value ooo                 
  1422.                 1 to 3 octal digits acceptable                           
  1423.         \xhhh== character represented by hexadecimal value hhh           
  1424.                 1 to 3 hexadecimal digits acceptable                     
  1425.         
  1426.          Any  other  character  following  the backslash is translated to
  1427.         mean that character. Thus '\c' would become a  single  'c',  '\['
  1428.         would  become  '[',  etc.  The  latter  is  necessary in order to
  1429.         include such characters as '[', ']', '-',  '!',  '(',  ')',  '*',
  1430.         '+',  '?'  in  regular expressions without invoking their special
  1431.         meanings as regular expression operators.
  1432.         
  1433.  
  1434.  
  1435.         QTAwk                        - 2-8 -                        QTAwk
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.         Section 2.6                                    Regular Expression
  1443.  
  1444.  
  1445.         E2.6 Position OperatorsF
  1446.         
  1447.          Three additional special characters have,  by  convention,  been
  1448.         defined for use in writing regular expressions, namely the period
  1449.         '.', the caret, '^' and the dollar sign, '$'. The period has been
  1450.         assigned  to mean "any character" in the set of characters except
  1451.         the newline character, '\n'. For our use  the  period  means  any
  1452.         character from ASCII 1 to ASCII 9 inclusive and ASCII 11 to ASCII
  1453.         255 inclusive.
  1454.         
  1455.          The caret and the dollar sign are position  indicators  and  not
  1456.         character  indicators.  The  caret,  '^', is used to indicate the
  1457.         beginning or start of the  search  string.  Thus,  any  character
  1458.         following  the  caret  in  a regular expression must be the first
  1459.         character of the string to be searched otherwise the match fails.
  1460.         The  dollar sign , '$', is used to indicate the end of the search
  1461.         string. Thus, any  character  preceding  the  dollar  sign  in  a
  1462.         regular expression must be the last character of the string to be
  1463.         searched or the match fails.
  1464.         
  1465.          To indicate "beginning of line", the caret must be in the  first
  1466.         character   position  of  a  regular  expression.  Similarly,  to
  1467.         indicate "end of line", the dollar  sign  must  be  in  the  last
  1468.         character   position  of  a  regular  expression.  In  any  other
  1469.         position, these characters lose their special significance. Thus,
  1470.         the regular expression:
  1471.         
  1472.                                   /(^|[\s\t])A/                          
  1473.         
  1474.          means  that  'A'  must  be  the first character on a line, or be
  1475.         preceded by a space or tab character to match. Similarly
  1476.         
  1477.                                   /A($|[\s\t])/                          
  1478.         
  1479.          means that 'A' must be the  last  character  on  a  line  or  be
  1480.         followed by a space or tab character.
  1481.         
  1482.         E2.7 ExamplesF
  1483.         
  1484.          The regular expression:
  1485.         
  1486.                               /[A-Za-z][a-z]\s+.*/                       
  1487.         
  1488.          will   match  an  upper  or  lower-case  letter  followed  by  a
  1489.         lower-case letter followed by one or more blanks followed by  any
  1490.         character except a newline zero or more times.
  1491.  
  1492.  
  1493.         QTAwk                        - 2-9 -                        QTAwk
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.         Section 2.7                                    Regular Expression
  1501.  
  1502.  
  1503.          The regular expression:
  1504.         
  1505.                                /\([A-Z]+\)[!\s]+/                        
  1506.         
  1507.          will  match a left parenthesis followed by one or more uppercase
  1508.         letters followed by a right parenthesis followed by one  or  more
  1509.         characters which are not blanks.
  1510.         
  1511.          The regular expression:
  1512.         
  1513.                            /[\s\t]+ARCHIVE([\s\t]+|$)/                   
  1514.         
  1515.          will  match  a blank or tab followed by the word (in upper-case)
  1516.         "ARCHIVE" followed either by one or more blanks or tabs or by the
  1517.         end  of  line.  Note  this kind of construct is handy for finding
  1518.         words as independent units and not  buried  within  other  words.
  1519.         
  1520.          The regular expression:
  1521.         
  1522.                                   /([\s\t]+|$)/                          
  1523.         
  1524.          is  necessary to find words with trailing blanks or that end the
  1525.         search line. If only [\s\t]+ had been used then words ending  the
  1526.         search  line  would  not  be  found,  since there are no trailing
  1527.         blanks or tabs.
  1528.         
  1529.          Note that for files with the newline character, '\n', at the end
  1530.         of all lines, commonly called ASCII text files, it is possible to
  1531.         search for regular expressions that may span more than one  line.
  1532.         For  example,  if  we  wanted  to find all sequences of the names
  1533.         
  1534.                            Ted, Alice, George and Mary                   
  1535.         
  1536.          that were separated by spaces, tabs or line boundaries, we would
  1537.         write the following regular expression:
  1538.         
  1539.               /[\t-\r\s]+Ted[\t-\r\s]+Alice[\t-\r\s]+Mary[\t-\r\s]/      
  1540.         
  1541.          The regular expression:
  1542.         
  1543.                 /^As\s+(Fred|Ted|Jed|Ned)\s+(began|ended)(\s+|$)/        
  1544.         
  1545.          will  match  the  beginning of the search line followed by "As",
  1546.         i.e., 'A' as the first character of the search line, followed  by
  1547.         one  or more blanks followed by "Fred" or "Ted" or "Jed" or "Ned"
  1548.         followed by one or more blanks followed  by  "began"  or  "ended"
  1549.  
  1550.  
  1551.         QTAwk                       - 2-10 -                        QTAwk
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.         Section 2.7                                    Regular Expression
  1559.  
  1560.  
  1561.         followed  by  one  or  more blanks or the end of the search line.
  1562.         This could be modified slightly to be:
  1563.         
  1564.                    /^As\s+(Fr|T|J|N)ed\s+(began|ended)(\s+|$)/           
  1565.         
  1566.          or
  1567.         
  1568.                    /^As\s+(Fr|[TJN])ed\s+(began|ended)(\s+|$)/           
  1569.         
  1570.          either form will result in exactly the same search.
  1571.         
  1572.         E2.8 Look Ahead OperatorF
  1573.         
  1574.          Sometimes it is necessary to find a regular expression, but only
  1575.         when  it  is followed by another regular expression. Thus we wish
  1576.         to find "Mr", but only  when  it  is  followed  by  "Smith".  The
  1577.         "look-ahead"  operator, '@', is used to denote this situation. In
  1578.         general, if r is a regular expression we wish to match, but  only
  1579.         when  followed by the regular expression s, then we would express
  1580.         this as:
  1581.         
  1582.                                       /r@s/                              
  1583.         
  1584.          Thus, to find "Mr", but only when followed by "Smith", we  have:
  1585.         
  1586.                                 /Mr@[\s\t]+Smith/                        
  1587.         
  1588.         E2.9 Match ClassesF
  1589.         
  1590.          There  are  also circumstances in which we wish to find pairs of
  1591.         characters. For example, we wish to find all clauses in a  letter
  1592.         enclosed  within  parenthesis,  "()",  braces, "{}", or brackets,
  1593.         "[]". We could write several separate regular  expressions  which
  1594.         are  identical  except  that  one  would use parenthesis, another
  1595.         braces, etc. A simpler  method  has  been  introduced  using  the
  1596.         concept  of  matched character classes. A matched character class
  1597.         is denoted as:
  1598.         
  1599.                              [#\(\{\[] and [#\)\}\]]                     
  1600.         
  1601.          The first instance of a "matched character class" in  a  regular
  1602.         expression  will  match  any  character  in the class. The second
  1603.         instance will match only the character in  the  position  of  the
  1604.         class  matched  by  the first instance. For example, in the above
  1605.         two classes, if the character that matched the  first  class  was
  1606.         '[',  then  only a ']' would match the second class and not a ')'
  1607.  
  1608.  
  1609.         QTAwk                       - 2-11 -                        QTAwk
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.         Section 2.9                                    Regular Expression
  1617.  
  1618.  
  1619.         or a '}'. Note the use  of  the  backslash  above  to  avoid  any
  1620.         confusion  in interpreting the characters "()", "{}", and "[]" as
  1621.         characters and regular expression operators. Except for ']',  the
  1622.         backslash  is not needed since the characters do act as operators
  1623.         within a character class. For the character ']', the backslash is
  1624.         necessary  to  prevent  early termination of the character class.
  1625.         
  1626.          Note that matched character classes cannot be nested. Thus,  the
  1627.         span  of  characters  between  two  different  matched  character
  1628.         classes cannot overlap. If we wanted to find regular  expressions
  1629.         contained  within  "(["  and  ")]"  or  within "{[" and "}]", the
  1630.         instances of each in the regular expression  could  not  overlap,
  1631.         i.e., we could NOT write a regular expression like:
  1632.         
  1633.         this /[#\(\[] exp [#\{\[] contains [#\)\]] two [#\}\]] matched/
  1634.               │<────────────────────────────────>│         │
  1635.               │       │<────────────────────────────────>│
  1636.         
  1637.          This regular expression would be interpreted as:
  1638.         
  1639.         /this [#\(\[] exp [#\{\[] contains [#\)\]] two [#\}\]] matched/
  1640.               │<───────────────>│       │<───────────────>│
  1641.         
  1642.         E2.10 Named ExpressionsF
  1643.         
  1644.          If  the  strings  to  be  found  using  regular  expressions are
  1645.         complicated, the associated regular expressions can  become  very
  1646.         difficult  to understand. This makes it very hard to determine if
  1647.         the regular expression  is  correct.  For  example,  the  regular
  1648.         expression (as one line):
  1649.         
  1650.            /^[A-Za-z_][A-Za-z0-9_]*([\s\t]+\**[A-Za-z_][A-Za-z0-9_]*)*   
  1651.         \((([\s\t]*[\*&]*[A-Za-z_][A-Za-z0-9_]*[\s\t]*)(,([\s\t]*
  1652.         [\*&]*[A-Za-z_][A-Za-z0-9_]*[\s\t]*))*)*\)([\s\t]*
  1653.         (\/\*.*\*\/)[\s\t]*)*$/
  1654.         
  1655.          will   find   function   definitions  in  C  language  programs.
  1656.         Constructing and analysing this regular expression  as  a  single
  1657.         entity, is difficult.
  1658.         
  1659.          Breaking  such regular expressions into smaller units, which are
  1660.         shorter and simpler,  makes  the  task  much  easier.  QTAwk  has
  1661.         introduced  the  concept of "named expressions" for this purpose.
  1662.         Named expressions are QTAwk variable names  enclosed  in  braces,
  1663.         '{' '}'. In translating the regular expression into internal form
  1664.         QTAwk, scans the regular expression  for  named  expressions  and
  1665.  
  1666.  
  1667.         QTAwk                       - 2-12 -                        QTAwk
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.         Section 2.10                                   Regular Expression
  1675.  
  1676.  
  1677.         substitutes  the  current  value  of  the  variable  named.  If a
  1678.         variable does not exist by the name specified, no substitution is
  1679.         made.
  1680.         
  1681.          By defining a variable:
  1682.         
  1683.                               fst = "first words";                       
  1684.         
  1685.          Then the following regular expression:
  1686.         
  1687.                             /The {fst} of the child/                     
  1688.         
  1689.          would expand into:
  1690.         
  1691.                          /The first words of the child/                  
  1692.         
  1693.          Named expressions allow for building up regular expressions from
  1694.         smaller  more  easily  understood  regular  expressions  and  for
  1695.         re-using  the  smaller regular expressions. The following example
  1696.         QTAwk  utility  builds  the  previous  regular   expression   for
  1697.         recognizing  C  language  function  definitions (all on one line)
  1698.         from many smaller regular expressions. Each  constituent  regular
  1699.         expression  is  built  to  recognize  a  particular  part  of the
  1700.         function  definition.  When  combined  into  the  final   regular
  1701.         expression,  the  three  parts  of  the  definition can be easily
  1702.         understood. The final regular expression is expanded in the final
  1703.         print  statement. It spans several 80 character lines and is much
  1704.         more difficult to understand due to its  length  and  complexity.
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.         QTAwk                       - 2-13 -                        QTAwk
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.         Section 2.10                                   Regular Expression
  1733.  
  1734.  
  1735.         Example:
  1736.         BEGIN {
  1737.         # define variables for use in regular expressions:
  1738.         # Define C name expression
  1739.              c_n = /[A-Za-z_][A-Za-z0-9_]*/;
  1740.         # Define C comment expression
  1741.         # Note: Does NOT allow comment to span lines
  1742.              c_c = /(\/\*.*\*\/)/;
  1743.         # Define single line comment
  1744.              c_slc = /({_w}*{c_c}{_w}*)*/;
  1745.         # Define C name with pointer
  1746.              c_np = /\**{c_n}/;
  1747.         # Define C name with pointer or address
  1748.              c_ni = /[\*&]*{c_n}/;
  1749.         # Define C function type and name declaration
  1750.              c_fname = /{c_n}({_w}+{c_np})*/;
  1751.         # Define expression for first argument in function list
  1752.              c_first_arg = /({_w}*{c_ni})/;
  1753.         #  Define  expression  for  remaining  argument  in function list
  1754.              c_rem_arg = /({_w}*,{c_first_arg})*/;
  1755.         # Define C function argument list
  1756.              c_arg_list = /\(({c_first_arg}{c_rem_arg})*\)/;
  1757.         #
  1758.         # Expression to find all C function definitions
  1759.              totl_name = /^{c_fname}{c_arg_list}{c_slc}$/;
  1760.         #
  1761.         # print total expression to illustrate expansion of named
  1762.         # expressions
  1763.         # Refer to the description of the 'replace' function
  1764.         #
  1765.              print replace(totl_name);
  1766.         }
  1767.         
  1768.          The string output by this utility is:
  1769.         
  1770.            ^[A-Za-z_][A-Za-z0-9_]*([\s\t]+\**[A-Za-z_][A-Za-z0-9_]*)*    
  1771.         \((([\s\t]*[\*&]*[A-Za-z_][A-Za-z0-9_]*[\s\t]*)(,([\s\t]*
  1772.         [\*&]*[A-Za-z_][A-Za-z0-9_]*[\s\t]*))*)*\)([\s\t]*
  1773.         (\/\*.*\*\/)[\s\t]*)*$
  1774.         
  1775.          Note that in printing the regular expression,  the  leading  and
  1776.         trailing slash, '/', were not printed.
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.         QTAwk                       - 2-14 -                        QTAwk
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.         Section 2.11                                   Regular Expression
  1791.  
  1792.  
  1793.         E2.11 Predefined NamesF
  1794.         
  1795.          In  translating  regular  expressions,  names  starting  with an
  1796.         underscore and followed by a single upper or  lower  case  letter
  1797.         are  reserved  as  predefined. The following predefined names are
  1798.         currently available for use in named expressions:
  1799.         
  1800.               Alphabetic                                                 
  1801.         {_a}  ==  [A-Za-z]                                               
  1802.               Brackets                                                   
  1803.         {_b}  ==  [{}()[]<>]                                             
  1804.               Control Character                                          
  1805.         {_c}  ==  [\x001-\x01f\x07f]                                     
  1806.               Digit                                                      
  1807.         {_d}  ==  [0-9]                                                  
  1808.               Exponent                                                   
  1809.         {_e}  ==  [DdEe][-+]?{_d}{1,3}                                   
  1810.               Floating point number                                      
  1811.         {_f}  ==  [-+]?({_d}+\.{_d}*|{_d}*\.{_d}+)                       
  1812.               Floating, optional exponent                                
  1813.         {_g}  ==  {_f}({_e})?                                            
  1814.               Hexadecimal digit                                          
  1815.         {_h}  ==  [0-9A-Fa-f]                                            
  1816.               Integer                                                    
  1817.         {_i}  ==  [-+]?{_d}+                                             
  1818.               alpha-Numeric                                              
  1819.         {_n}  ==  [A-Za-z0-9]                                            
  1820.               Octal digit                                                
  1821.         {_o}  ==  [0-7]                                                  
  1822.               Punctuation                                                
  1823.         {_p}  ==  [\!-/:-@[-`{-\x07f]                                    
  1824.               double or single Quote                                     
  1825.         {_q}  ==  {_s}["'`]                                              
  1826.               Real number                                                
  1827.         {_r}  ==  {_f}{_e}                                               
  1828.               zero or even number of Slashes                             
  1829.         {_s}  ==  (^|[!\\](\\\\)*)                                       
  1830.               printable character                                        
  1831.         {_t}  ==  [\s-~]                                                 
  1832.               graphical character                                        
  1833.         {_u}  ==  [\x01f-~]                                              
  1834.               White space                                                
  1835.         {_w}  ==  [\s\t]                                                 
  1836.               space, \t, \n, \v, \f, \r, \s                              
  1837.         {_z}  ==  [\t-\r\s]                                              
  1838.         
  1839.  
  1840.  
  1841.         QTAwk                       - 2-15 -                        QTAwk
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.         Section 2.11                                   Regular Expression
  1849.  
  1850.  
  1851.          The  above  predefined  names  will  take  precedence  over  any
  1852.         variables  with identical names in replacing named expressions in
  1853.         regular expressions and the 'replace' function.
  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.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.         QTAwk                       - 2-16 -                        QTAwk
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.         Section 2.12                                   Regular Expression
  1907.  
  1908.  
  1909.         E2.12 Operator SummaryF
  1910.         
  1911.          The QTAwk regular expression  operators  are  summarized  below:
  1912.         
  1913.         ^ matches Beginning of Line
  1914.         $  matches  End  of  Line as last character of regular expression
  1915.         \c matches following (hexadecimal value  shown  in  parenthesis):
  1916.             \a   == bell (alert)           ( \x07 )                      
  1917.             \b   == backspace              ( \x08 )                      
  1918.             \f   == formfeed               ( \x0c )                      
  1919.             \n   == newline                ( \x0a )                      
  1920.             \r   == carriage return        ( \x0d )                      
  1921.             \s   == space                  ( \x20 )                      
  1922.             \t   == horizontal tab         ( \x09 )                      
  1923.             \v   == vertical tab           ( \x0b )                      
  1924.             \c   == c [ \\ == \ ]                                        
  1925.             \ooo == character represented by octal value ooo             
  1926.                     1 to 3 octal digits acceptable                       
  1927.             \xhhh== character represented by hexadecimal value hhh       
  1928.                     1 to 3 hexadecimal digits acceptable                 
  1929.             
  1930.         . matches any character except newline, '\n'
  1931.         [abc0-9] Character Class - match any character in class
  1932.         [^abc0-9]  Negated  Character  Class - match any character not in
  1933.             class
  1934.         [!abc0-9] Negated Character Class - match any  character  not  in
  1935.             class
  1936.         [#abc0-9]  Matched  Character  Class  -  for  second match, class
  1937.             character must match in corresponding position
  1938.         * - Closure, Zero or more matches
  1939.         + - Positive Closure, One or More matches
  1940.         ? - Zero or One matches
  1941.         r(s)t embedded regular expression s
  1942.         r|s|t '|' == logical 'or' operator. Regular expression r or s  or
  1943.             t
  1944.         @  -  Look-Ahead, r@t, matches regular expression 'r' only when r
  1945.             is followed by regular expression 't'. Regular  expression  t
  1946.             not  contained  in  final match. Symbol loses special meaning
  1947.             when contained within parenthesis, '()', or character  class,
  1948.             '[]'.
  1949.         r{n1,n2} - at least n1 and up to n2 repetitions of {re} r
  1950.             n1, n2 integers with 1 <= n1 <= n2
  1951.             r{2,6} ==> rrr?r?r?r?
  1952.             r{3,3} ==> rrr
  1953.             Expressions grouped by ", (), [], or names, "{name}"
  1954.             repeated  as  a  group:  (Note the treatment of quoted {ex}s)
  1955.  
  1956.  
  1957.         QTAwk                       - 2-17 -                        QTAwk
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.         Section 2.12                                   Regular Expression
  1965.  
  1966.  
  1967.             (r){2,6} ==> (r)(r)(r)?(r)?(r)?(r)?
  1968.             [r]{2,6} ==> [r][r][r]?[r]?[r]?[r]?
  1969.             {r}{2,6} ==> {r}{r}{r}?{r}?{r}?{r}?
  1970.             "r"{2,6} ==> "rr(r)?(r)?(r)?(r)?"
  1971.             
  1972.         {named_expr} - named expression. In regular expressions  "{name}"
  1973.             is   replaced  by  the  string  value  of  the  corresponding
  1974.             variable.  Unrecognized  variable  names  are  not  replaced.
  1975.         
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.         QTAwk                       - 2-18 -                        QTAwk
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.         Section 3.0                                           Expressions
  2023.  
  2024.  
  2025.         E-3.0 EXPRESSIONSF-Ç
  2026.         
  2027.          QTAwk  provides  a  rich  set  of operators which may be used in
  2028.         expressions. The QTAwk operators are listed below from highest to
  2029.         lowest precedence:
  2030.         
  2031.         Operation              Operator         Associativity            
  2032.         grouping               ()               left to right            
  2033.         array subscripting     []               left to right            
  2034.         field                  $                left to right            
  2035.         tag                    $$               left to right            
  2036.         logical negation (NOT) !                left to right            
  2037.         one's complement       ~                left to right            
  2038.         increment/decrement    ++ --            right to left            
  2039.         unary plus/minus       + -              left to right            
  2040.         exponentiation         ^                right to left            
  2041.         multiply, divide,      * / %            left to right            
  2042.         remainder                                                        
  2043.         binary plus/minus      + -              left to right            
  2044.         concatenation                           left to right            
  2045.         concatenation          ∩                left to right            
  2046.         shift left/right       << >>            left to right            
  2047.         relational             < <= > >=        left to right            
  2048.         equality               == !=            left to right            
  2049.         matching               ~~ !~            left to right            
  2050.         array membership       in               left to right            
  2051.         bit-wise AND           &                left to right            
  2052.         bit-wise XOR           @                left to right            
  2053.         bit-wise OR            |                left to right            
  2054.         logical AND            &&               left to right            
  2055.         logical OR             ||               left to right            
  2056.         conditional            ? :              right to left            
  2057.         assignment             = ^= *= /= %=    right to left            
  2058.                                += -= &= @= |=                            
  2059.                                <<= >>= ∩=                                
  2060.         sequence               ,                left to right            
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.         QTAwk                        - 3-1 -                        QTAwk
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.         Section 3.1                                           Expressions
  2081.  
  2082.  
  2083.         E3.1 New/Changed OperatorsF
  2084.         
  2085.          Note that QTAwk has changed some operators from C and Awk. QTAwk
  2086.         has retained the Awk exponentiation operator (the C  bitwise  XOR
  2087.         operator)  and  made  '@'  the  bitwise  XOR  operator. QTAwk has
  2088.         changed the Awk match operators to '~~' and '!~'  to  bring  them
  2089.         more  in  alignment  with  the equality operators, '==' and '!='.
  2090.         This has freed up the single tilde to restore it to its C meaning
  2091.         of one's complement. QTAwk has also brought forward the remainder
  2092.         of the C operators: shift, '<<'  and  '>>',  bit-wise  operators,
  2093.         '&', '@' and '|', and the sequence operator, ','.
  2094.         
  2095.          QTAwk  has retained the practice of forcing string concatenation
  2096.         by placing two constants, variables or function  calls  adjacent.
  2097.         QTAwk  has  introduced  the  string  concatenation  operator, '∩'
  2098.         (character 239, 0xef of the extended ASCII  character  set).  The
  2099.         string   concatenation  operator  has  the  advantage  of  making
  2100.         concatenation explicit  and  allowing  the  string  concatenation
  2101.         assignment  operator, '∩='. Thus, string concatenation operations
  2102.         which previously had to be written as:
  2103.         
  2104.                        new_string = new_string old_string;               
  2105.         
  2106.          may now be written:
  2107.         
  2108.                             new_string ∩= old_string;                    
  2109.         
  2110.          Thus a loop to build a string of numerics which  previously  was
  2111.         written as:
  2112.         
  2113.                      for( i = 8 , j = 9 ; i ; i-- ) j = j i;             
  2114.         
  2115.          can be written as:
  2116.         
  2117.                      for( i = 8 , j = 9 ; i ; i-- ) j ∩= i;              
  2118.         
  2119.          and will produce a value for j of:
  2120.         
  2121.                                    "987654321"                           
  2122.         
  2123.          The  string  concatenation  operator  will  make some constructs
  2124.         work as expected. For example, the statements:
  2125.         
  2126.         ostr = "prefix";
  2127.         suff = "suffix";
  2128.         k = 1;
  2129.  
  2130.  
  2131.         QTAwk                        - 3-2 -                        QTAwk
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.         Section 3.1                                           Expressions
  2139.  
  2140.  
  2141.         j = ostr ++k suff;
  2142.         print j;
  2143.         print ostr;
  2144.         
  2145.          will produce the seemly odd output:
  2146.         
  2147.         prefix1suffix
  2148.         1
  2149.         
  2150.          This results from two factors:
  2151.         
  2152.         1.  In tokenizing the statements, white space is  used  to  break
  2153.             keyword,   variable  and  function  names.  Otherwise  it  is
  2154.             ignored.
  2155.             
  2156.         2.  The increment operator,  '++',  has  higher  precedence  than
  2157.             string concatenation.
  2158.         
  2159.          Thus, QTAwk processes the following stream of tokens:
  2160.         
  2161.         1.  j
  2162.         2.  =
  2163.         3.  ostr
  2164.         4.  ++
  2165.         5.  k
  2166.         6.  suff
  2167.         7.  ;
  2168.         
  2169.          In  interpreting  the  stream,  '++'  is encountered immediately
  2170.         after 'ostr' and is interpreted as a postfix  operator  operating
  2171.         on  'ostr'  instead  of a prefix operator operating on 'k'. Thus,
  2172.         the stream apears to QTAwk as:
  2173.         
  2174.         j = ostr++ k suff;
  2175.         
  2176.          After concatenating the current string value of ostr,  "prefix",
  2177.         with  the string value of k, "1", ostr is converted to a numeric,
  2178.         yielding a value of zero, 0, which  is  incremented  to  one,  1.
  2179.         
  2180.          This  seemingly anomalous situation can be remedied in two ways:
  2181.         
  2182.         1.  Surround ++k with parenthesis, thus explicitly  binding  '++'
  2183.             to 'k':
  2184.             
  2185.              j = ostr (++k) suff;
  2186.             
  2187.  
  2188.  
  2189.         QTAwk                        - 3-3 -                        QTAwk
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.         Section 3.1                                           Expressions
  2197.  
  2198.  
  2199.         2.  Use  the string concatenation operator, '∩', to make explicit
  2200.             the string concatenation:
  2201.             
  2202.              j = ostr ∩ ++k suff;
  2203.             
  2204.              or
  2205.             
  2206.              j = ostr ∩ ++k ∩ suff;
  2207.         
  2208.          The output produced by this, is what was really desired:
  2209.         
  2210.         prefix2suffix
  2211.         prefix
  2212.         
  2213.         
  2214.          In addition, QTAwk has added one  operator,  the  tag  operator,
  2215.         '$$'.  The  tag  operator is analogous to the field operator, but
  2216.         can be followed only by the single numerical value of  zero  (0).
  2217.         This operator returns the string matched by a regular expression.
  2218.         When used in an action, the last regular expression match in  the
  2219.         corresponding  pattern will set the value of the tag operator. If
  2220.         there was no regular expression match in the pattern, $$0 is  the
  2221.         null  string.  The  operator  may  also  be used in the 'sub' and
  2222.         'gsub' functions in the same manner that  '&'  is  used.  Regular
  2223.         expressions used in actions will not disturb the value of the tag
  2224.         operator set by the pattern. The pattern/action pair:
  2225.         
  2226.          /[-+]?[0-9]+/ {
  2227.             print $$0;
  2228.             if ( $0 ~~ /[789]/ ) print $$0;
  2229.         }
  2230.         
  2231.          With the input line:
  2232.         
  2233.                        this line contains an integer 12745               
  2234.         
  2235.          both 'print' statements will output "12745"
  2236.         
  2237.         E3.2 Sequence OperatorF
  2238.         
  2239.          QTAwk uses the C sequence operator, the comma,  ','.  Using  the
  2240.         sequence operator, expressions may be combined into an expr_list:
  2241.         
  2242.                 expression_1 , expression_2 , expression_3 , ...         
  2243.         
  2244.          As in C,  a  list  of  expressions  separated  by  the  sequence
  2245.  
  2246.  
  2247.         QTAwk                        - 3-4 -                        QTAwk
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.         Section 3.2                                           Expressions
  2255.  
  2256.  
  2257.         operator  is valid anywhere an expression is valid. Such lists of
  2258.         expressions separated by the sequence operator will  be  referred
  2259.         to  as  an  expression  list  or expr_list. Each expression in an
  2260.         expr_list is evaluated in turn. The final value of the  expr_list
  2261.         is  the  value  of  the last expression. The sequence operator is
  2262.         very useful in  the  loop  control  statements  discussed  below.
  2263.         
  2264.         E3.3 Match Operator VariablesF
  2265.         
  2266.          QTAwk has defined two new built-in variables associated with the
  2267.         match operators, MLENGTH and MSTART. Whenever the match  operator
  2268.         is  executed  MLENGTH  is set equal to the length of the matching
  2269.         string or zero if no match is found. MSTART is set equal  to  the
  2270.         position  of the start of the matching string or zero if no match
  2271.         is found. These built-in variables are  completely  analogous  to
  2272.         the  built-in  variables  RLENGTH  and  RSTART  for  the built-in
  2273.         'match' function.
  2274.         
  2275.         E3.4 ConstantsF
  2276.         
  2277.          Expressions in QTAwk can contain  several  types  of  constants:
  2278.         
  2279.         1.  numeric constants
  2280.         2.  character constants
  2281.         3.  string constants
  2282.         4.  regular expressions
  2283.         
  2284.          Numeric  constants  have  several  forms:  integer constants and
  2285.         floating point constants.  Integers  follow  the  C  practice  of
  2286.         allowing decimal, octal and hexadecimal base constants.
  2287.         
  2288.          Decimal constants match the form:
  2289.         
  2290.                                    [-+]?[0-9]+                           
  2291.         
  2292.          Octal constants match the form:
  2293.         
  2294.                                      0[0-7]+                             
  2295.         
  2296.          Hexadecimal constants match the form:
  2297.         
  2298.                                 0[xX][0-9A-Fa-f]+                        
  2299.         
  2300.          The  results  of  all  three  of  the  following expressions are
  2301.         equivalent. All set the variable, int_cons, to the integer value,
  2302.         11567.
  2303.  
  2304.  
  2305.         QTAwk                        - 3-5 -                        QTAwk
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.         Section 3.4                                           Expressions
  2313.  
  2314.  
  2315.         
  2316.              int_cons = 11567;
  2317.         
  2318.              int_cons = 026457;
  2319.         
  2320.              int_cons = 0x2d2f;
  2321.         
  2322.          Floating point numeric constants match the form:
  2323.         
  2324.         {_g}
  2325.         
  2326.          Note  that octal and hexadecimal integers are only recognized in
  2327.         QTAwk expressions and not in the fields of  input  records.  Only
  2328.         decimal  and  floating  point numeric constants are recognized in
  2329.         input fields.
  2330.         
  2331.          String constants are  character  sequences  enclosed  in  double
  2332.         quotes,   ".   The  same  escape  sequences  allowed  in  regular
  2333.         expressions are allowed in string constants.
  2334.         
  2335.          Character constants are single  characters  enclosed  in  single
  2336.         quotes,  ',  The  same  escape  sequences  allowed in strings and
  2337.         regular expressions are allowed in character constants. All three
  2338.         of  the following expressions will set the variable, chr_cons, to
  2339.         'A':
  2340.         
  2341.                                  chr_cons = 'A';                         
  2342.         
  2343.                                chr_cons = '\x041';                       
  2344.         
  2345.                                 chr_cons = '\101'                        
  2346.         
  2347.          QTAwk will maintain variables  set  to  character  constants  as
  2348.         single characters, but they may be used in arithmetic expressions
  2349.         as any other number and QTAwk will automatically convert them  to
  2350.         their numeric value.
  2351.         
  2352.          The  'substr' function will return a character constant when the
  2353.         requested substring is only a single character wide.
  2354.         
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.         QTAwk                        - 3-6 -                        QTAwk
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.         Section 4.0                       Strings and Regular Expressions
  2371.  
  2372.  
  2373.         E-4.0 STRINGS and REGULAR EXPRESSIONSF-Ç
  2374.         
  2375.          Strings and regular expressions in QTAwk are very  similar,  yet
  2376.         very  different. Regular expressions can be used wherever strings
  2377.         are used and strings may be used in most cases  where  a  regular
  2378.         expression may be used.
  2379.         
  2380.         E4.1 Regular Expression and String TranslationF
  2381.         
  2382.          Regular  expressions and strings used as regular expressions are
  2383.         turned into an internal form for scanning the target string for a
  2384.         match.  For  regular  expressions this process of conversion into
  2385.         the internal form is done once, when the  regular  expression  is
  2386.         first used. For strings the process is done every time the string
  2387.         is used as a regular expression. The process of  conversion  into
  2388.         the  internal  form can be time consuming if done repeatedly. The
  2389.         judicious use of strings and regular expressions  can  give  both
  2390.         flexibility  and  speed.  By  using  regular expressions in those
  2391.         places where the content  of  the  regular  expression  will  not
  2392.         change  after the first use, the speed of a single conversion can
  2393.         be attained. By using strings in those  places  where  a  regular
  2394.         expression  is called for, e.g., the first argument of the 'gsub'
  2395.         function and the right hand expression for the  match  operators,
  2396.         the flexibility of dynamically changing expressions can be gained
  2397.         at the expense of speed.
  2398.         
  2399.         E4.2 Regular Expressions in PatternsF
  2400.         
  2401.          There are, however, some places where strings cannot be used  as
  2402.         regular  expressions. The most notable of these is as stand-alone
  2403.         regular expressions in patterns. Stand-alone regular  expressions
  2404.         in patterns are a shorthand for:
  2405.         
  2406.                                    $0 ~~ /re/                            
  2407.         
  2408.          Thus,  complex expressions may be built from stand-alone regular
  2409.         expressions in patterns. For example, the pattern:
  2410.         
  2411.                                  /re1/ && /re2/                          
  2412.         
  2413.          will  match  only  those  records   for   which   both   regular
  2414.         expressions  re1  and  re2  match. Using the logical, relational,
  2415.         equality and bit-wise operators, two or more regular  expressions
  2416.         may be combined in patterns to test records against more than one
  2417.         regular expression. The following pattern:
  2418.         
  2419.  
  2420.  
  2421.         QTAwk                        - 4-1 -                        QTAwk
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.         Section 4.2                       Strings and Regular Expressions
  2429.  
  2430.  
  2431.                                  /re1/ != /re2/                          
  2432.         
  2433.          will select only those records matching  re1  and  NOT  matching
  2434.         re2  But  records  matching re2 and not matching re1 will also be
  2435.         selected.
  2436.         
  2437.                                      !/re1/                              
  2438.         
  2439.          will select those records not matching the  regular  expression.
  2440.         To  use  regular expressions in this manner the following logical
  2441.         truth table may be used for selecting desired records which match
  2442.         or do not match desired regular expressions:
  2443.         
  2444.         r1    T   T   F   F                                              
  2445.         r2    T   F   T   F                                              
  2446.         
  2447.         ==    T   F   F   T                                              
  2448.         !=    F   T   T   F                                              
  2449.         <=    T   F   T   T                                              
  2450.         <     F   F   T   F                                              
  2451.         >     F   T   F   F                                              
  2452.         >=    T   T   F   T                                              
  2453.         &     T   F   F   F                                              
  2454.         |     T   T   T   F                                              
  2455.         @     F   T   T   F                                              
  2456.         &&    T   F   F   F                                              
  2457.         ||    T   T   T   F                                              
  2458.         
  2459.          Thus,  if  you  wanted to select only those records that matched
  2460.         both regular expressions and reject those records  that  did  not
  2461.         match  both,  the  following patterns are the only ones to do so:
  2462.         
  2463.                                   /re1/ & /re2/                          
  2464.         
  2465.          or
  2466.         
  2467.                                  /re1/ && /re2/                          
  2468.         
  2469.          To select those records matching only re1 and not re2  or  both,
  2470.         the following patterns could be used:
  2471.         
  2472.                                   /re1/ > /re2/                          
  2473.         
  2474.          or
  2475.         
  2476.                                  /re1/ && !/re2/                         
  2477.  
  2478.  
  2479.         QTAwk                        - 4-2 -                        QTAwk
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.         Section 4.2                       Strings and Regular Expressions
  2487.  
  2488.  
  2489.          Regular  expressions  and  strings  may  also  be used in 'case'
  2490.         statements  as  described  later.  However,   strings   are   not
  2491.         equivalent to regular expressions in the 'case' statement.
  2492.         
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.         QTAwk                        - 4-3 -                        QTAwk
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.         QTAwk                        - 4-4 -                        QTAwk
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.         Section 5.0                                       Pattern-Actions
  2603.  
  2604.  
  2605.         E-5.0 PATTERN-ACTIONSF-Ç
  2606.         
  2607.          QTAwk recognizes utilities in the following format:
  2608.         
  2609.                                pattern { action }                        
  2610.         
  2611.          The  opening  brace, '{', of the action must be on the same line
  2612.         as the pattern. Patterns control the execution of actions. When a
  2613.         pattern  matches  a  record,  the  associated action is executed.
  2614.         Patterns  consist  of  valid   QTAwk   expressions   or   regular
  2615.         expressions.  The sequence operator acquires a special meaning in
  2616.         pattern expressions and loses its meaning as a sequence operator.
  2617.         
  2618.          QTAwk   follows   the   C  practice  in  logical  operations  of
  2619.         considering a nonzero numeric value as true and  a  zero  numeric
  2620.         value  as  false.  This has been expanded in QTAwk for strings by
  2621.         considering the null string as false and any non-null  string  as
  2622.         true.  When  a  logical  operation  is  performed,  the operation
  2623.         returns an integer value of one (1) for a true condition  and  an
  2624.         integer value of zero (0) for a false condition.
  2625.         
  2626.         E5.1 QTAwk PatternsF
  2627.         
  2628.          QTAwk recognizes the following type of patterns:
  2629.         
  2630.         1.  { action }
  2631.             the  pattern  is assumed TRUE for every record and the action
  2632.             is executed for all records.
  2633.             
  2634.         2.  expression
  2635.             the default action {print;} is executed for every record  for
  2636.             which expression evaluates to TRUE.
  2637.             
  2638.         3.  expression { action }
  2639.             the actions are executed for each record for which expression
  2640.             evaluates to TRUE.
  2641.             
  2642.         4.  /regular expression/ { action }
  2643.             the actions are  executed  for  each  record  for  which  the
  2644.             regular  expression  matches  a  string  in  the record (TRUE
  2645.             condition).  The  regular   expression   may   be   specified
  2646.             explicitly as shown or specified by a variable with a regular
  2647.             expression value. For example, setting the variable,  var_re,
  2648.             as:
  2649.             
  2650.             var_re = /Replacement String/;
  2651.  
  2652.  
  2653.         QTAwk                        - 5-1 -                        QTAwk
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.         Section 5.1                                       Pattern-Actions
  2661.  
  2662.  
  2663.              and specifying the pattern as:
  2664.             
  2665.             var_re { action }
  2666.             
  2667.              would be identical to:
  2668.             
  2669.             /Replacement String/ { action }
  2670.             
  2671.              The  use  of  a  variable has the advantage of being able to
  2672.             change to the value of the variable. Changing the variable to
  2673.             another regular expression gives QTAwk utility the capability
  2674.             of dynamically changing patterns recognized.
  2675.             
  2676.         5.  compound pattern { action }
  2677.             the pattern combines regular expressions  with  logical  NOT,
  2678.             '!',  logical AND, '&&', logical OR, '||', bit-wise AND, '&',
  2679.             bit-wise  OR,  '|',  bit-wise  XOR,   '@',   the   relational
  2680.             operators, '<=', '<', '>', '>=', the equality operators, '=='
  2681.             and '!=', and the matching  operators,  '~~'  and  '!~'.  The
  2682.             action  is  executed  for  each record for which the compound
  2683.             pattern is TRUE.
  2684.             
  2685.         6.  expression1 , expression2 { action }
  2686.             range pattern. The action is executed for  the  first  record
  2687.             for   which  expression1  is  TRUE  and  every  record  until
  2688.             expression2 evaluates TRUE.  The  range  is  inclusive.  This
  2689.             illustrates  the  special meaning of the sequence operator in
  2690.             patterns.
  2691.             
  2692.         7.  predefined pattern { action }
  2693.             the predefined patterns are described next
  2694.         
  2695.         E5.2 QTAwk Predefined PatternsF
  2696.         
  2697.          QTAwk provides five predefined patterns, all  of  which  (except
  2698.         for  the  'GROUP'  pattern)  require actions. The five predefined
  2699.         patterns are:
  2700.         
  2701.         1.  BEGIN { action }
  2702.             the action(s) associated with the BEGIN pattern are  executed
  2703.             once  prior  to  opening  the  first input file. There may be
  2704.             multiple BEGIN  {  action  }  combinations.  Each  action  is
  2705.             executed in the order in which it is specified.
  2706.             
  2707.         2.  INITIAL { action }
  2708.             or
  2709.  
  2710.  
  2711.         QTAwk                        - 5-2 -                        QTAwk
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.         Section 5.2                                       Pattern-Actions
  2719.  
  2720.  
  2721.             INITIALIZE { action }
  2722.             the   action(s)  associated  with  the  INITIAL  (INITIALIZE)
  2723.             pattern are executed after each  input  file  is  opened  and
  2724.             before  the  first  record  is  read.  There  may be multiple
  2725.             INITIAL { action } combinations. Each action is  executed  in
  2726.             the order in which it is specified.
  2727.             
  2728.         3.  GROUP re { action }
  2729.             GROUP re { action }
  2730.             GROUP re { action }
  2731.             GROUP re { action }
  2732.             or
  2733.             GROUP re
  2734.             GROUP re { action }
  2735.             GROUP re
  2736.             GROUP re { action }
  2737.             or
  2738.             GROUP re
  2739.             GROUP re { action }
  2740.             GROUP re
  2741.             GROUP re
  2742.             
  2743.              the  pattern associated with the 'GROUP' pattern keyword may
  2744.             be a single regular expression constant, a string constant or
  2745.             a  variable  name.  All  consecutive  GROUP/action  pairs are
  2746.             grouped and the search for the regular expressions  optimized
  2747.             over the group. Each regular expression of the GROUP may have
  2748.             a separate action  associated  with  it.  In  this  case  the
  2749.             appropriate  action  is executed if the regular expression is
  2750.             matched on the current input record.  If  the  action  for  a
  2751.             regular  expression  is  not  given,  then  the  next  action
  2752.             explicitly given is executed. If no action is given  for  the
  2753.             last  regular  expression of a GROUP, then the default action
  2754.             
  2755.                                      { print ; }                         
  2756.             
  2757.              is assigned to it. When one of the  regular  expressions  of
  2758.             the GROUP is matched, the built-in variable, NG, is set equal
  2759.             to the number of the regular expression. The numbering of the
  2760.             regular expressions in the GROUP starts with one, 1.
  2761.             
  2762.              There  may  be  more  than  one  GROUP of regular expression
  2763.             patterns. Any pattern not preceded with the  'GROUP'  keyword
  2764.             will  cause  a  GROUP to be terminated. The occurrence of the
  2765.             'GROUP'  keyword  again  will  start  a  new  GROUP  and  the
  2766.             numbering of the new group starts at one, 1.
  2767.  
  2768.  
  2769.         QTAwk                        - 5-3 -                        QTAwk
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.         Section 5.2                                       Pattern-Actions
  2777.  
  2778.  
  2779.              GROUP patterns are discussed in more detail later.
  2780.             
  2781.         4.  NOMATCH { ACTION }
  2782.             the   action(s)  associated  with  the  NOMATCH  pattern  are
  2783.             executed for each record for which no pattern is TRUE.  There
  2784.             may  be multiple NOMATCH { action } combinations. Each action
  2785.             is executed in the order in which it is specified.
  2786.             
  2787.         5.  FINAL
  2788.             or
  2789.             FINALIZE
  2790.             the actions associated with the FINAL (FINALIZE) pattern  are
  2791.             executed  after  the  last record of each input file has been
  2792.             read and before the file is closed.  There  may  be  multiple
  2793.             FINAL { action } combinations. Each action is executed in the
  2794.             order in which it is specified.
  2795.             
  2796.         6.  END ( action )
  2797.             the action(s) associated with the END  pattern  are  executed
  2798.             once  after the last input file has been closed. There may be
  2799.             multiple END { action } combinations. Each action is executed
  2800.             in the order in which it is specified.
  2801.         
  2802.          Note  that there may be multiple predefined pattern-action pairs
  2803.         defined in an QTAwk utility.  Each  action  is  executed  at  the
  2804.         appropriate time in the order defined.
  2805.         
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.         QTAwk                        - 5-4 -                        QTAwk
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.         Section 6.0                                  Variables and Arrays
  2835.  
  2836.  
  2837.         E-6.0 VARIABLES and ARRAYSF-Ç
  2838.         
  2839.          Variables in QTAwk are of four kinds:
  2840.         1.  user defined
  2841.         2.  built-in
  2842.         3.  field
  2843.         4.  tag
  2844.         
  2845.          The names of user defined variables start with an upper or lower
  2846.         case character or underscore optionally followed by one  or  more
  2847.         upper or lower case characters, digits or underscores. Most QTAwk
  2848.         built-in  variables  are  named  with  upper  case  letters   and
  2849.         underscores  (only three are defined with lower case characters).
  2850.         
  2851.          Variables are defined by using them  in  expressions.  Variables
  2852.         have  numeric,  string  or regular expression values or all three
  2853.         depending upon the context in which they are used in  expressions
  2854.         or  function calls. Except for variables defined with the 'local'
  2855.         keyword, all variables are global in  scope.  That  is  they  are
  2856.         accessible  and  can  be changed anywhere within a QTAwk utility.
  2857.         Local variables will be discussed later when the 'local'  keyword
  2858.         is  discussed.  All  variables  are  initialized  with a zero (0)
  2859.         numeric  value  and  the  null  string  value  when  created   by
  2860.         reference.  The  value  of  the  variable  is  changed  with  the
  2861.         assignment operator, '=' or 'op='.
  2862.         
  2863.                                   var1 = 45.87;                          
  2864.         
  2865.                              var2 = "string value";                      
  2866.         
  2867.                      var3 = /[\s\t]+[A-Za-z_][A-Za-z0-9_]+/;             
  2868.         
  2869.          var1  has  a  numeric  value  of  45.87  from   the   assignment
  2870.         statement.  It  has  a  string  value of "45.87" and a value as a
  2871.         regular expression of /45\.87/. The string and regular expression
  2872.         values  of  var1  may  be  changed  by  changing the value of the
  2873.         built-in variable "OFMT". The string value of  OFMT  is  used  to
  2874.         convert  numeric  values to string and regular expression values.
  2875.         OFMT is initialized with a value of "%.6g"  and  can  be  changed
  2876.         with  an assignment statement. Such changes would then affect the
  2877.         string and regular expression values of numeric  quantities.  For
  2878.         example, if OFMT is assigned a value of "%u", then the string and
  2879.         regular expression values of var1  would  become  "45"  and  /45/
  2880.         respectively.
  2881.         
  2882.          The numeric values of both var2 and var3 is zero (0).
  2883.  
  2884.  
  2885.         QTAwk                        - 6-1 -                        QTAwk
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.         Section 6.0                                  Variables and Arrays
  2893.  
  2894.  
  2895.          The  string  value  of  var3 is "[\s\t]+[A-Za-z_][A-Za-z0-9_]+".
  2896.         Note that the tab escape  sequence,  '\t',  is  not  expanded  in
  2897.         converting the regular expression to a string. The reverse is not
  2898.         true. One difference between strings and regular  expressions  is
  2899.         the time at which escape sequences such as '\t' are translated to
  2900.         ASCII hexadecimal characters. For  strings,  the  translation  is
  2901.         done  when  the  strings  are  read  from  the QTAwk utility. For
  2902.         regular expressions the escape sequences are translated when  the
  2903.         regular  expression  is  converted  to  internal  form.  For this
  2904.         reason, strings used in the place of regular expressions  undergo
  2905.         a  double translation, first when read from the QTAwk utility and
  2906.         second when converted into the internal regular expression  form.
  2907.         The second translation of strings used for regular expressions is
  2908.         the reason backslash characters, '\', must be doubled for strings
  2909.         used in this manner.
  2910.         
  2911.         E6.1 QTAwk ArraysF
  2912.         
  2913.          Arrays  in QTAwk are a blending of Awk and C. The use of the Awk
  2914.         associative arrays is continued and  expanded  to  allow  integer
  2915.         indices. The use of the comma to delineate multiple array indices
  2916.         is discontinued. The comma is now the sequence operator and  will
  2917.         be  so  treated  in  array index expressions. Thus, the reference
  2918.         
  2919.                                      A[i,j]                              
  2920.         
  2921.          will now reference the element of A subscripted by  the  current
  2922.         value  of  the  variable  j.  As  a  consequence  of this the Awk
  2923.         built-in  variable  SUBSEP  has  been   dropped.   QTAwk   allows
  2924.         multidimensional arrays referenced in the same manner as C. Thus:
  2925.         
  2926.                                      A[i][j]                             
  2927.         
  2928.          references the jth column of the ith row of the  two-dimensional
  2929.         array A. Array subscripts may be strings. Thus:
  2930.         
  2931.                                   A[i]["state"]                          
  2932.         
  2933.          would  reference  the  "state" element of the ith row of the two
  2934.         dimensional array, A. QTAwk allows array  indices  to  be  either
  2935.         integers or strings. Integer or string indices may be used on the
  2936.         same array. Integer indices are  stored  before  string  indices,
  2937.         integer  indices  follow  the  usual  numeric ordering and string
  2938.         indices follow the ASCII collating sequence. The ordering will be
  2939.         apparent in use of the 'in' form of the 'for' statement:
  2940.         
  2941.  
  2942.  
  2943.         QTAwk                        - 6-2 -                        QTAwk
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.         Section 6.1                                  Variables and Arrays
  2951.  
  2952.  
  2953.                             for ( k in A ) statement                     
  2954.         
  2955.          k  is  stepped  through  the  indices  of the singly dimensioned
  2956.         array, A, in the order  stored.  Thus  if  A  has  the  following
  2957.         indices:  1, 3, 5, 7, 8, 9, 10, 12, 14, "county", "state", "zip".
  2958.         Then k would be stepped through the indices in that  order.  Note
  2959.         that  allowing  both  string  and  integer  indices overcomes the
  2960.         disconcerting order of the "stringized numerical" indices of Awk.
  2961.         Specifically,  index  10  does not precede 2 as "10" does precede
  2962.         "2" in Awk. QTAwk still allows the use of numeric strings such as
  2963.         "10",  "2",  etc.,  but in most cases where such strings would be
  2964.         used, the user should be  aware  that  integer  indices  are  now
  2965.         available  and will prevent the counterintuitive ordering of Awk.
  2966.         
  2967.          Note that only indexed elements of an array actually  referenced
  2968.         exist.  Thus,  for the array A above, the elements for indices 2,
  2969.         4, 6 and 13 do not exist since they  have  not  been  referenced.
  2970.         This  follows  the  general  philosophy  that a variable does not
  2971.         exist until it has been referenced.
  2972.         
  2973.         E6.2 QTAwk Arrays in Arithmetic ExpressionsF
  2974.         
  2975.          When Arrays are used in arithmetic  expressions  in  QTAwk,  the
  2976.         entire  array  is  operated  on  or assigned. For example, if the
  2977.         variable 'B' is a 3x3 array with the following values:
  2978.         
  2979.         B[1][1] = 11, B[1][2] = 12, B[1][3] = 13
  2980.         B[2][1] = 21, B[2][2] = 22, B[2][3] = 23
  2981.         B[3][1] = 31, B[3][2] = 32, B[3][3] = 33
  2982.         
  2983.          Assigning B to the variable 'A':
  2984.         
  2985.         A = B
  2986.         
  2987.          will duplicate the entire array into A.
  2988.         
  2989.         A[1][1] = 11, A[1][2] = 12, A[1][3] = 13
  2990.         A[2][1] = 21, A[2][2] = 22, A[2][3] = 23
  2991.         A[3][1] = 31, A[3][2] = 32, A[3][3] = 33
  2992.         
  2993.          If A and B are array variables and C  is  a  scalar  (non-array)
  2994.         variable,  then the following expression forms for the assignment
  2995.         operators, 'op=', are legal:
  2996.         
  2997.         1.   A = B
  2998.             assign one array to a second. The original elements of  array
  2999.  
  3000.  
  3001.         QTAwk                        - 6-3 -                        QTAwk
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.         Section 6.2                                  Variables and Arrays
  3009.  
  3010.  
  3011.             A  are  deleted  and the the elements of B duplicated into A.
  3012.             
  3013.         2.  C = B
  3014.             assigning an array to a variable currently  a  scalar.  Again
  3015.             the  elements  of  B  are duplicated into elements of C which
  3016.             becomes an array.
  3017.             
  3018.         3.  A = C
  3019.             assigning a scalar to a  variable  which  is  an  array.  The
  3020.             elements  of the array are discarded and the variable becomes
  3021.             a scalar.
  3022.             
  3023.         4.  A = B[i]...[j]
  3024.             assigning an array element to a variable which  is  currently
  3025.             an  array.  Since  the  element of an array is a scalar, this
  3026.             case is essentially the  same  as  the  immediately  previous
  3027.             case.
  3028.             
  3029.         5.  A[i]...[j] = B[k]...[l]
  3030.             since  array  elements  are scalars, this is the usual scalar
  3031.             assignment case.
  3032.             
  3033.         6.  A op= C
  3034.             the 'op=' operator is applied to every element of A. Thus,  A
  3035.             += 2, would add '2' to every element of A.
  3036.             
  3037.         7.  A op= B
  3038.             the 'op=' operator is applied to every element of A for which
  3039.             an element exists in B with identical  indices.  No  elements
  3040.             are  created  in  A  to  match  elements  of  B  with indices
  3041.             different from any  element  of  A.  Thus,  the  sequence  of
  3042.             statements:
  3043.             
  3044.             A = B;
  3045.             A += B;
  3046.             
  3047.              would  leave  every element of A with twice the value of the
  3048.             corresponding element of B.
  3049.         
  3050.          There  are  two  cases  of  using  arrays  with  the  assignment
  3051.         operators  that  are  not legal and for which QTAwk will issue an
  3052.         error message at runtime.
  3053.         
  3054.         1.  A[i]...[j] = B
  3055.         2.  A[i]...[j] op= B
  3056.         3.  C op= B
  3057.  
  3058.  
  3059.         QTAwk                        - 6-4 -                        QTAwk
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.         Section 6.2                                  Variables and Arrays
  3067.  
  3068.  
  3069.          These are all variations on the same expression.  In  the  first
  3070.         case,  the  expression  is  attempting  to  assign  an array to a
  3071.         scalar, an array  element.  Since  an  array  element  cannot  be
  3072.         further expanded into an array, the assignment is not allowed. In
  3073.         the second and third cases, the  expressions  are  attempting  to
  3074.         operate  on  a  scalar with an array and assign the result to the
  3075.         scalar. Both of these expressions fail for the  same  reason,  an
  3076.         array  cannot  operate  on  a scalar. It is possible for a single
  3077.         value, a scalar, to operate on every element of an array, but the
  3078.         reverse,  having  each element of the array operate on the scalar
  3079.         is not permitted.
  3080.         
  3081.          The reasoning prohibiting the second and  third  case  above  is
  3082.         extended  to all binary expressions involving arrays in QTAwk. In
  3083.         general, arrays are allowed in expressions with binary arithmetic
  3084.         operators:
  3085.         
  3086.                             ~ ^ * / % + - << >> & @ |                    
  3087.         
  3088.          as well as string concatenation:
  3089.         
  3090.                             A B (equivalent to A ∩ B)                    
  3091.         
  3092.          In  such expressions, arrays are allowed in the following forms:
  3093.         
  3094.         1.  A op B
  3095.         2.  A op C
  3096.         
  3097.          But not as
  3098.         
  3099.         C op A
  3100.         
  3101.          It could be argued that expressions such as,
  3102.         
  3103.         2 + A
  3104.         
  3105.          should be allowed since '+' is commutative  and  the  expression
  3106.         could be written equivalently as,
  3107.         
  3108.         A + 2
  3109.         
  3110.          This  is  true  for  addition,  but  not  for  all of the binary
  3111.         arithmetic operators. For example, the division operator  is  not
  3112.         commutative.
  3113.         
  3114.         2 / A
  3115.  
  3116.  
  3117.         QTAwk                        - 6-5 -                        QTAwk
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.         Section 6.2                                  Variables and Arrays
  3125.  
  3126.  
  3127.          could not be written equivalently as:
  3128.         
  3129.         A / 2
  3130.         
  3131.          For  this  reason, QTAwk does not allow any array expressions of
  3132.         the form:
  3133.         
  3134.         scalar op array
  3135.         
  3136.          The unary arithmetic operators may also be used  to  operate  on
  3137.         entire arrays:
  3138.         
  3139.             ++A (pre-fix increment operator)
  3140.         
  3141.             --A (pre-fix decrement operator)
  3142.         
  3143.             A++ (post-fix increment operator)
  3144.         
  3145.             A-- (post-fix decrement operator)
  3146.         
  3147.             -A (Unary minus operator)
  3148.         
  3149.             +A (Unary plus operator)
  3150.         
  3151.             ~A (Unary one's complement operator)
  3152.         
  3153.          An expression such as:
  3154.         
  3155.         A + B
  3156.         
  3157.          will  result in an array with element indices identical to those
  3158.         of A, and with values which are the sum of the elements of A  and
  3159.         B,  which have identical indices. If A has an element for which B
  3160.         does not have a  corresponding  element,  the  resultant  element
  3161.         value  is  equal to the A element value. Elements of B which have
  3162.         no corresponding element in A are not represented in the reultant
  3163.         array.
  3164.         
  3165.          An  array with elements of double the value of the elements of B
  3166.         can created as:
  3167.         
  3168.         A = B;
  3169.         D = A + B;
  3170.         
  3171.          or as
  3172.         
  3173.  
  3174.  
  3175.         QTAwk                        - 6-6 -                        QTAwk
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.         Section 6.2                                  Variables and Arrays
  3183.  
  3184.  
  3185.         D = B + B;
  3186.         
  3187.          or as
  3188.         
  3189.         D = B * 2;
  3190.         
  3191.          any of the above sequence of statements will result in an array,
  3192.         D, with elements with indices identical to B, and with double the
  3193.         element values. The array A could be made an array with  elements
  3194.         twice the element values of B with the statement:
  3195.         
  3196.         A = B;
  3197.         A *= 2;
  3198.         
  3199.          Arrays  may be used in expressions with arithmetic operators and
  3200.         the whole array will be utilized in the expression. This does not
  3201.         extend to the logical operators:
  3202.         
  3203.                           ! < <= >= > == != ~~ !~ && ||                  
  3204.         
  3205.          Using  an array with a logical operator will result in the first
  3206.         element in the array only being used in the expression.
  3207.         
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.         QTAwk                        - 6-7 -                        QTAwk
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.  
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.         QTAwk                        - 6-8 -                        QTAwk
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.         Section 7.0                                        Group Patterns
  3299.  
  3300.  
  3301.         E-7.0 GROUP PATTERNSF-Ç
  3302.         
  3303.          GROUP patterns follow the syntax:
  3304.         
  3305.         GROUP re1 { optional action }
  3306.         GROUP re2 { optional action }
  3307.         GROUP re3 { optional action }
  3308.         GROUP re4 { optional action }
  3309.         GROUP re5 { optional action }
  3310.         GROUP re6 { optional action }
  3311.         
  3312.          Actions are optional with any particular regular  expression  in
  3313.         the  group.  If  no action is given, the next action specified in
  3314.         the group is executed. If no action is  specified  for  the  last
  3315.         regular  expression in a group, the default action, "{print;}" is
  3316.         assigned to it.
  3317.         
  3318.          Any utility may have more than one GROUP of patterns. A group is
  3319.         terminated  by any pattern not starting with the 'GROUP' keyword.
  3320.         
  3321.         E7.1 GROUP Pattern AdvantageF
  3322.         
  3323.          GROUP patterns have two distinct advantages in QTAwk:
  3324.         
  3325.         1.  the regular expressions contained in the GROUP are  optimized
  3326.             to decrease search time, and
  3327.         2.  input  records  are searched once for all regular expressions
  3328.             in a GROUP. If the  regular  expressions  were  organized  as
  3329.             individual   pattern-actions,   each   record   is   searched
  3330.             separately for each regular expression.
  3331.         
  3332.          For utilities containing many regular  expression  patterns  for
  3333.         which  to  search,  a program organized into a one or more GROUPs
  3334.         can be many times faster than a  utility  organized  as  ordinary
  3335.         pattern/action pairs. For example, the QTAwk utility ansicstd.exp
  3336.         shown in Appendix III searches a C source file listing for ANSI C
  3337.         Standard  defined  names. The utility organizes the search into a
  3338.         single GROUP and will search a source file approximately 6  times
  3339.         faster than the same utility organized as separate pattern/action
  3340.         pairs without the use of a GROUP.
  3341.         
  3342.         E7.2 GROUP Pattern DisadvantageF
  3343.         
  3344.          GROUP  patterns  have  one  disadvantage  compared  to  ordinary
  3345.         pattern/action  pairs.  QTAwk  will  find only one of the regular
  3346.         expressions in a GROUP. A set of GROUP patterns:
  3347.  
  3348.  
  3349.         QTAwk                        - 7-1 -                        QTAwk
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.         Section 7.2                                        Group Patterns
  3357.  
  3358.  
  3359.         GROUP re1 { action1; }
  3360.         GROUP re2 { action2; }
  3361.         GROUP re3 { action3; }
  3362.         
  3363.          is similar in execution to:
  3364.         
  3365.         re1 { action1; next; }
  3366.         re2 { action2; next; }
  3367.         re3 { action3; next; }
  3368.         
  3369.          If more than one regular expression in  a  group  will  match  a
  3370.         given  string  in the input record, the regular expression listed
  3371.         first in the GROUP will be matched  and  the  appropriate  action
  3372.         executed.  If  all regular expression patterns in a GROUP must be
  3373.         found in input records, then separate pattern-action  pairs  must
  3374.         be used.
  3375.         
  3376.         E7.3 GROUP Pattern Regular ExpressionsF
  3377.         
  3378.          The regular expressions associated with the GROUP pattern can be
  3379.         either regular expression constants, e.g.,
  3380.         
  3381.         GROUP /regular expression constant/
  3382.         
  3383.          a string constant, e.g.,
  3384.         
  3385.         GROUP "string constant"
  3386.         
  3387.          or a variable, e.g.,
  3388.         
  3389.         GROUP var_name
  3390.         
  3391.         
  3392.          GROUP patterns are converted into an internal form  for  regular
  3393.         expressions  only once, when the pattern is first used to scan an
  3394.         input line. Any variables in a GROUP pattern will  be  evaluated,
  3395.         converted to string form and interpreted as a regular expression.
  3396.         
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.         QTAwk                        - 7-2 -                        QTAwk
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.         Section 8.0                                            Statements
  3415.  
  3416.  
  3417.         E-8.0 STATEMENTSF-Ç
  3418.         
  3419.          QTAwk has departed from Awk by using the C convention  of  using
  3420.         the  semi-colon,  ';',  as  a  statement terminator. QTAwk treats
  3421.         newline characters as white space and ignores  them,  except  for
  3422.         terminating comments. Comments are introduced by the symbol, '#',
  3423.         and continue to the next newline character. Thus the Awk practice
  3424.         of  letting  newlines  terminate some statements can no longer be
  3425.         used. The Awk rules for terminating statements with  the  newline
  3426.         except  under  some  conditions  can  now be forgotten. In QTAwk,
  3427.         terminate all statements with a semi-colon, ';'.
  3428.         
  3429.          QTAwk provides braces for grouping statements to  form  compound
  3430.         statements.  Various  keywords  are available for controlling the
  3431.         logical  flow  of  statement  execution  and  for  looping   over
  3432.         statements multiple times.
  3433.         
  3434.         E8.1 QTAwk KeywordsF
  3435.         
  3436.          The QTAwk keywords are:
  3437.         
  3438.         1.  break
  3439.         2.  case
  3440.         3.  continue
  3441.         4.  cycle
  3442.         5.  default
  3443.         6.  delete
  3444.         7.  deletea
  3445.         8.  do
  3446.         9.  else
  3447.         10.  endfile
  3448.         11.  exit
  3449.         12.  for
  3450.         13.  if
  3451.         14.  in
  3452.         15.  local
  3453.         16.  next
  3454.         17.  return
  3455.         18.  switch
  3456.         19.  while
  3457.         
  3458.          The  keywords  'cycle', 'deletea', 'local' and 'endfile' are new
  3459.         to QTAwk. The keywords 'switch', 'case' and 'default'  have  been
  3460.         appropriated from C with expanded functionality over C.
  3461.         
  3462.         E8.2 'cycle' and 'next'F
  3463.  
  3464.  
  3465.         QTAwk                        - 8-1 -                        QTAwk
  3466.  
  3467.  
  3468.  
  3469.  
  3470.  
  3471.  
  3472.         Section 8.2                                            Statements
  3473.  
  3474.  
  3475.          The  'cycle' and 'next' statements allow the user to control the
  3476.         execution of the QTAwk outer loop which reads  records  from  the
  3477.         current  input  file and compares them against the patterns. Both
  3478.         statements, restart the pattern matching.
  3479.         
  3480.          The 'next' statement causes the next input  record  to  be  read
  3481.         before  restarting the outer pattern matching loop with the first
  3482.         pattern-action pair.
  3483.         
  3484.          The 'cycle' statement may use the current input  record  or  the
  3485.         next input record for restarting the outer pattern matching loop.
  3486.         As each input record is read from the  current  input  file,  the
  3487.         built-in   variable  CYCLE_COUNT  is  set  to  one.  The  'cycle'
  3488.         statement increments the numeric value of CYCLE_COUNT by one  and
  3489.         compares  the  new  value  to  the  numeric value of the built-in
  3490.         MAX_CYCLE variable. One of two actions is taken depending on  the
  3491.         result of this comparison:
  3492.         
  3493.         1.  If  CYCLE_COUNT  is  greater  than  MAX_CYCLE,  then the next
  3494.             input record is read, setting NR, FNR, $0, NF and the  record
  3495.             fields  $1,  $2, ... $NF, before restarting the outer pattern
  3496.             matching loop. This is identical to the action of the  'next'
  3497.             keyword.
  3498.             
  3499.         2.  If  CYCLE_COUNT  is  less  than  or  equal  to MAX_CYCLE, the
  3500.             current values of NR, FNR, $0, NF and the record  fields  are
  3501.             utilized  when  restarting  the  outer pattern matching loop.
  3502.         
  3503.          The default value of MAX_CYCLE  is  100.  Both  CYCLE_COUNT  and
  3504.         MAX_CYCLE  are  built-in  variables  and may be set by the user's
  3505.         utility. Setting MAX_CYCLE is useful to  control  the  number  of
  3506.         iterations  possible  on  a  record. Setting MAX_CYCLE to 1 would
  3507.         make the 'cycle' and 'next' keywords identical.
  3508.         
  3509.          If the value of CYCLE_COUNT is set by the user's  utility,  care
  3510.         should  be  taken  to  prevent  the  possibility  of  the utility
  3511.         entering a loop from which it cannot exit.
  3512.         
  3513.          The 'cycle' statement is useful when it is necessary to  process
  3514.         the  current  input  record  through the outer pattern match loop
  3515.         more than once. The following utility is a trivial example of one
  3516.         such  use.  This  utility  will print each record with the record
  3517.         number multiple times. The number of times is determined  by  the
  3518.         value assigned MAX_CYCLE in the 'BEGIN' action.
  3519.         
  3520.         BEGIN {
  3521.  
  3522.  
  3523.         QTAwk                        - 8-2 -                        QTAwk
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.         Section 8.2                                            Statements
  3531.  
  3532.  
  3533.             MAX_CYCLE = 10;
  3534.         }
  3535.         
  3536.             {
  3537.             print FNR,$0;
  3538.             cycle;
  3539.         }
  3540.         
  3541.         E8.3 'delete' and 'deletea'F
  3542.         
  3543.          The  'delete'  and 'deletea' statements allow the user to delete
  3544.         individual elements of an array or an entire array  respectively.
  3545.         The form of the 'delete' and 'deletea' statements are:
  3546.         
  3547.                               delete A[expr_list];                       
  3548.         
  3549.          and
  3550.         
  3551.                                    deletea A;                            
  3552.         
  3553.          The  first form will delete the element of array A referenced by
  3554.         the subscript determined by 'expr_list'.  The  second  form  will
  3555.         delete the entire array. Note that for singly dimensioned arrays,
  3556.         the 'deletea' statement is equivalent to the statement:
  3557.         
  3558.                            for ( j in A ) delete A[j];                   
  3559.         
  3560.          The use of the 'deletea' statement is encouraged for  simplicity
  3561.         and  speed  of  execution. The 'delete' statement may be used for
  3562.         arrays of any  dimension.  However,  for  arrays  with  dimension
  3563.         greater  than  2,  the elements of the array are not deleted, but
  3564.         simply initialized to zero and the null string. This behavior has
  3565.         to do with the structure of arrays and the 'holes' which could be
  3566.         left by deleting elements. For singly dimensioned  arrays,  there
  3567.         is  no  problem, since there can be no 'hole' left by deleting an
  3568.         element. For  example  consider  the  singly  dimensioned  array:
  3569.         
  3570.                   A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9]           
  3571.         
  3572.          If the array element A[5] is deleted
  3573.         
  3574.                   A[1] A[2] A[3] A[4] ____ A[6] A[7] A[8] A[9]           
  3575.         
  3576.          Then the remaining elements 'shift' to fill the 'hole'.
  3577.         
  3578.                      A[1] A[2] A[3] A[4] A[6] A[7] A[8] A[9]             
  3579.  
  3580.  
  3581.         QTAwk                        - 8-3 -                        QTAwk
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.         Section 8.3                                            Statements
  3589.  
  3590.  
  3591.          For  two-dimensional  arrays  a complication arises in trying to
  3592.         fill the 'hole' left by deleting an array element.
  3593.         
  3594.         A[1][1] A[1][2] A[1][3] A[1][4] A[1][5] A[1][6]
  3595.         A[2][1] A[2][2] A[2][3] A[2][4] A[2][5] A[2][6]
  3596.         A[3][1] A[3][2] A[3][3] A[3][4] A[3][5] A[3][6]
  3597.         A[4][1] A[4][2] A[4][3] A[4][4] A[4][5] A[4][6]
  3598.         A[5][1] A[5][2] A[5][3] A[5][4] A[5][5] A[5][6]
  3599.         A[6][1] A[6][2] A[6][3] A[6][4] A[6][6] A[6][6]
  3600.         
  3601.          If element A[4][4] is deleted, then we have the 'hole':
  3602.         
  3603.         A[1][1] A[1][2] A[1][3] A[1][4] A[1][5] A[1][6]
  3604.         A[2][1] A[2][2] A[2][3] A[2][4] A[2][5] A[2][6]
  3605.         A[3][1] A[3][2] A[3][3] A[3][4] A[3][5] A[3][6]
  3606.         A[4][1] A[4][2] A[4][3] _______ A[4][5] A[4][6]
  3607.         A[5][1] A[5][2] A[5][3] A[5][4] A[5][5] A[5][6]
  3608.         A[6][1] A[6][2] A[6][3] A[6][4] A[6][6] A[6][6]
  3609.         
  3610.          In trying to fill the 'hole', we have a choice of  shifting  the
  3611.         elements  below the deleted element up to fill the 'hole', column
  3612.         priority, or shifting the elements to the right  of  the  deleted
  3613.         element  to fill the 'hole', row priority. In QTAwk, row priority
  3614.         is used in filling the 'hole':
  3615.         
  3616.         A[1][1] A[1][2] A[1][3] A[1][4] A[1][5] A[1][6]
  3617.         A[2][1] A[2][2] A[2][3] A[2][4] A[2][5] A[2][6]
  3618.         A[3][1] A[3][2] A[3][3] A[3][4] A[3][5] A[3][6]
  3619.         A[4][1] A[4][2] A[4][3] A[4][5] A[4][6]
  3620.         A[5][1] A[5][2] A[5][3] A[5][4] A[5][5] A[5][6]
  3621.         A[6][1] A[6][2] A[6][3] A[6][4] A[6][6] A[6][6]
  3622.         
  3623.          For arrays of higher  dimensions  the  situation  is  even  more
  3624.         complicated.  Not  only  do  elements  have  to be "shifted", but
  3625.         elements in the array will have to be discarded  to  do  so.  For
  3626.         example, if A is a 3x3x3 array and element A[2][2][2] is deleted,
  3627.         then element A[2][2][3], if it existed, would also be deleted  by
  3628.         shifting  other  elements  to fill the 'hole'. QTAwk will in this
  3629.         case initialize the element  A[2][2][2]  to  zero  and  the  null
  3630.         string  rather  than  delete the element and lose other elements.
  3631.         Thus, the 'delete' statement only truely deletes elements for one
  3632.         and two dimensional arrays.
  3633.         
  3634.          The  'deletea'  statement,  however,  works  on  arrays  of  any
  3635.         dimension. For multi-dimensional arrays, the 'deletea'  would  be
  3636.         equivalent  to  nested  'for'  statements.  For  example,  if the
  3637.  
  3638.  
  3639.         QTAwk                        - 8-4 -                        QTAwk
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.         Section 8.3                                            Statements
  3647.  
  3648.  
  3649.         'delete' statement truely deleted elements of a three dimensional
  3650.         array,   then  the  'deletea'  statement  could  be  imagined  as
  3651.         equivalent to:
  3652.         
  3653.         for ( i in A )
  3654.           for ( j in A[i] )
  3655.             for ( k in A[i][j] ) delete A[i][j][k]
  3656.         
  3657.         E8.4 'if'/'else'F
  3658.         
  3659.          The 'if' and  'else'  keywords  provide  for  executing  one  of
  3660.         possibly  two statements conditioned upon the TRUE or FALSE value
  3661.         of an expr_list. The form of the 'if'/'else' statement is:
  3662.         
  3663.                            if ( expr_list ) statement1                   
  3664.         
  3665.          or
  3666.         
  3667.                    if ( expr_list ) statement1 else statement2           
  3668.         
  3669.          If  expr_list  when  evaluated,  produces  a  TRUE  value   then
  3670.         statement1  is executed. If the expr_list produces a FALSE value,
  3671.         then for the second form, statement2 is executed.
  3672.         
  3673.         E8.5 'in'F
  3674.         
  3675.          The 'in' keyword allows the user to test membership in arrays in
  3676.         expressions.  The  form  of  an  expression  containing  the 'in'
  3677.         keyword is:
  3678.         
  3679.                                  expression in A                         
  3680.         
  3681.          if the value of 'expression' is a  current  subscript  value  of
  3682.         the array A, the expression yields a TRUE value, otherwise FALSE.
  3683.         For multidimensional arrays, the statement:
  3684.         
  3685.                                expression in A[i]                        
  3686.         
  3687.          would test if 'expression' is a valid column  subscript  in  the
  3688.         ith row of array A. Note that A may have more than two dimensions
  3689.         for this statement to be correct. The next higher dimension  than
  3690.         stated in the expression is always tested.
  3691.         
  3692.         E8.6 'switch', 'case', 'default'F
  3693.         
  3694.          QTAwk  includes  an  expanded  form  of  the  C  'switch'/'case'
  3695.  
  3696.  
  3697.         QTAwk                        - 8-5 -                        QTAwk
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.         Section 8.6                                            Statements
  3705.  
  3706.  
  3707.         statements. In C, the 'switch'/'case' statements must be  of  the
  3708.         form:
  3709.         
  3710.         switch ( expr_list ) {
  3711.              case constant1: statement
  3712.              case constant2: statement
  3713.              case constant3: statement
  3714.              case constant4: statement
  3715.              default: statement
  3716.         }
  3717.         
  3718.          The  expr_list  of  the  'switch'  statement must evaluate to an
  3719.         integral value and  'constant1',  'constant2',  'constant3',  and
  3720.         'constant4',  must  be  compile-time integral constant values. In
  3721.         QTAwk,  the  'case'  statement  may  contain  any   valid   QTAwk
  3722.         expression or expr_list:
  3723.         
  3724.         switch ( expr_list ) {
  3725.              case expr_list1: statement
  3726.              case expr_list2: statement
  3727.              case expr_list3: statement
  3728.              case expr_list4: statement
  3729.              default: statement
  3730.         }
  3731.         
  3732.          The  expr_lists  of the case statements are evaluated in turn at
  3733.         execution time. The resultant value is checked against the  value
  3734.         of  the  expr_list  of the 'switch' statement using the following
  3735.         logic.
  3736.         
  3737.         if ( cexpr is a regular expression ) sexpr ~~ cexpr;
  3738.           else sexpr == cexpr;
  3739.         
  3740.          where cexpr is the value of the case expr_list and sexpr is  the
  3741.         value  of  the  'switch'  statement expr_list. Thus if cexpr is a
  3742.         regular expression, a match operation is performed. If cexpr is a
  3743.         string,  a string comparison is performed. If cexpr is a numeric,
  3744.         a numerical comparison is performed. It is possible to have  case
  3745.         statements  with  differing types of expr_list values in the same
  3746.         'switch' statement and the proper comparison is made.
  3747.         
  3748.          Once a TRUE value is returned by a  case  statement  comparison,
  3749.         the execution falls through from 'case' to 'case' with no further
  3750.         comparisons made. The fall through of execution is broken by  the
  3751.         use of the 'break' statement as in C.
  3752.         
  3753.  
  3754.  
  3755.         QTAwk                        - 8-6 -                        QTAwk
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.         Section 8.6                                            Statements
  3763.  
  3764.  
  3765.          Note  that  the  expr_list of a 'case' statement is evaluated at
  3766.         execution time and it is possible for some 'case'  expr_lists  to
  3767.         never  be  evaluated.  Thus  side  effects from the evaluation of
  3768.         'case' expr_lists should not be relied upon. This is particularly
  3769.         true  where  execution falls through from one 'case' statement to
  3770.         the next.
  3771.         
  3772.          If the expr_list of a 'case' statement evaluates  to  a  regular
  3773.         expression,  then  two  built-in variables are set when the match
  3774.         operation is performed: CLENGTH and CSTART. CLENGTH is set to the
  3775.         length  of  the matching string found (or zero) and CSTART is set
  3776.         to the starting position of the matching string found (or  zero).
  3777.         CLENGTH and CSTART are completely analogous to RLENGTH and RSTART
  3778.         set for the 'match' function and MLENGTH and MSTART for the match
  3779.         operators, '~~' and '!~'.
  3780.         
  3781.          The   'default'  keyword  is  provided  in  analogy  to  C.  The
  3782.         statements following the 'default' statement are executed if  the
  3783.         'switch'  expr_list  matches  no  'case' expr_list. The 'default'
  3784.         statement may be combined with other 'case' statements.  It  need
  3785.         not be the last statement as shown.
  3786.         
  3787.         E8.7 LoopsF
  3788.         
  3789.          QTAwk has four forms of loop control statements:
  3790.         
  3791.         1.  for ( exp1 ; exp2 ; exp3 ) stmt
  3792.         2.  for ( var in array ) stmt
  3793.         3.  while ( exp ) stmt
  3794.         4.  do stmt while ( exp );
  3795.         
  3796.         E8.8 'while'F
  3797.         
  3798.          The 'while' statement has the form:
  3799.         
  3800.         
  3801.          while ( expr_list ) stmt
  3802.         
  3803.          the  expr_list  is  evaluated and if TRUE 'stmt' is executed and
  3804.         expr_list is re-evaluated. This cycle continues  until  expr_list
  3805.         evaluates  to  FALSE,  at which point the cycle is terminated and
  3806.         execution resumes with the utility after 'stmt'.
  3807.         
  3808.         E8.9 'for'F
  3809.         
  3810.          The 'for' statement has two forms:
  3811.  
  3812.  
  3813.         QTAwk                        - 8-7 -                        QTAwk
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.         Section 8.9                                            Statements
  3821.  
  3822.  
  3823.         1.  for ( exp1 ; exp2 ; exp3 ) stmt
  3824.         2.  for ( var in array ) stmt
  3825.         
  3826.          In the first form  the  following  sequence  of  operations  are
  3827.         performed:
  3828.         1.  The expressions in expr_list1 are evaluated,
  3829.         2.  The expressions in expr_list2 are evaluated,
  3830.         3.  The  action  taken  is  depenedent upon whether the resultant
  3831.             value of expr_list2 is true or false:
  3832.             a)  TRUE
  3833.                 1:  Execute 'stmt', which may be  a  compound  statement.
  3834.                 2:  Execute the expressions in expr_list3.
  3835.                 3:  Control returns to item 2. above.
  3836.             b)  FALSE - terminate loop
  3837.         
  3838.         
  3839.          The  second  form may also be used for multi-dimensional arrays:
  3840.         
  3841.         for ( var in array[s_expr_list]...[s_expr_list] ) stmt
  3842.         
  3843.          For each subscript in the next higher index level in  the  array
  3844.         reference,  var is set to the index value and 'stmt' is executed.
  3845.         'stmt' may be a compound statement. For a multidimensional array,
  3846.         the  second  form  may  be  used to loop sequentially through the
  3847.         indices  of  the  next  higher  index  level.  Thus  for  a   two
  3848.         dimensional array:
  3849.         
  3850.         for ( i in A )
  3851.             for ( j in A[i] )
  3852.         
  3853.          will loop through the indices in the array in row order.
  3854.         
  3855.         E8.10 'do'/'while'F
  3856.         
  3857.          The form of the 'do'/'while' statement is:
  3858.         
  3859.          do stmt while ( expr_list );
  3860.         
  3861.          'stmt'  is  executed,  expr_list evaluated and if TRUE 'stmt' is
  3862.         executed again else the loop is terminated. Note that  'stmt'  is
  3863.         executed at least once.
  3864.         
  3865.         E8.11 'local'F
  3866.         
  3867.          The  'local'  keyword  is  used  to  define  variables  within a
  3868.         compound statement that are local to the compound  statement  and
  3869.  
  3870.  
  3871.         QTAwk                        - 8-8 -                        QTAwk
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.         Section 8.11                                           Statements
  3879.  
  3880.  
  3881.         that  disappear when the statement is exited. The 'local' keyword
  3882.         may be used within any  compound  statement,  but  is  especially
  3883.         useful  in  user-defined  functions as described later. Variables
  3884.         defined with the 'local' keyword may be assigned an initial value
  3885.         in  the  statement  and  multiple variables may be defined with a
  3886.         single statement. If a variable is not assigned an initial value,
  3887.         it  is  initialized  to  zero  and the null string just as global
  3888.         variables are initialized.
  3889.         
  3890.          Thus:
  3891.         
  3892.          local i, j = 12, k = substr(str,5);
  3893.         
  3894.          will define three variables  local  to  the  enclosing  compound
  3895.         statement:
  3896.         1.  i initialized to zero/null string,
  3897.         2.  j initialized to 12, and
  3898.         3.  k initialized to a substring of the variable 'str'
  3899.         
  3900.          Local variables initialized explicitly in 'local' statements may
  3901.         be initialized to constants,  the  values  of  global  variables,
  3902.         values   returned  by  built-in  functions,  values  returned  by
  3903.         user-defined functions or previously defined local variables.  If
  3904.         the  value is set to that of a previously defined local variable,
  3905.         the variable may not be defined in the  same  'local'  statement.
  3906.         Thus:
  3907.         
  3908.         local k = 5;
  3909.         local j = k;
  3910.         
  3911.          is correct, but
  3912.         
  3913.         local k = 5, j = k;
  3914.         
  3915.          is not. In the latter case QTAwk will quietly assume that the k,
  3916.         to which j is assigned, is a global variable.
  3917.         
  3918.         E8.12 'endfile'F
  3919.         
  3920.          The 'endfile' keyword causes the utility to behave as if the end
  3921.         of  the  current input file has been reached. Any 'FINAL' actions
  3922.         are executed, if any input files remain to be processed from  the
  3923.         command  line,  the  next is opened for processing. If no further
  3924.         input files  remain  to  be  processed,  any  'END'  actions  are
  3925.         executed.
  3926.         
  3927.  
  3928.  
  3929.         QTAwk                        - 8-9 -                        QTAwk
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.         Section 8.13                                           Statements
  3937.  
  3938.  
  3939.         E8.13 'break'F
  3940.         
  3941.          This  keyword  will  terminate  the  execution  of the enclosing
  3942.         'while', 'for', 'do'/'while' loop or break execution in  cascaded
  3943.         'case' statements.
  3944.         
  3945.         E8.14 'continue'F
  3946.         
  3947.          This keyword will cause execution to jump to just after the last
  3948.         statement in the loop body and execute the next iteration of  the
  3949.         enclosing   loop.   The   loop  may  be  any  'for',  'while'  or
  3950.         'do'/'while'.
  3951.         
  3952.         E8.15 'exit opt_expr_list'F
  3953.         
  3954.          This statement causes the utility to behave as if the end of the
  3955.         current  input  file  had  been  reached. Any further input files
  3956.         specified are ignored. If there are any  FINAL  or  END  actions,
  3957.         they are executed.
  3958.         
  3959.          If  encountered in a FINAL action, the action is terminated, any
  3960.         further input files are ignored and any END actions are executed.
  3961.         
  3962.          If  encountered in an END action, the execution of the action is
  3963.         terminated and utility execution is terminated.
  3964.         
  3965.          The optional expr_list is  evaluated  and  the  resultant  value
  3966.         returned  to DOS upon termination by QTAwk as the exit status. If
  3967.         no expr_list is present,  or  no  'exit'  statement  encountered,
  3968.         QTAwk returns a value of zero for the exit status.
  3969.         
  3970.         E8.16 'return opt_expr_list'F
  3971.         
  3972.          This  statement  will  cause  execution  to  return  from a user
  3973.         defined function. If the optional expr_list  is  present,  it  is
  3974.         evaluated  and  the  resultant  value  returned as the functional
  3975.         value.
  3976.         
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.         QTAwk                       - 8-10 -                        QTAwk
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.         Section 9.0                                    Built-in Functions
  3995.  
  3996.  
  3997.         E-9.0 BUILT-IN FUNCTIONSF-Ç
  3998.         
  3999.          QTAwk offers a rich set of  built-in  arithmetic,  string,  I/O,
  4000.         array  and  system  functions.  The  array  of built-in functions
  4001.         available has been extended over that available with Awk. The I/O
  4002.         functions have been changed to match the functional syntax of all
  4003.         other built-in and user defined functions.
  4004.         
  4005.         E9.1 Arithmetic FunctionsF
  4006.         
  4007.          QTAwk offers the following built-in arithmetic functions.  Those
  4008.         marked with an asterisk, '*', are new to QTAwk:
  4009.         
  4010.         1.  acos(x)  ==>  return  arc-cosine  of  x (refer to the DEGREES
  4011.             built-in variable).
  4012.             
  4013.         2.  asin(x) ==> return  arc-sine  of  x  (refer  to  the  DEGREES
  4014.             built-in variable).
  4015.             
  4016.         3.  atan2(y,x)  ==>  return arc-tangent of y/x, -π to π (refer to
  4017.             the DEGREES built-in variable).
  4018.             
  4019.         4.  cos(x) ==> return cosine of x (refer to the DEGREES  built-in
  4020.             variable).
  4021.             
  4022.         5.  * cosh(x) ==> return hyperbolic cosine of x
  4023.             
  4024.         6.  exp(x) ==> return e^x
  4025.             
  4026.         7.  * fract(x) ==> return fractional portion of x
  4027.             
  4028.         8.  int(x) ==> return integer portion of x
  4029.             
  4030.         9.  log(x) ==> return natural (base e) logarithm of x
  4031.             
  4032.         10.  * log10(x) ==> return base 10 logarithm of x
  4033.             
  4034.         11.  * pi() ==> return pi
  4035.             
  4036.         12.  * pi ==> return pi
  4037.             
  4038.         13.  rand() ==> return random number r, 0 <= r < 1
  4039.             
  4040.         14.  sin(x)  ==>  return sine of x (refer to the DEGREES built-in
  4041.             variable).
  4042.             
  4043.  
  4044.  
  4045.         QTAwk                        - 9-1 -                        QTAwk
  4046.  
  4047.  
  4048.  
  4049.  
  4050.  
  4051.  
  4052.         Section 9.1                                    Built-in Functions
  4053.  
  4054.  
  4055.         15.  * sinh(x) ==> return hyperbolic sine of x
  4056.             
  4057.         16.  sqrt(x) ==> return square root of x
  4058.             
  4059.         17.  srand(x) ==> set x as new seed for rand()
  4060.             
  4061.         18.  srand() ==> set current system time as new seed  for  rand()
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.         QTAwk                        - 9-2 -                        QTAwk
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.         Section 9.2                                    Built-in Functions
  4111.  
  4112.  
  4113.         E9.2 String FunctionsF
  4114.         
  4115.          QTAwk  offers  the following built-in string handling functions.
  4116.         Those marked with an asterisk, '*', are new to QTAwk:
  4117.         
  4118.         1.  * center(s,w)  ==>  return  string  s  centered  in  w  blank
  4119.             characters.
  4120.             
  4121.         2.  * center(s,w,c)  ==>  return  string  s  centered  in  w  'c'
  4122.             characters.
  4123.             
  4124.         3.  * copies(s,n) ==> return n copies of string s.
  4125.             
  4126.         4.  * deletec(s,p,n)  ==>  return  string  s  with  n  characters
  4127.             deleted starting at position p.
  4128.             
  4129.         5.  gsub(r,s)  ==>  substitute  s  for strings matched by regular
  4130.             expression, r, globally in $0, return number of substitutions
  4131.             made.
  4132.             
  4133.         6.  gsub(r,s,t)  ==>  substitute s for strings matched by regular
  4134.             expression,  r,  globally  in  string  t,  return  number  of
  4135.             substitutions made.
  4136.             
  4137.         7.  index(s1,s2)  ==>  return position of string s2 in string s1.
  4138.             
  4139.         8.  * insert(s1,s2,p)  ==>  return  string  formed  by  inserting
  4140.             string s2 into string s1 starting at position p.
  4141.             
  4142.         9.  * justify(a,n,w)  ==>  return string w characters long formed
  4143.             by justifying n elements of array a padded with blanks. If  n
  4144.             elements  of array a with at least one blank between elements
  4145.             would exceed width w, then the number of  elements  justified
  4146.             is reduced to fit in the length w.
  4147.             
  4148.         10.  * justify(a,n,w,c)  ==>  return  string  w  characters  long
  4149.             formed by justifying  n  elements  of  array  a  padded  with
  4150.             character 'c'. If n elements of array a with at least one 'c'
  4151.             character between elements would exceed  width  w,  then  the
  4152.             number  of elements justified is reduced to fit in the length
  4153.             w.
  4154.             
  4155.         11.  length ==> return number of characters in $0.
  4156.             
  4157.         12.  length() ==> return number of characters in $0.
  4158.             
  4159.  
  4160.  
  4161.         QTAwk                        - 9-3 -                        QTAwk
  4162.  
  4163.  
  4164.  
  4165.  
  4166.  
  4167.  
  4168.         Section 9.2                                    Built-in Functions
  4169.  
  4170.  
  4171.         13.  length(s) ==> return  number  of  characters  in  string  s.
  4172.             
  4173.         14.  match(s,r)  ==>  return  true/false  if  string s contains a
  4174.             substring matched by r. Set RLENGTH to  length  of  substring
  4175.             matched  (or  zero) and RSTART to start position of substring
  4176.             matched (or zero).
  4177.             
  4178.         15.  * overlay(s1,s2,p) ==> return string  formed  by  overlaying
  4179.             string  s2  on  string  s1 starting at position p. May extend
  4180.             length of s1. If p > length(s1), s1  padded  with  blanks  to
  4181.             appropriate length.
  4182.             
  4183.         16.  * remove(s,c)  ==>  return string formed by removing all 'c'
  4184.             characters from string s
  4185.             
  4186.         17.  * replace(s) ==>  return  string  formed  by  replacing  all
  4187.             repeated expressions, {n1,n2}, and named expressions, {name},
  4188.             in string s. Same operation performed  for  strings  used  as
  4189.             regular expressions.
  4190.             
  4191.         18.  * sdate(fmt)   ==>  return  current  system  date  formatted
  4192.             according to integer value of fmt.
  4193.             mname == full month name
  4194.             amname == abbreviated month name (3 characters)
  4195.             wkday == full day name
  4196.             aday == abbreviated day name (3 characters)
  4197.             integer value of fmt:
  4198.             0 - mm/dd/yy
  4199.             1 - mm/dd/yyyy
  4200.             2 - dd/mm/yy
  4201.             3 - dd/mm/yyyy
  4202.             4 - amname dd, yyyy
  4203.             5 - mname dd, yyyy
  4204.             6 - aday mm/dd/yyyy
  4205.             7 - wkday mm/dd/yyyy
  4206.             8 - aday, amname dd, yyyy
  4207.             9 - wkday, mname dd, yyyy
  4208.             10 - return amname
  4209.             11 - return month name
  4210.             12 - return aday
  4211.             13 - return wkday
  4212.             14 - return current system date in form  yymmdd  for  sorting
  4213.             15 - return number of days this century
  4214.             16 - return number of days this year
  4215.             a  value  greater  than  16, gives a run-time error and QTAwk
  4216.             halts execution.
  4217.  
  4218.  
  4219.         QTAwk                        - 9-4 -                        QTAwk
  4220.  
  4221.  
  4222.  
  4223.  
  4224.  
  4225.  
  4226.         Section 9.2                                    Built-in Functions
  4227.  
  4228.  
  4229.         19.  split(s,a)  ==>  split  string  s  into  array  a  on  field
  4230.             separator FS. Return number of fields. The same rules applied
  4231.             to FS for splitting the current input record apply to the use
  4232.             of fs in splitting s into a.
  4233.             
  4234.         20.  split(s,a,fs)  ==>  split  string  s  into  array a on field
  4235.             separator fs. Return number of fields. The same rules applied
  4236.             to FS for splitting the current input record apply to the use
  4237.             of fs in splitting s into a.
  4238.             
  4239.         21.  * srange(c1,c2) ==> return string formed from  character  by
  4240.             concatenating  characters from c1 to c2 inclusive. If c2 < c1
  4241.             null string returned. Thus,
  4242.             
  4243.             srange('a','k') == "abcdefghijk".
  4244.             
  4245.         22.  * srev(s) ==> return string formed by  reversing  string  s.
  4246.             
  4247.             srev(srange('a','k')) == "kjihgfedcba".
  4248.             
  4249.         23.  * stime(fmt)   ==>  return  current  system  time  formatted
  4250.             according to the integer value of fmt.
  4251.             0 - hh:mm:ss:00, 0 <= hh <= 24
  4252.             1 - hh:mm:ss, 0 <= hh <= 24
  4253.             2 - hh:mm, 0 <= hh <= 24
  4254.             3 - hh:mm:ss am/pm
  4255.             4 - hh:mm am/pm
  4256.             a value greater than 4, gives  a  run-time  error  and  QTAwk
  4257.             halts execution.
  4258.             
  4259.         24.  * stran(s)   ==>   return   string   formed  by  translating
  4260.             characters in string s matching characters in string value of
  4261.             built-in  variable, TRANS_FROM, to corresponding character in
  4262.             string  value  of  built-in   variable,   TRANS_TO.   if   no
  4263.             corresponding character in TRANS_TO, then replace with blank.
  4264.             TRANS_FROM and TRANS_TO intially set to:
  4265.             
  4266.             TRANS_FROM = srange('A','Z');
  4267.             
  4268.             TRANS_TO = srange('a','z');
  4269.             
  4270.         25.  * stran(s,st)  ==>  return  string  formed  by   translating
  4271.             characters in string s matching characters in string value of
  4272.             built-in variable, TRANS_FROM, to corresponding character  in
  4273.             st.  if  no  corresponding  character in st then replace with
  4274.             blank.
  4275.  
  4276.  
  4277.         QTAwk                        - 9-5 -                        QTAwk
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.         Section 9.2                                    Built-in Functions
  4285.  
  4286.  
  4287.         26.  * stran(s,st,sf) ==> return  string  formed  by  translating
  4288.             characters   in   string  s  matching  characters  in  sf  to
  4289.             corresponding character in st. if no corresponding  character
  4290.             in st then replace with blank.
  4291.             
  4292.         27.  * strim(s)  ==> return string formed by trimming leading and
  4293.             tailing white  space  from  string  s.  Leading  white  space
  4294.             matches  the  regular  expression  /^[\s\t]+/.  Tailing white
  4295.             space matches the regular expression /[\s\t]+$/.
  4296.             
  4297.         28.  * strim(s,le) ==> return string formed  by  trimming  string
  4298.             matching  le and tailing white space from string s. Differing
  4299.             actions are taken depending the type of le:
  4300.             
  4301.             ────────────┬────────────────────────────────────────────────────────
  4302.             le type     │  action
  4303.             ────────────┼────────────────────────────────────────────────────────
  4304.             regular     │
  4305.             expression  │  delete  first string  matching  regular    expression
  4306.                     │
  4307.             string        │  convert to  regular expression  and delete  first
  4308.                     │  matching string
  4309.                     │
  4310.             single        │
  4311.             character   │ delete  all leading characters  equal to 'le'
  4312.                     │
  4313.             non-zero    │
  4314.             numeric     │ delete leading white space matching /^[\s\t]+/
  4315.                     │
  4316.             zero        │
  4317.             numeric     │ ignore
  4318.             ────────────┴────────────────────────────────────────────────────────
  4319.             
  4320.              strim(s,TRUE) is equivalent to the form strim(s)
  4321.             
  4322.              The following all delete the leading dashes from  the  given
  4323.             string:
  4324.             
  4325.              strim("------ remove leading -------",/^-+/);
  4326.             strim("------ remove leading -------",/-+/);
  4327.             strim("------ remove leading -------",'-');
  4328.             ==> "remove leading -------"
  4329.             
  4330.         29.  * strim(s,le,te)   ==>  return  string  formed  by  trimming
  4331.             string matching le and string matching te from  s.  'le'  and
  4332.             'te'  may  be  a  regular  expression,  a  string,  a  single
  4333.  
  4334.  
  4335.         QTAwk                        - 9-6 -                        QTAwk
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.         Section 9.2                                    Built-in Functions
  4343.  
  4344.  
  4345.             character or a numeric. Differing actions are taken depending
  4346.             the type of le and te:
  4347.             
  4348.             ────────────┬────────────────────────────────────────────────────────
  4349.             le/te type  │  action
  4350.             ────────────┼────────────────────────────────────────────────────────
  4351.             regular     │
  4352.             expression  │  delete  first string  matching  regular    expression
  4353.                     │
  4354.             string        │  convert to  regular expression  and delete  first
  4355.                     │  matching string
  4356.                     │
  4357.             single        │
  4358.             character   │ delete  all leading/tailing characters  equal to
  4359.                     │ 'le'/'te' respectively
  4360.                     │
  4361.             non-zero    │
  4362.             numeric     │ delete leading/tailing white space matching /^[\s\t]+/
  4363.                     │ or /[\s\t]+$/ respectively
  4364.                     │
  4365.             zero        │
  4366.             numeric     │ ignore
  4367.             ────────────┴────────────────────────────────────────────────────────
  4368.             
  4369.              strim(s,TRUE,TRUE)   is  equivalent  to  the  form  strim(s)
  4370.             
  4371.             
  4372.              strim("======remove  leading  and   tailing-------",'=','-')
  4373.             or
  4374.             strim("======remove  leading  and  tailing-------",/^=+/,'-')
  4375.             or
  4376.             strim("======remove  leading  and  tailing-------",'+',/-+$/)
  4377.             or
  4378.             strim("======remove  leading and tailing-------",/^=+/,/-+$/)
  4379.             ==> "remove leading and tailing"
  4380.             
  4381.              strim("======remove leading-------",'=',FALSE)
  4382.             ==> "remove leading-------"
  4383.             
  4384.              strim("======remove tailing-------",FALSE,'-')
  4385.             ==> "======remove tailing"
  4386.             
  4387.         30.  * strlwr(s) ==> return string s  translated  to  lower-case.
  4388.             
  4389.         31.  * strupr(s)  ==>  return  string s translated to upper-case.
  4390.             
  4391.  
  4392.  
  4393.         QTAwk                        - 9-7 -                        QTAwk
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.         Section 9.2                                    Built-in Functions
  4401.  
  4402.  
  4403.         32.  sub(r,s) ==> substitute s for  leftmost  string  matched  by
  4404.             regular  expression, r, in $0, return number of substitutions
  4405.             made (0/1).
  4406.             
  4407.         33.  sub(r,s,t) ==> substitute s for leftmost string  matched  by
  4408.             regular  expression,  r, in t, return number of substitutions
  4409.             made (0/1).
  4410.             
  4411.         34.  substr(s,p) ==> return string formed from suffix  of  string
  4412.             s starting at position p.
  4413.             
  4414.         35.  substr(s,p,n)  ==> return string formed from n characters of
  4415.             string s starting at position p.  If  n  ==  1,  a  character
  4416.             constant is returned.
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.  
  4438.  
  4439.  
  4440.  
  4441.  
  4442.  
  4443.  
  4444.  
  4445.  
  4446.  
  4447.  
  4448.  
  4449.  
  4450.  
  4451.         QTAwk                        - 9-8 -                        QTAwk
  4452.  
  4453.  
  4454.  
  4455.  
  4456.  
  4457.  
  4458.         Section 9.3                                    Built-in Functions
  4459.  
  4460.  
  4461.         E9.3 I/O FunctionsF
  4462.         
  4463.          QTAwk  offers the following built-in I/O functions. Those marked
  4464.         with an asterisk, '*', differ from those in AWK.
  4465.         
  4466.         1.  * getline();
  4467.             or
  4468.             * getline ; ==> reads next record  from  current  input  file
  4469.             into  $0.  Sets fields, NF, NR and FNR. Returns the number of
  4470.             characters read, 0 if end-of-file was encountered or -1 if an
  4471.             error occurred.
  4472.             
  4473.         2.  * getline(v);
  4474.             or
  4475.             * getline  v  ; ==> reads next record from current input file
  4476.             into variable v. Sets NR  and  FNR.  Returns  the  number  of
  4477.             characters read, 0 if end-of-file was encountered or -1 if an
  4478.             error occurred.
  4479.             
  4480.         3.  * fgetline(F) ==> reads next record  from  file  F  into  $0.
  4481.             Sets  fields and NF. Returns the number of characters read, 0
  4482.             if end-of-file was encountered or -1 if  an  error  occurred.
  4483.             
  4484.         4.  * fgetline(F,v)  ==>  reads  next  record  from  file  F into
  4485.             variable v. Returns the  number  of  characters  read,  0  if
  4486.             end-of-file  was  encountered  or  -1  if  an error occurred.
  4487.             
  4488.         5.  * fprint(F);
  4489.             or
  4490.             * fprint F ; ==> prints $0  to  file  'F'  followed  by  ORS.
  4491.             Returns number of characters printed.
  4492.             
  4493.         6.  * fprint(F,...);
  4494.             or
  4495.             * fprint  F,...  ;  ==>  prints expressions in the expr_list,
  4496.             '...', to the file 'F',  each  separated  by  OFS.  The  last
  4497.             expression  is  followed by ORS. Returns number of characters
  4498.             printed.
  4499.             
  4500.         7.  fprintf(F,fmt,...) ==> print  expr_list,  ...,  to  file  'F'
  4501.             according  to  format 'fmt'. Returns the number of characters
  4502.             printed.
  4503.             
  4504.         8.  print();
  4505.             or
  4506.             print ; ==> prints $0 to standard  output  file  followed  by
  4507.  
  4508.  
  4509.         QTAwk                        - 9-9 -                        QTAwk
  4510.  
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.         Section 9.3                                    Built-in Functions
  4517.  
  4518.  
  4519.             ORS. Returns number of characters printed.
  4520.             
  4521.         9.  print(...);
  4522.             or
  4523.             print  ... ; ==> prints expressions in the expr_list, ..., to
  4524.             the standard output file, each separated  by  OFS.  The  last
  4525.             expression  is  followed by ORS. Returns number of characters
  4526.             printed.
  4527.             
  4528.         10.  printf(fmt,...)  ==>  print  expr_list,  ...,  to   standard
  4529.             output  file  according  to  format,  fmt.  Returns number of
  4530.             characters printed.
  4531.             
  4532.         11.  sprintf(fmt,...) ==>  return  string  formed  by  formatting
  4533.             expr_list, ... , according to format, fmt.
  4534.             
  4535.         12.  close(F) ==> close file F.
  4536.         
  4537.          The  use  of  the re-direction and pipeline operators, '<', '>',
  4538.         '>>' and '|', have been discontinued as error prone. The  use  of
  4539.         the syntax:
  4540.         
  4541.                               { print $1, $2 > $3 }                      
  4542.         
  4543.          has been replaced by the 'fprint' function:
  4544.         
  4545.                               { fprint($3,$1,$2); }                      
  4546.         
  4547.          or
  4548.         
  4549.                               { fprint $3,$1,$2; }                       
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.  
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.  
  4565.  
  4566.  
  4567.         QTAwk                       - 9-10 -                        QTAwk
  4568.  
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.         Section 9.4                                    Built-in Functions
  4575.  
  4576.  
  4577.         E9.4 Miscellaneous FunctionsF
  4578.         
  4579.         E9.4.1 Expression TypeF
  4580.         
  4581.          *e_type(expr) ==> returns the type of 'expr'. Function evaluates
  4582.         the expression 'expr' and returns the type of the  final  result.
  4583.         The return is an integer defining the type:
  4584.         
  4585.         Return      Type                                                 
  4586.         0           Un-initialized (returned when 'expr' is a variable which
  4587.                                     has not had a value assigned to it. Also
  4588.                                     if not been assigned since acted on  
  4589.                                     by "deleta" statement)               
  4590.         1           Regular Expression Value                             
  4591.         2           String Value                                         
  4592.         3           Single Character Value                               
  4593.         4           Integral Value                                       
  4594.         5           Floating Point Value                                 
  4595.         
  4596.         local lvar;
  4597.         e_type(lvar)          ==> 0                                      
  4598.         e_type(/string test/) ==> 1                                      
  4599.         e_type("string test") ==> 2                                      
  4600.         e_type('a')           ==> 3                                      
  4601.         e_type(45)            ==> 4                                      
  4602.         e_type(45.6)          ==> 5                                      
  4603.         e_type(45.6 ∩ "")     ==> 2                                      
  4604.         e_type("45.6" + 0.0)  ==> 5                                      
  4605.         e_type("45" + 0)      ==> 4                                      
  4606.         
  4607.         
  4608.         
  4609.         E9.4.2 Execute StringF
  4610.         
  4611.          QTAwk  offers  two  forms of a function to execute QTAwk dynamic
  4612.         expressions or statements. The first form will execute strings as
  4613.         QTAwk  expressions  or  statements. The second will execute array
  4614.         elements as QTAwk expressions or elements.
  4615.         
  4616.          *execute(s[,se[,rf]]) ==> execute string s as an QTAwk statement
  4617.         or  expression.  If  se  == TRUE, then string s is executed as an
  4618.         expression and the resultant value is returned by  the  'execute'
  4619.         function.  If  se  ==  FALSE,  then  string  s  is  executed as a
  4620.         statement and the constant value of one, 1, is returned.  The  se
  4621.         parameter  is  optional  and  defaults  to FALSE. Any built-in or
  4622.         user-defined function may be executed in the  'execute'  function
  4623.  
  4624.  
  4625.         QTAwk                       - 9-11 -                        QTAwk
  4626.  
  4627.  
  4628.  
  4629.  
  4630.  
  4631.  
  4632.         Section 9.4.2                                  Built-in Functions
  4633.  
  4634.  
  4635.         except  the  'execute'  function  itself.  New  variables  may be
  4636.         defined as well as new constant strings and regular  expressions.
  4637.         
  4638.          The  optional  rf  parameter is the error recovery flag. If rf =
  4639.         FALSE (the default value), an error  encountered  in  parsing  or
  4640.         executing  the string s will cause QTAwk to issue the appropriate
  4641.         error message and  halt  execution.  If  rf  ==  TRUE,  an  error
  4642.         encountered in parsing or executing the string s will cause QTAwk
  4643.         to issue the appropriate error message,  discontinue  parsing  or
  4644.         execution  of the string and continue executing the current QTAwk
  4645.         utility. Attempting to execute the 'execute' function from within
  4646.         the  'execute'  function  is  a fatal error and will always cause
  4647.         QTAwk to halt execution.
  4648.         
  4649.          The following string can be executed as either an expression  or
  4650.         statement:
  4651.         
  4652.                            nvar = "power2 = 2 ^ 31;";                    
  4653.         
  4654.          If executed as an expression:
  4655.         
  4656.         print execute(nvar,1);
  4657.         
  4658.          the output will be: 2147483648
  4659.         
  4660.          If executed as a statement:
  4661.         
  4662.         print execute(nvar,0);
  4663.         
  4664.         or
  4665.         
  4666.         print execute(nvar);
  4667.         
  4668.          the output will be: 1
  4669.         
  4670.          Multiple  statements/expressions may be executed with a compound
  4671.         statement of the form:
  4672.         
  4673.          pvar = "{ pow8 = 2 ^ 8; pow16 = 2 ^ 16; pow31  =  2  ^  31;  }";
  4674.         
  4675.          Then
  4676.         
  4677.         execute(pvar,0);
  4678.         
  4679.         or
  4680.         
  4681.  
  4682.  
  4683.         QTAwk                       - 9-12 -                        QTAwk
  4684.  
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.         Section 9.4.2                                  Built-in Functions
  4691.  
  4692.  
  4693.         execute(pvar);
  4694.         
  4695.          will set the three variables:
  4696.         
  4697.         1.  pow8
  4698.         2.  pow16
  4699.         3.  pow31
  4700.         
  4701.          even  if  the  variables  were  not  previously  defined. If the
  4702.         variables were not previously defined, they  will  added  to  the
  4703.         list of the utility variables.
  4704.         
  4705.          Note that attempting to execute pvar as an expression:
  4706.         
  4707.         execute(pvar,1);
  4708.         
  4709.          will  result  in the error message "Undefined Symbol". All three
  4710.         expressions may be executed, as an expression, by the use of  the
  4711.         sequence operator in the following manner:
  4712.         
  4713.          pvar = "pow8 = 2 ^ 8 , pow16 = 2 ^ 16 , pow31 = 2 ^ 31;";
  4714.         
  4715.          *execute(a[,se[,rf]])  ==> execute the elements of array a as an
  4716.         QTAwk statement or expression. The se and rf parameters have  the
  4717.         same  function  and  default  values  as  above. For example, the
  4718.         compound statement contained in pvar above may  be  split  amoung
  4719.         the elements of an array:
  4720.         
  4721.         avar[1] = "{";
  4722.         avar[2] = "pow8 = 2 ^ 8;";
  4723.         avar[3] = "pow16 = 2 ^ 16;";
  4724.         avar[4] = "pow31 = 2 ^ 31;";
  4725.         avar[5] = "}";
  4726.         
  4727.          and executed as:
  4728.         
  4729.         execute(avar);
  4730.         
  4731.         or
  4732.         
  4733.         execute(avar,0);
  4734.         
  4735.         
  4736.         
  4737.         E9.4.3 Array FunctionF
  4738.         
  4739.  
  4740.  
  4741.         QTAwk                       - 9-13 -                        QTAwk
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.  
  4748.         Section 9.4.3                                  Built-in Functions
  4749.  
  4750.  
  4751.          QTAwk offers the following built-in array function.
  4752.         
  4753.          rotate(a) - the values of the array are rotated.
  4754.         The  value  of  the  first  element goes to the last element, the
  4755.         second to the first, third to the second, etc. If the  array  has
  4756.         the following elements:
  4757.         
  4758.         1.  a[1] = 1
  4759.         2.  a[2] = 2
  4760.         3.  a[3] = 3
  4761.         4.  a[4] = 4
  4762.         
  4763.          then rotate(a) will have the result:
  4764.         
  4765.         1.  a[1] = 2
  4766.         2.  a[2] = 3
  4767.         3.  a[3] = 4
  4768.         4.  a[4] = 1
  4769.         
  4770.          It  is  not  necessary  to  specify  one-dimensional arrays. If:
  4771.         
  4772.         1.  a[1][1] = 1
  4773.         2.  a[1][2] = 2
  4774.         3.  a[1][3] = 3
  4775.         4.  a[1][4] = 4
  4776.         
  4777.          Then rotate(a[1]) will produce the result:
  4778.         
  4779.         1.  a[1][1] = 2
  4780.         2.  a[1][2] = 3
  4781.         3.  a[1][3] = 4
  4782.         4.  a[1][4] = 1
  4783.         
  4784.         
  4785.         
  4786.         E9.4.4 System Control FunctionF
  4787.         
  4788.         1.  system(e) ==> executes the system command  specified  by  the
  4789.             string value of the expression e.
  4790.         
  4791.         
  4792.         
  4793.         E9.4.5 Variable AccessF
  4794.         
  4795.          There  are  two  built-in  functions  available  for  access  to
  4796.         variables. The first, "pd_sym",  accesses  pre-defined  variables
  4797.  
  4798.  
  4799.         QTAwk                       - 9-14 -                        QTAwk
  4800.  
  4801.  
  4802.  
  4803.  
  4804.  
  4805.  
  4806.         Section 9.4.5                                  Built-in Functions
  4807.  
  4808.  
  4809.         and the second, ud_sym, accesses user-defined variables. Each has
  4810.         two forms:
  4811.         
  4812.         pd_sym(name_str)
  4813.         
  4814.         or
  4815.         
  4816.         pd_sym(name_num,name_str)
  4817.         
  4818.         1.  To access pre-defined variables, the  function  "pd_sym"  may
  4819.             be  used.  This  function  has  been  supplied  to  provide a
  4820.             pre-defined variable access function similar to the  function
  4821.             "ud_sym"  for accessing user-defined variables. The forms and
  4822.             returns are similar.
  4823.             
  4824.         2.  To access user-defined variables where the variable name  may
  4825.             not  be  known  in  advance,  the  function "ud_sym" has been
  4826.             supplied. The first form:
  4827.             
  4828.             ud_sym(name_expr)
  4829.             
  4830.              is useful in situations where the variable name is not known
  4831.             until  the  statement  is  to  be  executed.  In these cases,
  4832.             name_expr may be any expression or variable with  the  string
  4833.             value of the unknown variable. In this form, the string value
  4834.             of name_expr is used to access the variable.  ud_sym  returns
  4835.             the variable in question, if one exists with the string value
  4836.             passed.
  4837.             
  4838.              The functional return value may be used  in  any  expression
  4839.             just as the variable itself would. This includes operating on
  4840.             the return value with the array index operators, "[]".
  4841.             
  4842.              Note: This form may be used to access both local and  global
  4843.             variables.  If  both  a  local  and global variable have been
  4844.             defined with the desired  name  and  the  local  variable  is
  4845.             within scope, then the local variable is returned.
  4846.             
  4847.              The second form:
  4848.             
  4849.             ud_sym(name_expr,name_str)
  4850.             
  4851.              is useful in those situations where it may be impractical to
  4852.             use string values to access the variables, e.g., in a  "for",
  4853.             "while"  or  "do"  loop,  but  a numeric value can be used to
  4854.             access the variables.
  4855.  
  4856.  
  4857.         QTAwk                       - 9-15 -                        QTAwk
  4858.  
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.         Section 9.4.5                                  Built-in Functions
  4865.  
  4866.  
  4867.              The user variables are accessed in the order defined in  the
  4868.             user  utility  starting with one (1). If the integer value of
  4869.             name_expr exceeds the number of user-defined variables,  then
  4870.             a  non-variable  is  returned. The second parameter must be a
  4871.             variable. Upon return, this variable will have a string value
  4872.             equal to the name of the variable found or the null string if
  4873.             name_expr exceeds the number of user-defined  variables.  The
  4874.             return  value of this variable may be tested to assure that a
  4875.             variable was found.
  4876.             
  4877.              The functional return value may be used  in  any  expression
  4878.             just as the variable itself would. This includes operating on
  4879.             the return value with the array index operators, "[]".
  4880.             
  4881.              Note: This form may be used to access global variables ONLY.
  4882.             Local  variables  cannot  be  accessed  with this form of the
  4883.             function.
  4884.         
  4885.          The  following  short  function  will  return  the   number   of
  4886.         user-defined global variables:
  4887.         
  4888.         # function to return the current number of
  4889.         # GLOBAL variables defined in utility
  4890.         function var_number(display) {
  4891.             local cnt, j, jj;
  4892.         
  4893.             for ( cnt = 1, j = ud_sym(cnt,jj) ; jj ; j = ud_sym(++cnt,jj) )
  4894.                   if ( display ) print cnt ∩ " : " ∩ jj ∩ " ==>" ∩ j ∩ "<==";
  4895.             return cnt - 1;
  4896.         }
  4897.         
  4898.          The  following  function  may  be  called  with  the name of the
  4899.         variable desired. The value of the  variable  will  be  returned.
  4900.         Note  that  the  appropriate  variables  have been defined in the
  4901.         "BEGIN" action.
  4902.         
  4903.         BEGIN {
  4904.         #define the conversion variables
  4905.             _kilometers_to_statute_miles_ = 1.609344; # kilometers / mile (exact)
  4906.             _statute_miles_to_kilometers_ = 1/1.609344; # kilometers / mile (exact)
  4907.             _inches_to_centimeters_ = 2.54;
  4908.             _centimeters_to_inches_ = 1/2.54;
  4909.             _radians_to_degrees_ = 180/pi;
  4910.             _degrees_to_radians_ = pi/180;
  4911.         }
  4912.         # function to return the appropriate conversion
  4913.  
  4914.  
  4915.         QTAwk                       - 9-16 -                        QTAwk
  4916.  
  4917.  
  4918.  
  4919.  
  4920.  
  4921.  
  4922.         Section 9.4.5                                  Built-in Functions
  4923.  
  4924.  
  4925.         function conversion_factor(conversion_name) {
  4926.             local name = '_' ∩ conversion_name ∩ '_';
  4927.             return ud_sym(name);
  4928.         }
  4929.         
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.  
  4955.  
  4956.  
  4957.  
  4958.  
  4959.  
  4960.  
  4961.  
  4962.  
  4963.  
  4964.  
  4965.  
  4966.  
  4967.  
  4968.  
  4969.  
  4970.  
  4971.  
  4972.  
  4973.         QTAwk                       - 9-17 -                        QTAwk
  4974.  
  4975.  
  4976.  
  4977.  
  4978.  
  4979.  
  4980.  
  4981.  
  4982.  
  4983.  
  4984.  
  4985.  
  4986.  
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.         QTAwk                       - 9-18 -                        QTAwk
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.         Section 10.0                                 Format Specification
  5039.  
  5040.  
  5041.         E-10.0 FORMAT SPECIFICATIONF-Ç
  5042.         
  5043.          QTAwk follows the Draft ANSI C language standard for the  format
  5044.         string in the 'printf' and 'fprintf' functions except for the 'P'
  5045.         and  'n'  types,  which  are  not   supported   and   will   give
  5046.         unpredictable results.
  5047.         
  5048.          A format specification has the form:
  5049.         
  5050.                    %[flags][width][.precision][h | l | L]type            
  5051.         
  5052.          which is matched by the following regular expression:
  5053.         
  5054.                    /%{flags}?{width}?{precision}?[hlL]?{type}/           
  5055.         
  5056.          with:
  5057.         
  5058.         flags = /[-+\s#0]/;
  5059.         width = /([0-9]+|\*)/;
  5060.         precision = /(\.([0-9]+|\*))/;
  5061.         type = /[diouxXfeEgGcs]/;
  5062.         
  5063.          Each  field of the format specification is a single character or
  5064.         a  number  signifying  a  particular  format  option.  The   type
  5065.         character,  which  appears  after the last optional format field,
  5066.         enclosed in braces  '[..]',  determines  whether  the  associated
  5067.         argument  is  interpreted  as a character, a string, or a number.
  5068.         The simplest format specification contains only the percent  sign
  5069.         and  a  type  character  (for  example,  %s). The optional fields
  5070.         control other aspects of the formatting, as follows:
  5071.         
  5072.         1.  flags ==> Control justification of  output  and  printing  of
  5073.             signs,   blanks,   decimal   points,  octal  and  hexadecimal
  5074.             prefixes.
  5075.             
  5076.         2.  width  ==>  Control  minimum  number  of  characters  output.
  5077.             
  5078.         3.  precision  ==>  Controls maximum number of characters printed
  5079.             for all or part of the output field,  or  minimum  number  of
  5080.             digits printed for integer values.
  5081.             
  5082.         4.  h,  l,  L  ==>  Prefixes  that  determine  size  of  argument
  5083.             expected (this field is retained only for compatibility to  C
  5084.             format strings).
  5085.             
  5086.             a)  h  ==>  Used  as a prefix with the integer types d, i, o,
  5087.  
  5088.  
  5089.         QTAwk                       - 10-1 -                        QTAwk
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.         Section 10.0                                 Format Specification
  5097.  
  5098.  
  5099.                 x, and X to specify that the argument is  short  int,  or
  5100.                 with u to specify a short unsigned int
  5101.                 
  5102.             b)  l  ==  > Used as a prefix with d, i, o, x, and X types to
  5103.                 specify that the argument is  long  int,  or  with  u  to
  5104.                 specify  a  long unsigned int; also used as a prefix with
  5105.                 e, E, f, g, and G types to specify a double, rather  than
  5106.                 a float
  5107.                 
  5108.             c)  L  ==>  Used  as a prefix with e, E, f, g, and G types to
  5109.                 specify a long double
  5110.         
  5111.          If a percent sign, '%', is followed by a character that  has  no
  5112.         meaning  as a format field, the character is simply copied to the
  5113.         output. For example, to print a percent-sign character, use "%%".
  5114.         
  5115.         E10.1 Output TypesF
  5116.         
  5117.          Type characters:
  5118.         
  5119.         1.  d ==> integer, Signed decimal integer
  5120.         2.  i ==> integer, Signed decimal integer
  5121.         3.  u ==> integer, Unsigned decimal integer
  5122.         4.  o ==> integer, Unsigned octal integer
  5123.         5.  x  ==>  integer, Unsigned hexadecimal integer, using "abcdef"
  5124.         6.  X ==> integer, Unsigned hexadecimal integer,  using  "ABCDEF"
  5125.         7.  f ==> float, Signed value having the form
  5126.             
  5127.                                     [-]dddd.dddd                         
  5128.             
  5129.              where  dddd  is  one  or  more decimal digits. The number of
  5130.             digits before the decimal point depends on the  magnitude  of
  5131.             the  number, and the number of digits after the decimal point
  5132.             depends on the requested precision.
  5133.             
  5134.         8.  e ==> float, Signed value having the form
  5135.             
  5136.                                 [-]d.dddde[sign]ddd,                     
  5137.             
  5138.              where d is a single decimal  digit,  dddd  is  one  or  more
  5139.             decimal digits, ddd is exactly three decimal digits, and sign
  5140.             is + or -.
  5141.             
  5142.         9.  E ==> float,  Identical  to  the  e  format,  except  that  E
  5143.             introduces the exponent instead of e.
  5144.         10.  g  ==>  float,  Signed  value  printed  in  f  or  e format,
  5145.  
  5146.  
  5147.         QTAwk                       - 10-2 -                        QTAwk
  5148.  
  5149.  
  5150.  
  5151.  
  5152.  
  5153.  
  5154.         Section 10.1                                 Format Specification
  5155.  
  5156.  
  5157.             whichever is more compact for the given value and  precision.
  5158.             The  e  format is used only when the exponent of the value is
  5159.             less than -4 or greater than the precision argument. Trailing
  5160.             zeros are truncated and the decimal point appears only if one
  5161.             or more digits follow it.
  5162.             
  5163.         11.  G ==> float, Identical  to  the  g  format,  except  that  E
  5164.             introduces  the  exponent  (where  appropriate) instead of e.
  5165.             
  5166.         12.  c ==> character, Single character
  5167.             
  5168.         13.  s ==> string,  Characters  printed  up  to  the  first  null
  5169.             character  ('\0')  or  until  the precision value is reached.
  5170.         
  5171.         E10.2 Output FlagsF
  5172.         
  5173.          Flag Characters
  5174.         
  5175.         1.  '-' ==> Left  justify  the  result  within  the  given  field
  5176.             width. Default: Right justify.
  5177.             
  5178.         2.  '+'  ==>  Prefix the output value with a sign (+ or -) if the
  5179.             output value is of a signed type. Default: Sign appears  only
  5180.             for negative signed values (-).
  5181.             
  5182.         3.  blank  ('  ') ==> Prefix the output value with a blank if the
  5183.             output value is signed and positive. The blank is ignored  if
  5184.             both the blank and + flags appear. Default: No blank.
  5185.             
  5186.         4.  '#'  ==>  When  used  with  the o, x, or X format, the # flag
  5187.             prefixes  any  nonzero  output  value  with  0,  0x,  or  0X,
  5188.             respectively. Default: No blank.
  5189.             
  5190.         5.  '#'  ==>  When  used  with  the e, E, or f format, the # flag
  5191.             forces the output value to contain a  decimal  point  in  all
  5192.             cases.  Default:  Decimal point appears only if digits follow
  5193.             it.
  5194.             
  5195.         6.  '#' ==> When used with the g or G format, the #  flag  forces
  5196.             the  output value to contain a decimal point in all cases and
  5197.             prevents the truncation of trailing zeros.  Default:  Decimal
  5198.             point  appears  only  if digits follow it. Trailing zeros are
  5199.             truncated.
  5200.             
  5201.         7.  '#' ==> Ignored when used with c, d, i, u or s
  5202.             
  5203.  
  5204.  
  5205.         QTAwk                       - 10-3 -                        QTAwk
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.         Section 10.2                                 Format Specification
  5213.  
  5214.  
  5215.         8.  '0' ==> For d, i, o, u, x, X, e, E, f, g, and G  conversions,
  5216.             leading  zeros (following any indication of sign or base) are
  5217.             used  to  pad  to  the  field  width;  no  space  padding  is
  5218.             performed.  If the 0 and - flags both appear, the 0 flag will
  5219.             be ignored. For d, i, o,  u,  x,  and  X  conversions,  if  a
  5220.             precision is specified, the 0 flag will be ignored. For other
  5221.             conversions the behavior is  undefined.  Default:  Use  blank
  5222.             padding
  5223.         
  5224.          If  the  argument corresponding to a floating-point specifier is
  5225.         infinite or indefinite, the following output is produced:
  5226.         
  5227.         + infinity ==> 1.#INFrandom-digits
  5228.         - infinity ==> -1.#INFrandom-digits
  5229.         Indefinite ==> digit.#INDrandom-digits
  5230.         
  5231.         E10.3 Output WidthF
  5232.         
  5233.          The width argument is a non-negative decimal integer controlling
  5234.         the  minimum  number  of  characters  printed.  If  the number of
  5235.         characters in the output value is less than the specified  width,
  5236.         blanks  are  added  to  the  left  or  the  right  of  the values
  5237.         (depending on whether the - flag is specified) until the  minimum
  5238.         width  is  reached. If width is prefixed with a 0 flag, zeros are
  5239.         added  until  the  minimum  width  is  reached  (not  useful  for
  5240.         left-justified numbers).
  5241.         
  5242.          The width specification never causes a value to be truncated; if
  5243.         the number of characters in the output value is greater than  the
  5244.         specified  width,  or  width  is not given, all characters of the
  5245.         value are  printed  (subject  to  the  precision  specification).
  5246.         
  5247.          The width specification may be an asterisk (*), in which case an
  5248.         integer argument from the argument list supplies the  value.  The
  5249.         width  argument  must  precede  the  value being formatted in the
  5250.         argument list. A nonexistent or small field width does not  cause
  5251.         a  truncation  of a field; if the result of a conversion is wider
  5252.         than the field width, the field expands to contain the conversion
  5253.         result.
  5254.         
  5255.         E10.4 Output PrecisionF
  5256.         
  5257.          The  precision  specification  is a non-negative decimal integer
  5258.         preceded  by  a  period,  '.',  which  specifies  the  number  of
  5259.         characters  to  be  printed, the number of decimal places, or the
  5260.         number of significant digits. Unlike the width specification, the
  5261.  
  5262.  
  5263.         QTAwk                       - 10-4 -                        QTAwk
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.         Section 10.4                                 Format Specification
  5271.  
  5272.  
  5273.         precision  can  cause truncation of the output value, or rounding
  5274.         in the case of a floating-point value.
  5275.         
  5276.          The precision specification may be an asterisk,  '*',  in  which
  5277.         case  an  integer  argument  from  the argument list supplies the
  5278.         value. The  precision  argument  must  precede  the  value  being
  5279.         formatted in the argument list.
  5280.         
  5281.          The  interpretation of the precision value, and the default when
  5282.         precision is omitted, depend on the type, as shown below:
  5283.         
  5284.         1.  d,i,u,o,x,X ==> The precision specifies  the  minimum  number
  5285.             of  digits  to  be  printed.  If  the number of digits in the
  5286.             argument is less than precision, the output value  is  padded
  5287.             on  the  left with zeros. The value is not truncated when the
  5288.             number of digits exceeds precision. Default: If precision  is
  5289.             0 or omitted entirely, or if the period (.) appears without a
  5290.             number following it, the precision is set to 1.
  5291.             
  5292.         2.  e, E ==> The precision specifies the number of digits  to  be
  5293.             printed  after  the  decimal point. The last printed digit is
  5294.             rounded. Default: Default precision is 6; if precision  is  0
  5295.             or  the  period (.) appears without a number following it, no
  5296.             decimal point is printed.
  5297.             
  5298.         3.  f ==> The precision value  specifies  the  number  of  digits
  5299.             after the decimal point. If a decimal point appears, at least
  5300.             one digit appears before it. The  value  is  rounded  to  the
  5301.             appropriate  number  of digits. Default: Default precision is
  5302.             6; if precision is 0, or if the period (.) appears without  a
  5303.             number following it, no decimal point appears.
  5304.             
  5305.         4.  g,  G  ==>  The  precision  specifies  the  maximum number of
  5306.             significant digits printed. Default: Six  significant  digits
  5307.             are  printed,  without any trailing zeros that are truncated.
  5308.             
  5309.         5.  c ==> No effect. Default: Character printed
  5310.             
  5311.         6.  s  ==>  The  precision  specifies  the  maximum   number   of
  5312.             characters  to  be printed. Characters in excess of precision
  5313.             are not printed. Default: All characters of  the  string  are
  5314.             printed.
  5315.         
  5316.  
  5317.  
  5318.  
  5319.  
  5320.  
  5321.         QTAwk                       - 10-5 -                        QTAwk
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362.  
  5363.  
  5364.  
  5365.  
  5366.  
  5367.  
  5368.  
  5369.  
  5370.  
  5371.  
  5372.  
  5373.  
  5374.  
  5375.  
  5376.  
  5377.  
  5378.  
  5379.         QTAwk                       - 10-6 -                        QTAwk
  5380.  
  5381.  
  5382.  
  5383.  
  5384.  
  5385.  
  5386.         Section 11.0                               User-Defined Functions
  5387.  
  5388.  
  5389.         E-11.0 USER-DEFINED FUNCTIONSF-Ç
  5390.         
  5391.          QTAwk supports user-defined functions and has enhanced them over
  5392.         Awk in several important aspects.
  5393.         
  5394.         E11.1 Local VariablesF
  5395.         
  5396.          In QTAwk it is no longer necessary to declare local variables as
  5397.         excess  arguments  in the function definition. QTAwk has included
  5398.         the 'local' keyword. This keyword may be  used  in  any  compound
  5399.         statement,   but   was  invented  specifically  for  user-defined
  5400.         functions. Consider the simple function to accumulate words  from
  5401.         the current input record in the formatting utility:
  5402.         
  5403.         # accumulate words for line
  5404.         function addword(w) {
  5405.             local lw = length(w); # length of added word
  5406.         
  5407.                 # check new line length
  5408.             if ( cnt + size + lw >= width ) printline(yes);
  5409.             line[++cnt] = w; # add word to line array
  5410.             size += lw;
  5411.         }
  5412.         
  5413.          That  lw  is  local  to the function and will disappear when the
  5414.         function is exited is obvious from the definition of  lw.  It  is
  5415.         also  now  easy  to  pick out the function arguments, 'w' in this
  5416.         case. The initialization of lw to  the  length  of  the  argument
  5417.         passed  is also easily picked up from the definition. The 'local'
  5418.         keyword thus truly separates local variables  from  the  function
  5419.         arguments.
  5420.         
  5421.         E11.2 Argument CheckingF
  5422.         
  5423.          By  using  the '_arg_chk' built-in variable, it is also possible
  5424.         to have QTAwk now do some argument  checking  for  the  user.  If
  5425.         _arg_chk  is TRUE, then QTAwk will, at run-time, check the number
  5426.         of arguments passed against the number of arguments  defined.  If
  5427.         the  number  passed  differs  from  the  number  defined,  then a
  5428.         run-time error is issued and  QTAwk  halts.  When  '_arg_chk'  is
  5429.         FALSE,  QTAwk  will  check  at  run-time  only that the number of
  5430.         arguments passed is less than or equal  to  the  number  defined.
  5431.         This follows the Awk practice and allows for the use of arguments
  5432.         defined, but not passed, as local variables. The default value of
  5433.         '_arg_chk'  is FALSE. It is recommended that '_arg_chk' be set to
  5434.         TRUE and the 'local' keyword used to define variables meant to be
  5435.  
  5436.  
  5437.         QTAwk                       - 11-1 -                        QTAwk
  5438.  
  5439.  
  5440.  
  5441.  
  5442.  
  5443.  
  5444.         Section 11.2                               User-Defined Functions
  5445.  
  5446.  
  5447.         local to a function.
  5448.         
  5449.         E11.3 Variable Length Argument ListsF
  5450.         
  5451.          QTAwk  allows  user-defined  functions  to  be  defined  with  a
  5452.         variable number of arguments. The actual number of arguments will
  5453.         be  determined  from  the  call  at run-time. QTAwk follows the C
  5454.         syntax  for  defining  a  function  with  a  variable  number  of
  5455.         arguments:
  5456.         
  5457.         # function to determine maximum value
  5458.         function max(...) {
  5459.             local max = vargv[1];
  5460.             local i;
  5461.         
  5462.             for ( i = 2 ; i <= vargc ; i++ )
  5463.               if ( max < vargv[i] ) max = vargv[i];
  5464.             return max;
  5465.         }
  5466.         
  5467.          The  ellipses,  '...',  is  used  as  the  last  argument  in  a
  5468.         user-defined argument list to indicate that a variable number  of
  5469.         arguments  follow.  In the max function shown, no fixed arguments
  5470.         are indicated. Within the function, the  variable  arguments  are
  5471.         accessed  via the built-in singly-dimensioned array, 'vargv'. The
  5472.         built-in variable 'vargc' is set equal to the number of  elements
  5473.         of  the array and, hence, the variable number of arguments passed
  5474.         to the function. Since the variable arguments  are  passed  in  a
  5475.         singly  dimensioned  array,  the  'for'  statement may be used to
  5476.         access each in turn:
  5477.         
  5478.         # function to determine maximum value
  5479.         function max(...) {
  5480.             local max = vargv[1];
  5481.             local i;
  5482.         
  5483.             for ( i in vargv )
  5484.               if ( max < vargv[i] ) max = vargv[i];
  5485.             return max;
  5486.         }
  5487.         
  5488.          A user-defined function may have fixed arguments and a  variable
  5489.         number of arguments following:
  5490.         
  5491.         #  function  with  both  fixed  and  variable number of arguments
  5492.         function sample(arg1,arg2,...) {
  5493.  
  5494.  
  5495.         QTAwk                       - 11-2 -                        QTAwk
  5496.  
  5497.  
  5498.  
  5499.  
  5500.  
  5501.  
  5502.         Section 11.3                               User-Defined Functions
  5503.  
  5504.  
  5505.             .
  5506.             .
  5507.             .
  5508.         }
  5509.         
  5510.          If a user-defined function is  to  have  a  variable  number  of
  5511.         arguments,  then the 'local' keyword must be used to define local
  5512.         variables. The ellipses denoting the variable arguments  must  be
  5513.         last in the function definition argument list.
  5514.         
  5515.         E11.4 Null Argument ListF
  5516.         
  5517.          A  user  defined  function  may  be  defined  with no arguments.
  5518.         Consider the function to accumulate words from input records  for
  5519.         the text formatter:
  5520.         
  5521.         # function to add current line to parsed text
  5522.         function add_line() {
  5523.             for ( i = 1 ; i <= NF ; i++ ) if ( length($i) ) addword($i);
  5524.         }
  5525.         
  5526.          In  the  case of a user-defined function with no arguments to be
  5527.         passed,  the  function  may  be  invoked  with  no  parenthesized
  5528.         parameter  list. Consider the invocation of the add-line function
  5529.         in the text formatter. The  action  executed  for  input  records
  5530.         which do not start with a format control word is:
  5531.         
  5532.             {
  5533.             if ( format ) add_line;
  5534.               else if ( table_f ) format_table($0);
  5535.               else output_line($0,FALSE);
  5536.         }
  5537.         
  5538.          In  QTAwk, the add_line function may be invoked as "add_line" as
  5539.         above or as "add_line()", with  a  null  length  parameter  list.
  5540.         
  5541.          QTAwk has also relaxed the Awk rule that the left parenthesis of
  5542.         the  parameter  list  must  immediately  follow  a   user-defined
  5543.         function invocation. QTAwk allows blanks between the name and the
  5544.         left parenthesis. The blanks are ignored.
  5545.         
  5546.         E11.5 Arrays and Used-Defined FunctionsF
  5547.         
  5548.          Just as arrays are integrated into QTAwk expressions, arrays are
  5549.         also  integrated into the passing of arguments to, and the return
  5550.         value from, user-defined functions.  Used-defined  functions  may
  5551.  
  5552.  
  5553.         QTAwk                       - 11-3 -                        QTAwk
  5554.  
  5555.  
  5556.  
  5557.  
  5558.  
  5559.  
  5560.         Section 11.5                               User-Defined Functions
  5561.  
  5562.  
  5563.         return  arrays  as well as scalars. This will be illustrated in a
  5564.         sample utility later.
  5565.         
  5566.          QTAwk passes  scalar  arguments  to  user-defined  functions  by
  5567.         value,  i.e., if a scalar variable is specified as an argument to
  5568.         a function, a copy of the variable is passed to the function  and
  5569.         not  the  variable itself. This is called pass by value. Thus, if
  5570.         the function alters the value of the argument,  the  variable  is
  5571.         not  altered,  only  the  copy. When the function terminates, the
  5572.         copy is discarded, and the variable still  retains  its  original
  5573.         value.
  5574.         
  5575.          In  contrast,  QTAwk passes array variables by "reference". This
  5576.         means  that  the  local  variable  represented  by  the  function
  5577.         argument,  is the referenced variable and not a copy. Any changes
  5578.         to the  local  variable  are  actually  made  to  the  referenced
  5579.         variable.
  5580.         
  5581.          In QTAwk, function arguments may also be constant arrays and not
  5582.         variable arrays, i.e., the argument  may  be  the  result  of  an
  5583.         arithmetic  operation on an array. For example, if A is an array,
  5584.         then the result of the expression
  5585.         
  5586.                                     "A + 10"                             
  5587.         
  5588.          is an array and would  be  passed  as  a  constant  array  as  a
  5589.         function   argument.   Such   arrays   are  discard  at  function
  5590.         termination.
  5591.         
  5592.          QTAwk passes by reference under three conditions:
  5593.         
  5594.         1.  The argument is a global or  local  variable  and  an  array,
  5595.             
  5596.         2.  The  argument  is  a  global or local variable and used as an
  5597.             array, i.e., indexed or referenced by an 'in'  statement,  in
  5598.             the  called  function.  This  is  true whether the referenced
  5599.             variable is a scalar or array when the function is called. If
  5600.             the  referenced  variable  was  a scalar when the function is
  5601.             called, then at function termination, if the statement(s)  in
  5602.             which  the argument was indexed WERE EXECUTED, the referenced
  5603.             variable will be an array with the index  values  referenced.
  5604.             This  behaviour  is  identical  to creating array elements in
  5605.             global variables by referencing the elements.
  5606.             
  5607.         3.  The argument is a global or  local  scalar  variable  and  at
  5608.             function  termination the argument is an array. In this case,
  5609.  
  5610.  
  5611.         QTAwk                       - 11-4 -                        QTAwk
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  
  5617.  
  5618.         Section 11.5                               User-Defined Functions
  5619.  
  5620.  
  5621.             the argument may not have  been  directly  referenced  as  an
  5622.             array,  but  may  be  the result of an operation involving an
  5623.             array. Alternatively the argument may  have  been  passed  to
  5624.             another function which referenced it as an array or set it to
  5625.             the result of operations on arrays.
  5626.         
  5627.          The following QTAwk utility with a  user-defined  function  will
  5628.         illustrate  the  use  of arrays and scalars as function arguments
  5629.         and the return of arrays by user-defined functions.
  5630.  
  5631.  
  5632.  
  5633.  
  5634.  
  5635.  
  5636.  
  5637.  
  5638.  
  5639.  
  5640.  
  5641.  
  5642.  
  5643.  
  5644.  
  5645.  
  5646.  
  5647.  
  5648.  
  5649.  
  5650.  
  5651.  
  5652.  
  5653.  
  5654.  
  5655.  
  5656.  
  5657.  
  5658.  
  5659.  
  5660.  
  5661.  
  5662.  
  5663.  
  5664.  
  5665.  
  5666.  
  5667.  
  5668.  
  5669.         QTAwk                       - 11-5 -                        QTAwk
  5670.  
  5671.  
  5672.  
  5673.  
  5674.  
  5675.  
  5676.         Section 11.5                               User-Defined Functions
  5677.  
  5678.  
  5679.         BEGIN {
  5680.                 # create arrays 'a' and 'b'
  5681.             for ( i = 1 ; i < 6 ; i++ ) a[i] = b[i] = i;
  5682.                 # create scalars 'c' and 'f'
  5683.             c = f = 10;
  5684.                 # pass scalar variables/values and return scalar value
  5685.             print "scalar : "set_var(c,c,c)" and c == "c;
  5686.                 # pass two arrays, 'a' & 'b',
  5687.                 # and one scalar constant, 'c+0'
  5688.                 # function will return an array "== a + b + (c+0)"
  5689.             d = set_var(a,b,c+0);
  5690.                 # print returned array 'd' (== a + b + (c+0))
  5691.             for ( i in d ) print "d["i"] = "d[i];
  5692.                 #print scalar 'c' to show unchanged
  5693.             print c;
  5694.                 # pass two arrays, 'a' & 'b',
  5695.                 # and one scalar variable, 'c'
  5696.                 # function will return an array "== a + b + c"
  5697.             e = set_var(a,b,c);
  5698.                 # print returned array
  5699.             for ( i in e ) print "e["i"] = "e[i];
  5700.                 # print former scalar, 'c',
  5701.                 # converted to array by operation c = b + 2;
  5702.             for ( i in c ) print "c["i"] = "c[i];
  5703.                 # pass two arrays, 'a' & 'b', and constant array, 'b+0'
  5704.             h = set_var(a,b,b+0);
  5705.                 # print returned array
  5706.             for ( i in h ) print "h["i"] = "h[i];
  5707.                 # print array 'b' to assure that unchanged
  5708.             for ( i in b ) print "b["i"] = "b[i];
  5709.                 # attempt illegal operation in function: w = f + b
  5710.                 # adding array, 'b', to scalar, 'f'.
  5711.                 # error message will be issued and execution halted
  5712.             g = set_var(f,b,f);
  5713.         }
  5714.         
  5715.         function set_var(x,y,z) {
  5716.                 # create local variable
  5717.             local w = x + y + z;
  5718.                 # alter third argument
  5719.                 # if first & second arguments arrays,
  5720.                 # this will convert third to an array
  5721.                 # (if not already passed as an array).
  5722.             z = y + 2;
  5723.             return w;
  5724.         }
  5725.  
  5726.  
  5727.         QTAwk                       - 11-6 -                        QTAwk
  5728.  
  5729.  
  5730.  
  5731.  
  5732.  
  5733.  
  5734.  
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740.  
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.  
  5747.  
  5748.  
  5749.  
  5750.  
  5751.  
  5752.  
  5753.  
  5754.  
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760.  
  5761.  
  5762.  
  5763.  
  5764.  
  5765.  
  5766.  
  5767.  
  5768.  
  5769.  
  5770.  
  5771.  
  5772.  
  5773.  
  5774.  
  5775.  
  5776.  
  5777.  
  5778.  
  5779.  
  5780.  
  5781.  
  5782.  
  5783.  
  5784.  
  5785.         QTAwk                       - 11-7 -                        QTAwk
  5786.  
  5787.  
  5788.  
  5789.  
  5790.  
  5791.  
  5792.         Section 11.5                               User-Defined Functions
  5793.  
  5794.  
  5795.          This QTAwk utility illustrates several ideas in using arrays and
  5796.         user-defined functions in QTAwk. The line:
  5797.         
  5798.             print "scalar : "set_var(c,c,c)" and c == "c;
  5799.         
  5800.          calls  the  function  'set_var' with three scalar variables, all
  5801.         'c'. Three copies of 'c' are actually passed. The local variable,
  5802.         'w',  is  computed  using  scalar  quantities  and  is  a  scalar
  5803.         quantity. Since argument 'y' is a scalar quantity, the result  of
  5804.         the expression:
  5805.         
  5806.             z = y + 2;
  5807.         
  5808.          is  a  scalar  and  the  third  argument,  'c',  is unchanged. A
  5809.         functional value of 30 (== c + c + c) is returned.
  5810.         
  5811.          The line:
  5812.         
  5813.             d = set_var(a,b,c+0);
  5814.         
  5815.          passes arrays as the  first  and  second  arguments.  The  third
  5816.         argument  is  a constant scalar value, and thus cannot be changed
  5817.         by the function called. The return value of the function:
  5818.         
  5819.         w = x + y + z; (== a + b + 10;)
  5820.         
  5821.          is an array. The line:
  5822.         
  5823.             for ( i in d ) print "d["i"] = "d[i];
  5824.         
  5825.          prints the values of the array:
  5826.         
  5827.         d[1] = 12
  5828.         d[2] = 14
  5829.         d[3] = 16
  5830.         d[4] = 18
  5831.         d[5] = 20
  5832.         
  5833.          The line:
  5834.         
  5835.             e = set_var(a,b,c);
  5836.         
  5837.          passes arrays as the  first  and  second  arguments.  The  third
  5838.         argument  is  a variable scalar value, and thus can be changed by
  5839.         the function called if the third argument at function termination
  5840.         is an array. The return value of the function:
  5841.  
  5842.  
  5843.         QTAwk                       - 11-8 -                        QTAwk
  5844.  
  5845.  
  5846.  
  5847.  
  5848.  
  5849.  
  5850.         Section 11.5                               User-Defined Functions
  5851.  
  5852.  
  5853.         
  5854.         w = x + y + z; (== a + b + c;)
  5855.         
  5856.          is  an  array  as  above. Note that at function termination, the
  5857.         third argument is now an array since it was set to the result  of
  5858.         an operation on an array:
  5859.         
  5860.             z = y + 2;
  5861.         
  5862.          which is now equivalent to:
  5863.         
  5864.             z = b + 2;
  5865.         
  5866.          Thus,  at  function termination the scalar variable 'c' has been
  5867.         converted to an array. The line:
  5868.         
  5869.             for ( i in c ) print "c["i"] = "c[i];
  5870.         
  5871.          will print the values of the array elements:
  5872.         
  5873.         c[1] = 3 ( == b[1] + 2)
  5874.         c[2] = 4 ( == b[2] + 2)
  5875.         c[3] = 5 ( == b[3] + 2)
  5876.         c[4] = 6 ( == b[4] + 2)
  5877.         c[5] = 7 ( == b[5] + 2)
  5878.         
  5879.          The line:
  5880.         
  5881.             h = set_var(a,b,b+0);
  5882.         
  5883.          passes arrays as the  first  and  second  arguments.  The  third
  5884.         argument is a constant array value, and thus cannot be changed by
  5885.         the function called. The return value of the function is an array
  5886.         as  above.  Note that at function termination, the third argument
  5887.         is again an array as above. However, the third argument has  been
  5888.         passed as a constant array and thus no variable is changed as 'c'
  5889.         was  above.  The  third  argument  is   discarded   at   function
  5890.         termination. The line:
  5891.         
  5892.             for ( i in b ) print "b["i"] = "b[i];
  5893.         
  5894.          prints the array 'b' to assure that it was not changed.
  5895.         
  5896.          The line:
  5897.         
  5898.             g = set_var(f,b,f);
  5899.  
  5900.  
  5901.         QTAwk                       - 11-9 -                        QTAwk
  5902.  
  5903.  
  5904.  
  5905.  
  5906.  
  5907.  
  5908.         Section 11.5                               User-Defined Functions
  5909.  
  5910.  
  5911.          will result in an illegal operation in the function:
  5912.         
  5913.             local w = x + y + z; (== f + b + f;)
  5914.         
  5915.          this  operation  is  now attempting to add an array to a scalar:
  5916.         
  5917.             f + b
  5918.         
  5919.          This  operation  will  result  in  an  error  message  and  halt
  5920.         execution.
  5921.         
  5922.          The   above  sample  QTAwk  utility  illustrates  the  power  of
  5923.         user-defined functions  in  automatically  handling  scalars  and
  5924.         arrays   as  both  arguments  and  return  values  and  adjusting
  5925.         accordingly. The same function may  be  used  interchangably  for
  5926.         both  arrays  and  scalars  with natural and predictable results.
  5927.         
  5928.  
  5929.  
  5930.  
  5931.  
  5932.  
  5933.  
  5934.  
  5935.  
  5936.  
  5937.  
  5938.  
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944.  
  5945.  
  5946.  
  5947.  
  5948.  
  5949.  
  5950.  
  5951.  
  5952.  
  5953.  
  5954.  
  5955.  
  5956.  
  5957.  
  5958.  
  5959.         QTAwk                       - 11-10 -                       QTAwk
  5960.  
  5961.  
  5962.  
  5963.  
  5964.  
  5965.  
  5966.         Section 12.0                                     Trace Statements
  5967.  
  5968.  
  5969.         E-12.0 TRACE STATEMENTSF-Ç
  5970.         
  5971.          QTAwk  has  added  a  facility  for  debugging  utilities.  This
  5972.         facility  is  activated  through  the  built-in variable 'TRACE'.
  5973.         QTAwk can trace the loop control statements, 'if', 'while', 'do',
  5974.         'for' (both forms), and 'switch'. In addition, built-in functions
  5975.         and user-defined functions are traced.
  5976.         
  5977.          By default, TRACE is set to FALSE and no tracing  is  done.  The
  5978.         variable  may  be  set  to  any value, numeric, string or regular
  5979.         expression and the value will determine the statements traced. If
  5980.         TRACE  has  a  nonzero  numeric  value  then QTAwk will trace all
  5981.         statements of the type listed.
  5982.         
  5983.         E12.1 Selective Statement TracingF
  5984.         
  5985.          If TRACE has a string value, then the string is compared against
  5986.         the keywords:
  5987.         
  5988.         1.  if
  5989.         2.  while
  5990.         3.  do
  5991.         4.  for
  5992.         5.  switch
  5993.         6.  function_b (built-in functions)
  5994.         7.  function_u (user-defined functions)
  5995.         
  5996.          If  an  exact  match  (case  is  important)  is  found, then the
  5997.         statement is traced. If TRACE is set  to  a  regular  expression,
  5998.         then  the keywords are matched against the regular expression. If
  5999.         a match is found, then the statement is traced.
  6000.         
  6001.         E12.2 Trace OutputF
  6002.         
  6003.          In tracing a statement, QTAwk issues a message to  the  standard
  6004.         output file. The message issued will have the form:
  6005.         
  6006.         Stmt Trace: stmt_str value_str
  6007.         Action File line: xxxx
  6008.         Scanning File: FILENAME
  6009.         Line: xxxxx
  6010.         Record: xxxxxx
  6011.         
  6012.          where  stmt_str  is the appropriate keyword listed above for the
  6013.         statement traced and value_str is  a  value  dependent  upon  the
  6014.         statement traced as listed below:
  6015.  
  6016.  
  6017.         QTAwk                       - 12-1 -                        QTAwk
  6018.  
  6019.  
  6020.  
  6021.  
  6022.  
  6023.  
  6024.         Section 12.2                                     Trace Statements
  6025.  
  6026.  
  6027.         keyword           value string                                   
  6028.         if           ==>  0/1 conditional expression TRUE/FALSE          
  6029.         while        ==>  0/1 conditional expression TRUE/FALSE          
  6030.         do           ==>  0/1 conditional expression TRUE/FALSE          
  6031.         for          ==>  0/1 conditional expression TRUE/FALSE          
  6032.         for          ==>  subscript value                                
  6033.         switch       ==>  switch expression value                        
  6034.         function_b   ==>  function name                                  
  6035.         function_u   ==>  function name                                  
  6036.         
  6037.          When  a  statement  that can be traced is encountered, the value
  6038.         of the statement is determined, e.g., for an 'if' statement,  the
  6039.         value  of  the  conditional is evaluated before issuing the trace
  6040.         statement.
  6041.         
  6042.          The following TRACE values will trace the statements  indicated:
  6043.         
  6044.         1.  TRACE = "if";
  6045.             This  value  will  trace  all 'if' statements, indicating the
  6046.             TRUE/FALSE value of the conditional.
  6047.             
  6048.         2.  TRACE = /^[iwd]/;
  6049.             This value will trace all 'if', 'while' and 'do'  statements,
  6050.             indicating the TRUE/FALSE value of the conditional.
  6051.             
  6052.         3.  TRACE = /_u$/;
  6053.             This  value will trace all user-defined functions, indicating
  6054.             the function name in the trace message.
  6055.         
  6056.  
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  
  6064.  
  6065.  
  6066.  
  6067.  
  6068.  
  6069.  
  6070.  
  6071.  
  6072.  
  6073.  
  6074.  
  6075.         QTAwk                       - 12-2 -                        QTAwk
  6076.  
  6077.  
  6078.  
  6079.  
  6080.  
  6081.  
  6082.         Section 13.0                                   Built-in Variables
  6083.  
  6084.  
  6085.         E-13.0 BUILT-IN VARIABLESF-Ç
  6086.         
  6087.          QTAwk offers the following built-in variables. The variables may
  6088.         be  set  by the user. Those marked with an asterisk, '*', are new
  6089.         to QTAwk:
  6090.         
  6091.         1.  * _arg_chk ==> TRUE/FALSE. Default value = FALSE.  If  FALSE,
  6092.             the  number of arguments passed to a user defined function is
  6093.             checked only to ensure that  the  number  is  not  more  than
  6094.             defined.  Arguments  defined,  but not passed are initialized
  6095.             and passed for use as local variables as in Awk. If TRUE, the
  6096.             number  of  arguments  passed  to  a user defined function is
  6097.             checked  for  number  against  the  number  defined  for  the
  6098.             function,  unless  the  function  was defined with a variable
  6099.             number of arguments. If the  number  passed  is  not  exactly
  6100.             equal  to  the number defined, an error message is issued and
  6101.             execution halted. For this case, any local variables must  be
  6102.             defined with the 'local' keyword.
  6103.             
  6104.         2.  ARGC  ==>  set  equal  to  the  number of arguments passed to
  6105.             QTAwk as in Awk.
  6106.             
  6107.         3.  * ARGI ==> equal to the index  value  in  ARGV  of  the  next
  6108.             command  line  argument  to  be  processed. This value may be
  6109.             changed and will change the array element of  ARGV  processed
  6110.             next.  When  the  last  element  of ARGV is the current input
  6111.             file, ARGI is set to one of two integer values:
  6112.             
  6113.             a)  the integer value of the index of  the  last  element  of
  6114.                 ARGV plus one, or
  6115.             b)  if  the  last element of ARGV has a string index, ARGI is
  6116.                 set to zero.
  6117.             
  6118.              Setting ARGI to zero, ARGC or a value for which there is  no
  6119.             element  of ARGV with a corresponding index value, will cause
  6120.             the current input file to be the last command  line  argument
  6121.             processed.
  6122.             
  6123.         4.  ARGV  ==>  one-dimensional  array  with elements equal to the
  6124.             arguments passed to QTAwk as in Awk.  The  index  values  are
  6125.             integers  ranging  in  value  from  zero  to ARGC. ARGV[0] ==
  6126.             filename  by  which  QTAwk  invoked,  including   full   path
  6127.             information.
  6128.             
  6129.         5.  *CYCLE_COUNT  ==>  value  for  the  current cycle through the
  6130.             outer pattern  match  loop  for  the  current  record.  Value
  6131.  
  6132.  
  6133.         QTAwk                       - 13-1 -                        QTAwk
  6134.  
  6135.  
  6136.  
  6137.  
  6138.  
  6139.  
  6140.         Section 13.0                                   Built-in Variables
  6141.  
  6142.  
  6143.             incremented by the 'cycle' statement.
  6144.             
  6145.         6.  * DEGREES  ==>  TRUE/FALSE.  Default  value = FALSE. If FALSE
  6146.             trigonometric functions assume radian values are  passed  and
  6147.             return  radian values. If TRUE trigonometric functions assume
  6148.             degree values are passed and return degree values.
  6149.             
  6150.         7.  ENVIRON ==> one-dimensional array with elements equal to  the
  6151.             environment  strings  passed  to  QTAwk. The index values are
  6152.             integers  ranging  in  value  from  zero  to  the  number  of
  6153.             environment strings defined less one.
  6154.             
  6155.         8.  * FALSE ==> predefined with zero, 0, constant value.
  6156.             
  6157.         9.  FILENAME  ==>  equal  to  string  value  of current filename,
  6158.             including any path specified. If assigned a  new  value,  the
  6159.             file  with a name equal to the new string value is opened (or
  6160.             an error message displayed if the filename is  illegal).  The
  6161.             new  file  becomes  the  current input file. The former input
  6162.             file  is  not  closed  and  may  continue  to  be  input   by
  6163.             re-assigning  FILENAME,  putting  the name in ARGV for future
  6164.             use or read with the 'fgetline' function.
  6165.             
  6166.         10.  FNR ==> equal to current  record  number  of  current  input
  6167.             file.
  6168.             
  6169.         11.  FS  ==>  value of current input field separator. The default
  6170.             value for FS is /[\t-\r\s]+/,  i.e.,  any  consecutive  white
  6171.             space  characters. If FS is set on the command line or in the
  6172.             user utility then the following  rules  apply  (see  also  RS
  6173.             below):
  6174.             a)  setting to a single blank, ' ' or " ", will set FS to the
  6175.                 default value of /[\t-\r\s]+/,
  6176.             b)  setting to a single  character  or  a  value  which  when
  6177.                 converted  to  a  string  yields  a  string  of  a single
  6178.                 character in length, 'x' or "x", will  cause  the  single
  6179.                 character to be used as the input record field separator,
  6180.             c)  setting to a regular  expression,  a  multiple  character
  6181.                 string or a value which when converted to a string yields
  6182.                 a  multiple  character  string,  the   string   will   be
  6183.                 considered  a  regular  expression  and  converted to the
  6184.                 regular expression internal form when the  assignment  is
  6185.                 made. Input records are scanned for a string matching the
  6186.                 regular expression  and  matching  strings  become  field
  6187.                 separators. The length of matching strings is governed by
  6188.                 the LONGEST_EXPR built-in variable.
  6189.  
  6190.  
  6191.         QTAwk                       - 13-2 -                        QTAwk
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.         Section 13.0                                   Built-in Variables
  6199.  
  6200.  
  6201.         12.  * LONGEST_EXP ==>  TRUE/FALSE.  default  ==  TRUE.  If  TRUE
  6202.             longest  string  matching  a  regular expression is found in:
  6203.             a)  patterns
  6204.             b)  match operators, '~~' and '!~'
  6205.             c)  'match' function
  6206.             d)  'gsub' function
  6207.             e)  'sub' function
  6208.             f)  'strim' function
  6209.             g)  input record separator strings when RS  is  considered  a
  6210.                 regular expression,
  6211.             h)  input   record   field   separator  strings  when  FS  is
  6212.                 considered a regular expression,
  6213.             i)  field separator matching in 'split' function  when  field
  6214.                 separator is a regular expression
  6215.             
  6216.              If   FALSE  then  the  first  string  matching  the  regular
  6217.             expression is found.
  6218.             
  6219.         13.  *MAX_CYCLE ==> Maximum value  for  CYCLE_COUNT  for  cycling
  6220.             through  outer  pattern match loop with current input record.
  6221.             Default value == 100.
  6222.             
  6223.         14.  NF ==> equal to the number of fields in  the  current  input
  6224.             record
  6225.             
  6226.         15.  * NG  ==>  set  to the number of the expression matching the
  6227.             current input record for GROUP patterns.
  6228.             
  6229.         16.  NR ==> total number of records read so far across all  input
  6230.             files.
  6231.             
  6232.         17.  OFMT  ==>  output  and string conversion format for numbers.
  6233.             Default value of "%.6g".
  6234.             
  6235.         18.  OFS ==> output field separator. Default value  of  a  single
  6236.             blank, ' '.
  6237.             
  6238.         19.  ORS  ==>  output record separator. Default value of a single
  6239.             newline character, '\n'.
  6240.             
  6241.         20.  * RETAIN_FS ==> TRUE/FALSE. Default value = FALSE. If  FALSE
  6242.             then  OFS is used between fields to reconstruct $0 whenever a
  6243.             field value is altered. If TRUE the original field  separator
  6244.             characters are retained in reconstructing $0 whenever a field
  6245.             value is altered.
  6246.             
  6247.  
  6248.  
  6249.         QTAwk                       - 13-3 -                        QTAwk
  6250.  
  6251.  
  6252.  
  6253.  
  6254.  
  6255.  
  6256.         Section 13.0                                   Built-in Variables
  6257.  
  6258.  
  6259.         21.  RS ==> input record separator. The default value for  RS  is
  6260.             a single newline character, '\n'. If RS is set on the command
  6261.             line or in the user utility then the  following  rules  apply
  6262.             (see also FS above):
  6263.             a)  setting  to  the  null  string,  "",  will  set RS to the
  6264.                 regular expression /\n\n/. Thus, blank lines,  i.e.,  two
  6265.                 consecutive  newline  characters,  bound  input  records.
  6266.             b)  setting to a single  character  or  a  value  which  when
  6267.                 converted  to  a  string  yields  a  string  of  a single
  6268.                 character in length, 'x' or "x", will  cause  the  single
  6269.                 character  to  be  used  as  the  input record separator,
  6270.             c)  setting to a regular  expression,  a  multiple  character
  6271.                 string or a value which when converted to a string yields
  6272.                 a  multiple  character  string,  the   string   will   be
  6273.                 considered  a  regular  expression  and  converted to the
  6274.                 regular expression internal form when the  assignment  is
  6275.                 made.  The  input  file character stream is scanned for a
  6276.                 string  matching  the  regular  expression  and  matching
  6277.                 strings  become record separators. The length of matching
  6278.                 strings  is  governed  by   the   LONGEST_EXPR   built-in
  6279.                 variable.
  6280.             
  6281.         22.  * TRACE  ==>  control  statement  tracing.  Default  value =
  6282.             FALSE.  Determines  whether  statements  are  traced   during
  6283.             execution.
  6284.             
  6285.         23.  * TRANS_FROM   ==>  string  used  by  'stran'  function  for
  6286.             translating       from.        Default        value        is
  6287.             "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
  6288.             
  6289.         24.  * TRANS_TO   ==>   string   used  by  'stran'  function  for
  6290.             translating        to.        Default        value         is
  6291.             "abcdefghijklmnopqrstuvwxyz".
  6292.             
  6293.         25.  * TRUE ==> predefined with one, 1, constant value.
  6294.             
  6295.         26.  * CLENGTH  ==>  length of string matched in 'case' statement
  6296.             
  6297.         27.  * CSTART ==> start of string  matched  in  'case'  statement
  6298.             
  6299.         28.  * MLENGTH  ==>  length of string matched in match operators,
  6300.             '~~' and '!~'
  6301.             
  6302.         29.  * MSTART ==> start of string  matched  in  match  operators,
  6303.             '~~' and '!~'
  6304.             
  6305.  
  6306.  
  6307.         QTAwk                       - 13-4 -                        QTAwk
  6308.  
  6309.  
  6310.  
  6311.  
  6312.  
  6313.  
  6314.         Section 13.0                                   Built-in Variables
  6315.  
  6316.  
  6317.         30.  RLENGTH  ==>  length  of  string matched in 'match' function
  6318.             
  6319.         31.  RSTART ==> start  of  string  matched  in  'match'  function
  6320.         
  6321.         E13.1 User Function Variable Argument ListsF
  6322.         
  6323.         1.  * vargc  ==>  count  of  variable arguments passed to current
  6324.             invocation
  6325.             
  6326.         2.  * vargv ==> singly-dimensioned array  of  variable  arguments
  6327.             passed  to  current  function  invocation.  Indexing  numeric
  6328.             starting at one, 1.
  6329.         
  6330.  
  6331.  
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340.  
  6341.  
  6342.  
  6343.  
  6344.  
  6345.  
  6346.  
  6347.  
  6348.  
  6349.  
  6350.  
  6351.  
  6352.  
  6353.  
  6354.  
  6355.  
  6356.  
  6357.  
  6358.  
  6359.  
  6360.  
  6361.  
  6362.  
  6363.  
  6364.  
  6365.         QTAwk                       - 13-5 -                        QTAwk
  6366.  
  6367.  
  6368.  
  6369.  
  6370.  
  6371.  
  6372.  
  6373.  
  6374.  
  6375.  
  6376.  
  6377.  
  6378.  
  6379.  
  6380.  
  6381.  
  6382.  
  6383.  
  6384.  
  6385.  
  6386.  
  6387.  
  6388.  
  6389.  
  6390.  
  6391.  
  6392.  
  6393.  
  6394.  
  6395.  
  6396.  
  6397.  
  6398.  
  6399.  
  6400.  
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406.  
  6407.  
  6408.  
  6409.  
  6410.  
  6411.  
  6412.  
  6413.  
  6414.  
  6415.  
  6416.  
  6417.  
  6418.  
  6419.  
  6420.  
  6421.  
  6422.  
  6423.         QTAwk                       - 13-6 -                        QTAwk
  6424.  
  6425.  
  6426.  
  6427.  
  6428.  
  6429.  
  6430.         Section 14.0                                       Invoking QTAwk
  6431.  
  6432.  
  6433.         E-14.0 COMMAND LINE INVOCATIONF-Ç
  6434.         
  6435.          There are two ways of specifying utilities to QTAwk:
  6436.         1.  Specifying the utility on the command line, e.g.,
  6437.             
  6438.               QTAwk "/^$/{if(!bc++)print;next;}{bc=FALSE;print;}" file1  
  6439.             
  6440.              This short command line utility will  read  file1,  printing
  6441.             only  the  first  blank  line in a series of blank lines. All
  6442.             other lines are printed.
  6443.             
  6444.              Note that the "utility" has been enclosed in double  quotes,
  6445.             ".  This is necessary to keep PC/MS-DOS from interpreting the
  6446.             utility as a file.  In  addition,  if  the  utility  contains
  6447.             symbols  recognized  by  PC/MS-DOS,  e.g.,  the  re-direction
  6448.             operators,  '<'  or  '>',  the  quotes  keep  PC/MS-DOS  from
  6449.             recognizing  the  symbols.  If  the  utility contains quotes,
  6450.             e.g., a constant string definition, then the imbedded  quotes
  6451.             should be preceded by a back-slash, '\'.
  6452.             
  6453.              For example, the short utility:
  6454.             
  6455.                          QTAwk "{print FNR\" : \"$0;}" file1             
  6456.             
  6457.              prints  each  line of file1 preceded by the line number. The
  6458.             constant string,
  6459.             
  6460.                                         " : "                            
  6461.             
  6462.              separates the line number from the line.  Back-slashes  must
  6463.             precede the quotes surrounding the constant string.
  6464.             
  6465.         2.  -futilityfile
  6466.             or
  6467.             -f utilityfile
  6468.             
  6469.              When  a  utility may be used frequently or grows too long to
  6470.             include on the command line as above, it becomes necessary to
  6471.             store  it  in  a  file.  The utility may then be specified to
  6472.             QTAwk with this option. The blank  between  the  'f'  command
  6473.             line option and the utility file name is optional.
  6474.         
  6475.         E14.1 Multiple QTAwk UtilitiesF
  6476.         
  6477.          More  than  one  utility  file may be specified to QTAwk in this
  6478.         manner.  Each  utility  file  specified  is  read  in  the  order
  6479.  
  6480.  
  6481.         QTAwk                       - 14-1 -                        QTAwk
  6482.  
  6483.  
  6484.  
  6485.  
  6486.  
  6487.  
  6488.         Section 14.1                                       Invoking QTAwk
  6489.  
  6490.  
  6491.         specified  and  combined  into  a  single  QTAwk utility. In this
  6492.         manner it is possible to keep constantly used pattern-actions  or
  6493.         user-defined  functions  in  separate files and combine them into
  6494.         QTAwk utilities as necessary. The order of the utility  files  is
  6495.         not  important  except for the order in which predefined patterns
  6496.         are executed and the order  in  which  pattern-action  pairs  are
  6497.         executed.   Thus   if   a  utility  file  contained  only  common
  6498.         user-defined functions,  it  may  be  defined  in  any  order  in
  6499.         relation to other utility files.
  6500.         
  6501.          Scanning  of  the command line for arguments may be stopped with
  6502.         the double hyphen command line argument, "--". This  argument  is
  6503.         not passed to the QTAwk utility.
  6504.         
  6505.          This  method of specifying utilities to QTAwk cannot be combined
  6506.         with the command line utility definition method.
  6507.         
  6508.          The command line is scanned for all utility files specified with
  6509.         the  'f'  option  prior to reading the utility files or any input
  6510.         files. The utility files are then "removed" from the command line
  6511.         and the command line argument count.
  6512.         
  6513.         E14.2 Setting the Field SeparatorF
  6514.         
  6515.          The  QTAwk input record separator, FS, may be set on the command
  6516.         line with the 'F' option.
  6517.         
  6518.                                  QTAwk -F "/:/"                          
  6519.         
  6520.          or
  6521.         
  6522.                                    QTAwk -F/:/                           
  6523.         
  6524.          The blank between the 'F' and the string or  regular  expression
  6525.         defining  the new input record separator is optional. This option
  6526.         may only be specified once on the command line. The command  line
  6527.         is scanned for all 'F' options prior to reading any utility files
  6528.         or input files. The option and the new  value  for  FS  are  then
  6529.         "removed from the command line and the command line count.
  6530.         
  6531.          Another  method is available for setting FS prior to reading the
  6532.         input files. This method is more general, may  be  used  multiple
  6533.         times  on  the  command  line  and may be used to set any utility
  6534.         variable and not just FS.
  6535.         
  6536.         E14.3 Setting Variables on the Command LineF
  6537.  
  6538.  
  6539.         QTAwk                       - 14-2 -                        QTAwk
  6540.  
  6541.  
  6542.  
  6543.  
  6544.  
  6545.  
  6546.         Section 14.3                                       Invoking QTAwk
  6547.  
  6548.  
  6549.          Including the following on the command line:
  6550.         
  6551.                                    var = value                           
  6552.         
  6553.          or
  6554.         
  6555.                                     var=value                            
  6556.         
  6557.          will set the variable 'var' to the value  specified.  'var'  may
  6558.         be  any  built-in  or user-defined variable in the QTAwk utility.
  6559.         'var' must be a variable defined in the current QTAwk utility  or
  6560.         a  run-time  error  will  occur  and  QTAwk will stop processing.
  6561.         
  6562.         E14.4 QTAwk Execution SequenceF
  6563.         
  6564.          QTAwk execution follows the following sequence:
  6565.         
  6566.         1.  The command line is scanned for any 'f' and 'F'  options.  If
  6567.             any such options are found, they are removed from the command
  6568.             line.
  6569.             
  6570.         2.  The QTAwk utility is read and processed. If any  'f'  options
  6571.             were  found  in  the  preceding  step, the associated utility
  6572.             files are opened, read and processed in the order  specified.
  6573.             If  no  'f'  options  were  specified, the first command line
  6574.             argument is processed as the QTAwk utility and  then  removed
  6575.             from the command line arguments.
  6576.             
  6577.         3.  The  ARGC  and  ARGV  built-in variables are set according to
  6578.             the command line parameters. The ARGI  built-in  variable  is
  6579.             set to 1.
  6580.             
  6581.         4.  Any  "BEGIN"  actions in the QTAwk utility are executed. This
  6582.             is done prior to any further interpretation  of  the  command
  6583.             line arguments.
  6584.             
  6585.         5.  The  command  line  argument, ARGV[ARGI], is examined. One of
  6586.             two actions is taken depending on the form of  the  argument:
  6587.                 
  6588.             a)  An argument of the form:
  6589.                 
  6590.                                        var = value                       
  6591.                 
  6592.                  or
  6593.                 
  6594.                                         var=value                        
  6595.  
  6596.  
  6597.         QTAwk                       - 14-3 -                        QTAwk
  6598.  
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604.         Section 14.4                                       Invoking QTAwk
  6605.  
  6606.  
  6607.                  is  interpreted  as  setting  the variable specified, to
  6608.                 the value specified.
  6609.                 
  6610.             b)  Any other argument is interpreted as  a  file  name.  The
  6611.                 file  specified is opened for input. If the file does not
  6612.                 exist, an error message is issued and  execution  halted.
  6613.                 If  a single hyphon, '-', is specified, it is interpreted
  6614.                 as representing the standard input file.  If  no  command
  6615.                 line  arguments are specified beyond the QTAwk utility or
  6616.                 variable setting commands, the  standard  input  file  is
  6617.                 read for input.
  6618.             
  6619.         6.  Any  "INITIAL"  actions  in  the  QTAwk utility are executed.
  6620.             
  6621.         7.  The input file is read record by record and  matched  against
  6622.             the   patterns   present   in   the   QTAwk  utility.  If  no
  6623.             pattern/action pairs are given in  the  QTAwk  utility,  each
  6624.             record  is  read, the NF, FNR, NR and field variables are set
  6625.             and the record is then discarded. If an 'exit'  or  'endfile'
  6626.             statement  is executed, action passes to the next step below.
  6627.             
  6628.         8.  When the end of the input file is reached  or  an  "exit"  or
  6629.             "endfile"  statement  is  executed,  any  'FINAL' actions are
  6630.             executed.
  6631.             
  6632.         9.  The input file is closed.
  6633.             
  6634.         10.  If an "exit" statement was executed,  processing  passes  to
  6635.             step 11) below, else the following steps are executed:
  6636.             
  6637.             a)  The  element  of ARGV corresponding the the current index
  6638.                 value of ARGI is sought. If  none  is  found,  processing
  6639.                 proceeds as if the "exit" statement was executed.
  6640.             b)  ARGI  is  set  to  the index value of the next element of
  6641.                 ARGV. If there is no next  element  of  ARGV,  processing
  6642.                 proceeds as if the "exit" statement was executed.
  6643.             c)  processing continues with step 5) above.
  6644.             
  6645.         11.  Any "END" actions in the QTAwk utility are executed.
  6646.             
  6647.         12.  QTAwk execution halts.
  6648.         
  6649.  
  6650.  
  6651.  
  6652.  
  6653.  
  6654.  
  6655.         QTAwk                       - 14-4 -                        QTAwk
  6656.  
  6657.  
  6658.  
  6659.  
  6660.  
  6661.  
  6662.         Section 15.0                                         QTAwk Limits
  6663.  
  6664.  
  6665.         E-15.0 LIMITSF-Ç
  6666.         
  6667.          QTAwk has the following limitations:
  6668.         
  6669.         1024 fields
  6670.             
  6671.         4096 characters per input record
  6672.             
  6673.         4096 characters per formatted output record
  6674.             
  6675.         256   characters   in  character  class  (with  character  ranges
  6676.             expanded)
  6677.             
  6678.         256 user-defined functions
  6679.             
  6680.         256 local variables
  6681.             
  6682.         256 global variables
  6683.             
  6684.         1024 characters in constant strings
  6685.             
  6686.         1024 characters in regular expressions on input
  6687.             
  6688.         4096 characters in regular expressions after expansion  of  named
  6689.             expressions and repetition operators.
  6690.             
  6691.         4096  characters  in  strings  used  as regular expressions after
  6692.             expansion of  named  expressions  and  repetition  operators.
  6693.             
  6694.         4096  characters  in  strings  returned  by  'replace'  functions
  6695.             
  6696.         4096 characters in input strings read by 'getline' and  fgetline'
  6697.             functions
  6698.             
  6699.         4096  characters  in  strings  after  substitution for 'gsub' and
  6700.             'sub' functions
  6701.             
  6702.         4096  characters  maximum  in  strings  returned   by   following
  6703.             functions:
  6704.             1.  copies
  6705.             2.  deletec
  6706.             3.  insert
  6707.             4.  overlay
  6708.             5.  remove
  6709.         
  6710.  
  6711.  
  6712.  
  6713.         QTAwk                       - 15-1 -                        QTAwk
  6714.  
  6715.  
  6716.  
  6717.  
  6718.  
  6719.  
  6720.  
  6721.  
  6722.  
  6723.  
  6724.  
  6725.  
  6726.  
  6727.  
  6728.  
  6729.  
  6730.  
  6731.  
  6732.  
  6733.  
  6734.  
  6735.  
  6736.  
  6737.  
  6738.  
  6739.  
  6740.  
  6741.  
  6742.  
  6743.  
  6744.  
  6745.  
  6746.  
  6747.  
  6748.  
  6749.  
  6750.  
  6751.  
  6752.  
  6753.  
  6754.  
  6755.  
  6756.  
  6757.  
  6758.  
  6759.  
  6760.  
  6761.  
  6762.  
  6763.  
  6764.  
  6765.  
  6766.  
  6767.  
  6768.  
  6769.  
  6770.  
  6771.         QTAwk                       - 15-2 -                        QTAwk
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.  
  6778.         Section 16.0                                           Appendix I
  6779.  
  6780.  
  6781.         E-16.0 Appendix IF-Ç
  6782.         
  6783.          ASCII character set
  6784.         ( escape sequences shown for non-printable characters )
  6785.         
  6786.         dec hex char        dec hex  char   dec hex char   dec  hex char
  6787.                           ╤               ╤              ╤
  6788.          0  00      NUL   │ 32  20    \s  │ 64  40  @    │ 96   60  `
  6789.          1  01  ^   SOH   │ 33  21   !    │ 65  41  A    │ 97   61  a
  6790.          2  02  ^   STX   │ 34  22   "    │ 66  42  B    │ 98   62  b
  6791.          3  03  ^   ETX   │ 35  23   #    │ 67  43  C    │ 99   63  c
  6792.          4  04  ^   EOT   │ 36  24   $    │ 68  44  D    │ 100  64  d
  6793.          5  05  ^   ENQ   │ 37  25   %    │ 69  45  E    │ 101  65  e
  6794.          6  06  ^   ACK   │ 38  26   &    │ 70  46  F    │ 102  66  f
  6795.          7  07  ^\a BEL   │ 39  27   '    │ 71  47  G    │ 103  67  g
  6796.          8  08  ^\b BS    │ 40  28   (    │ 72  48  H    │ 104  68  h
  6797.          9  09  ^    \t HT    │ 41  29   )    │ 73  49  I    │ 105  69  i
  6798.         10  0A  ^ \n LF    │ 42  2A   *    │ 74  4A  J    │ 106  6A  j
  6799.         11  0B  ^ \v VT    │ 43  2B   +    │ 75  4B  K    │ 107  6B  k
  6800.         12  0C  ^ \f FF    │ 44  2C   ,    │ 76  4C  L    │ 108  6C  l
  6801.         13  0D  ^\r CR    │ 45  2D   -    │ 77  4D  M    │ 109  6D  m
  6802.         14  0E  ^   SO    │ 46  2E   .    │ 78  4E  N    │ 110  6E  n
  6803.         15  0F  ^   SI    │ 47  2F   /    │ 79  4F  O    │ 111  6F  o
  6804.         16  10  ^   DLE   │ 48  30   0    │ 80  50  P    │ 112  70  p
  6805.         17  11  ^   DC1   │ 49  31   1    │ 81  51  Q    │ 113  71  q
  6806.         18  12  ^   DC2   │ 50  32   2    │ 82  52  R    │ 114  72  r
  6807.         19  13  ^   DC3   │ 51  33   3    │ 83  53  S    │ 115  73  s
  6808.         20  14  ^   DC4   │ 52  34   4    │ 84  54  T    │ 116  74  t
  6809.         21  15  ^   NAK   │ 53  35   5    │ 85  55  U    │ 117  75  u
  6810.         22  16  ^   SYN   │ 54  36   6    │ 86  56  V    │ 118  76  v
  6811.         23  17  ^   ETB   │ 55  37   7    │ 87  57  W    │ 119  77  w
  6812.         24  18  ^   CAN   │ 56  38   8    │ 88  58  X    │ 120  78  x
  6813.         25  19  ^         │ 57  39   9    │ 89  59  Y    │ 121  79  y
  6814.         26  1A      SUB   │ 58  3A   :    │ 90  5A  Z    │ 122  7A  z
  6815.         27  1B  ^   ESC   │ 59  3B   ;    │ 91  5B  [    │ 123  7B  {
  6816.         28  1C  ^   FS    │ 60  3C   <    │ 92  5C  \    │ 124  7C  |
  6817.         29  1D  ^   GS    │ 61  3D   =    │ 93  5D  ]    │ 125  7D  }
  6818.         30  1E  ^         │ 62  3E   >    │ 94  5E  ^    │ 126  7E  ~
  6819.         31  1F  ^         │ 63  3F   ?    │ 95  5F  _    │ 127  7F
  6820.         
  6821.  
  6822.  
  6823.  
  6824.  
  6825.  
  6826.  
  6827.  
  6828.  
  6829.         QTAwk                       - 16-1 -                        QTAwk
  6830.  
  6831.  
  6832.  
  6833.  
  6834.  
  6835.  
  6836.         Section 16.0                                           Appendix I
  6837.  
  6838.  
  6839.         ASCII character sets. (continued)
  6840.         
  6841.         dec  hex char  dec  hex char dec  hex char  dec  hex char
  6842.                      ╤             ╤              ╤
  6843.         128  80  ^Ç   │ 160  A0  á  │ 192  C0  └   │ 224  E0  α
  6844.         129  81  ^ü   │ 161  A1  í  │ 193  C1  ┴   │ 225  E1  ß
  6845.         130  82  ^é   │ 162  A2  ó  │ 194  C2  ┬   │ 226  E2  Γ
  6846.         131  83  ^â   │ 163  A3  ú  │ 195  C3  ├   │ 227  E3  π
  6847.         132  84  ^ä   │ 164  A4  ñ  │ 196  C4  ─   │ 228  E4  Σ
  6848.         133  85  ^à   │ 165  A5  Ñ  │ 197  C5  ┼   │ 229  E5  σ
  6849.         134  86  ^å   │ 166  A6  ª  │ 198  C6  ╞   │ 230  E6  µ
  6850.         135  87  ^ç   │ 167  A7  º  │ 199  C7  ╟   │ 231  E7  τ
  6851.         136  88  ^ê   │ 168  A8  ¿  │ 200  C8  ╚   │ 232  E8  Φ
  6852.         137  89  ^ë   │ 169  A9  ⌐  │ 201  C9  ╔   │ 233  E9  Θ
  6853.         138  8A  ^è   │ 170  AA  ¬  │ 202  CA  ╩   │ 234  EA  Ω
  6854.         139  8B  ^ï   │ 171  AB  ½  │ 203  CB  ╦   │ 235  EB  δ
  6855.         140  8C  ^î   │ 172  AC  ¼  │ 204  CC  ╠   │ 236  EC  ∞
  6856.         141  8D  ^ì   │ 173  AD  ¡  │ 205  CD  ═   │ 237  ED  φ
  6857.         142  8E  ^Ä   │ 174  AE  «  │ 206  CE  ╬   │ 238  EE  ε
  6858.         143  8F  ^Å   │ 175  AF  »  │ 207  CF  ╧   │ 239  EF  ∩
  6859.         144  90  ^É   │ 176  B0  ░  │ 208  D0  ╨   │ 240  F0  ≡
  6860.         145  91  ^æ   │ 177  B1  ▒  │ 209  D1  ╤   │ 241  F1  ±
  6861.         146  92  ^Æ   │ 178  B2  ▓  │ 210  D2  ╥   │ 242  F2  ≥
  6862.         147  93  ^ô   │ 179  B3  │  │ 211  D3  ╙   │ 243  F3  ≤
  6863.         148  94  ^ö   │ 180  B4  ┤  │ 212  D4  ╘   │ 244  F4  ⌠
  6864.         149  95  ^ò   │ 181  B5  ╡  │ 213  D5  ╒   │ 245  F5  ⌡
  6865.         150  96  ^û   │ 182  B6  ╢  │ 214  D6  ╓   │ 246  F6  ÷
  6866.         151  97  ^ù   │ 183  B7  ╖  │ 215  D7  ╫   │ 247  F7  ≈
  6867.         152  98  ^ÿ   │ 184  B8  ╕  │ 216  D8  ╪   │ 248  F8  °
  6868.         153  99  ^Ö   │ 185  B9  ╣  │ 217  D9  ┘   │ 249  F9  ∙
  6869.         154  9A  ^Ü   │ 186  BA  ║  │ 218  DA  ┌   │ 250  FA  ·
  6870.         155  9B  ^¢   │ 187  BB  ╗  │ 219  DB  █   │ 251  FB  √
  6871.         156  9C  ^£   │ 188  BC  ╝  │ 220  DC  ▄   │ 252  FC  ⁿ
  6872.         157  9D  ^¥   │ 189  BD  ╜  │ 221  DD  ▌   │ 253  FD  ²
  6873.         158  9E  ^₧   │ 190  BE  ╛  │ 222  DE  ▐   │ 254  FE  ■
  6874.         159  9F  ^ƒ   │ 191  BF  ┐  │ 223  DF  ▀   │ 255  FF
  6875.         
  6876.         
  6877.  
  6878.  
  6879.  
  6880.  
  6881.  
  6882.  
  6883.  
  6884.  
  6885.  
  6886.  
  6887.         QTAwk                       - 16-2 -                        QTAwk
  6888.  
  6889.  
  6890.  
  6891.  
  6892.  
  6893.  
  6894.         Section 17.0                                          Appendix II
  6895.  
  6896.  
  6897.         E-17.0 Appendix IIF-Ç
  6898.         
  6899.          Major differences between QTAwk and Awk.
  6900.         
  6901.         1.  Expanded Regular Expressions
  6902.             All  of the Awk regular expression operators are allowed plus
  6903.             the following:
  6904.             a)  complemented character  class  using  the  Awk  notation,
  6905.                 '[^...]', as well as the Awk/QTAwk and C logical negation
  6906.                 operator, '[!...]'.
  6907.                 
  6908.             b)  Matched character classes, '[#...]'.  These  classes  are
  6909.                 used  in  pairs. The position of the character matched in
  6910.                 the first class of the  pair,  determines  the  character
  6911.                 which  must  match in the position occupied by the second
  6912.                 class of the pair.
  6913.                 
  6914.             c)  Look-ahead Operator. r@t regular expression r is  matched
  6915.                 only when followed by regular expression t.
  6916.                 
  6917.             d)  Repetition  Operator.  r{n1,n2}  at least n1 and up to n2
  6918.                 repetitions of regular expression r. 1 <= n1 <= n2
  6919.                 
  6920.             e)  Named Expressions.
  6921.                 {named_expr} is replaced  by  the  string  value  of  the
  6922.                 corresponding variable.
  6923.             
  6924.         2.  Consistent  statement  termination  syntax. The QTAwk Utility
  6925.             Creation Tool utilizes the semi-colon, ';', to terminate  all
  6926.             statements.   The  practice  in  Awk  of  using  newlines  to
  6927.             "sometimes" terminate statements is no longer allowed.
  6928.             
  6929.         3.  Expanded Operator Set
  6930.             The Awk set of operators has been  changed  to  more  closely
  6931.             match  those  of  C.  The  Awk  match operator, '~', has been
  6932.             changed to '~~' so that  the  similarity  between  the  match
  6933.             operators, '~~' and '!~', to the equality operators, '==' and
  6934.             '!=", is complete. The single tilde symbol, '~',  reverts  to
  6935.             the  C one's complement operator, an addition to the operator
  6936.             set  over  Awk.  The  introduction  of  the  explicit  string
  6937.             concatenation  operator.  The  remaining  "new"  operators to
  6938.             QTAwk are:
  6939.  
  6940.  
  6941.  
  6942.  
  6943.  
  6944.  
  6945.         QTAwk                       - 17-1 -                        QTAwk
  6946.  
  6947.  
  6948.  
  6949.  
  6950.  
  6951.  
  6952.         Section 17.0                                          Appendix II
  6953.  
  6954.  
  6955.             Operation             Operator                               
  6956.             tag                   $$                                     
  6957.             one's complement      ~                                      
  6958.             concatenation         ∩                                      
  6959.             shift left/right      << >>                                  
  6960.             matching              ~~ !~                                  
  6961.             bit-wise AND          &                                      
  6962.             bit-wise XOR          @                                      
  6963.             bit-wise OR           |                                      
  6964.             sequence              ,                                      
  6965.             
  6966.              The carot, '^', remains as the exponentiation operator.  The
  6967.             symbol '@' is used for the exclusive OR operator.
  6968.             
  6969.         4.  Expanded  set  of  recognized  constants  in QTAwk utilities:
  6970.             a)  decimal integers,
  6971.             b)  octal integers,
  6972.             c)  hexadecimal integers,
  6973.             d)  character constants, and
  6974.             e)  floating point constants.
  6975.             
  6976.         5.  Expanded Pre-defined patterns giving more control:
  6977.             a)  INIITAL  -  similar  to  BEGIN.  Actions  executed  after
  6978.                 opening  each input file and before reading first record.
  6979.             b)  FINAL - similar to END. Actions  executed  after  reading
  6980.                 last  record  of each input file and before closing file.
  6981.             c)  NOMATCH - actions executed  for  each  input  record  for
  6982.                 which no pattern was matched.
  6983.             d)  GROUP  -  used  to group multiple regular expressions for
  6984.                 search optimization. Can speed search by a factor of six.
  6985.             
  6986.         6.  True multi-dimensional arrays
  6987.             The  use  of  the  comma  in  index  expressions  to simulate
  6988.             multiple array indices is no longer supported. True  multiple
  6989.             indices   are   supported.  Indexing  is  in  the  C  manner,
  6990.             'a[i1][i2]'. The SUBSEP built-in variable  of  AWK  has  been
  6991.             dropped since it is no longer necessary.
  6992.             
  6993.         7.  Integer array indices as well as string indices
  6994.             Array  indices have been expanded to include integers as well
  6995.             as the string indices of Awk. Indices are  not  automatically
  6996.             converted  to  strings  as  in  Awk.  Thus,  for true integer
  6997.             indices, the index ordering follows the numeric sequence with
  6998.             an  integer  index  value  of  '10'  following a value of '2'
  6999.             instead of preceeding it.
  7000.             
  7001.  
  7002.  
  7003.         QTAwk                       - 17-2 -                        QTAwk
  7004.  
  7005.  
  7006.  
  7007.  
  7008.  
  7009.  
  7010.         Section 17.0                                          Appendix II
  7011.  
  7012.  
  7013.         8.  Arrays integrated into QTAwk
  7014.             QTAwk integrates arrays with arithemetic  operators  so  that
  7015.             the  operations  are  carried  out on the entire array. QTAwk
  7016.             also integrates arrays into user-defined  functions  so  that
  7017.             they  can  be passed to and returned from such functions in a
  7018.             natural and intuitive manner. Awk does  not  allow  returning
  7019.             arrays   from  user-defined  functions  or  allow  arithmetic
  7020.             operators to operate on whole arrays.
  7021.             
  7022.         9.  NEW keywords:
  7023.             
  7024.             a)  cycle
  7025.                 similar to 'next' except that may use current  record  in
  7026.                 restarting outer pattern matching loop.
  7027.             b)  deletea
  7028.                 similiar   to  'delete'  except  that  ALL  array  values
  7029.                 deleted.
  7030.             c)  switch, case, default
  7031.                 similiar to C syntax with the allowed 'switch' and 'case'
  7032.                 values  expanded  to  include any legal QTAwk expression,
  7033.                 evaluated at run-time. The expressions  may  evaluate  to
  7034.                 any  value including any numeric value, string or regular
  7035.                 expression.
  7036.             d)  local
  7037.                 new keyword to allow the declaration  and  use  of  local
  7038.                 variables    within    compound   statements,   including
  7039.                 user-defined functions. Its use in user defined functions
  7040.                 instead  of  the  Awk  practice of defining excess formal
  7041.                 parameters,  leads  to  easier  to  read   and   maintain
  7042.                 functions. The C 'practice' of allowing initialization in
  7043.                 the 'local' statement is followed.
  7044.             e)  endfile
  7045.                 similar to 'exit'. Simulates end of  current  input  file
  7046.                 only,  any  remaining  input  files  are still processed.
  7047.             
  7048.         10.  Expanded arithmetic functions
  7049.             QTAwk includes 18 built-in arithmetic functions. All  of  the
  7050.             functions supported by Awk plus the following:
  7051.             a)  acos(x)
  7052.             b)  asin(x)
  7053.             c)  cosh(x)
  7054.             d)  fract(x)
  7055.             e)  log10(x)
  7056.             f)  pi() or pi
  7057.             g)  sinh(x)
  7058.             
  7059.  
  7060.  
  7061.         QTAwk                       - 17-3 -                        QTAwk
  7062.  
  7063.  
  7064.  
  7065.  
  7066.  
  7067.  
  7068.         Section 17.0                                          Appendix II
  7069.  
  7070.  
  7071.         11.  Expanded string functions
  7072.             QTAwk  includes  33  built-in  string  functions.  All of the
  7073.             functions supported by Awk plus the following:
  7074.             a)  center(s,w) or center(s,w,c)
  7075.             b)  copies(s,n)
  7076.             c)  deletec(s,p,n)
  7077.             d)  insert(s1,s2,p)
  7078.             e)  justify(a,n,w) or justify(a,n,w,c)
  7079.             f)  overlay(s1,s2,p)
  7080.             g)  remove(s,c)
  7081.             h)  replace(s)
  7082.             i)  sdate(fmt)
  7083.             j)  srange(c1,c2)
  7084.             k)  srev(s)
  7085.             l)  stime(fmt)
  7086.             m)  stran(s) or stran(s,st) or stran(s,st,sf)
  7087.             n)  strim(s) or strim(s,c) or strim(s,c,d)
  7088.             o)  strlwr(s)
  7089.             p)  strupr(s)
  7090.             
  7091.         12.  New Miscellaneous functions
  7092.             a)  The  function  'rotate(a)'  is  provided  to  rotate  the
  7093.                 elements of the array a.
  7094.             b)  execute(s) or execute(s,se) or execute(s,se,rf) - execute
  7095.                 string s
  7096.             c)  execute(a) or execute(a,se) or execute(a,se,rf) - execute
  7097.                 array a
  7098.             d)  pd_sym - access pre-defined symbols
  7099.             e)  ud_sym - access user defined symbols
  7100.             
  7101.         13.  New I/O functions
  7102.             I/O  function  syntax has been made consistent with syntax of
  7103.             other functions. The  redirection  operators,  '<',  '>'  and
  7104.             '>>',  and  pipeline  operator,  '|',  have  been  deleted as
  7105.             excessively error prone in expressions. The functional syntax
  7106.             of  the 'getline' function has been made identical to that of
  7107.             the other built-in functions. The new  functions  'fgetline',
  7108.             'fprint'  and  'fprintf' have been introduced for reading and
  7109.             writing to files other than the current input file.  The  new
  7110.             functions  'getc()'  and  'fgetc()'  have been introduced for
  7111.             single character input.
  7112.             
  7113.         14.  Expanded capability of formatted Output.
  7114.             The limited output formatting available with the Awk 'printf'
  7115.             function  has  been  expanded by adopting the complete output
  7116.             format specification of the draft ANSI C standard.
  7117.  
  7118.  
  7119.         QTAwk                       - 17-4 -                        QTAwk
  7120.  
  7121.  
  7122.  
  7123.  
  7124.  
  7125.  
  7126.         Section 17.0                                          Appendix II
  7127.  
  7128.  
  7129.         15.  Use of 'local' keyword
  7130.             The  'local'  keyword  has  been  introduced  to  allow   for
  7131.             variables  local  to user-defined functions (and any compound
  7132.             statement). This expansion makes the Awk practice of defining
  7133.             'extra' formal parameters no longer necessary.
  7134.             
  7135.         16.  Expanded user-defined functions
  7136.             With  the  'local'  keyword,  QTAwk allows the user to define
  7137.             functions that may accept a  variable  number  of  arguments.
  7138.             Functions,  such as finding the minimum/maximum of a variable
  7139.             number of variables, are possible with  one  function  rather
  7140.             than   defining   separate   functions   for   each  possible
  7141.             combination of arguments.
  7142.             
  7143.         17.  User controlled trace capability
  7144.             A user controlled statement trace capability has been  added.
  7145.             This  gives  the  user  a  simple  to  use mechanism to trace
  7146.             utility execution. Rather  than  adding  'print'  statements,
  7147.             merely re-defining the value of a built-in variable will give
  7148.             utility execution trace information, including  utility  line
  7149.             number.
  7150.             
  7151.         18.  Expanded built-in variable list
  7152.             With  30  built-in  variables,  QTAwk  includes all (with the
  7153.             exception of SUBSEP) of the built-in variables  of  Awk  plus
  7154.             the following:
  7155.             a)  _arg_chk  -  used to determine whether to check number of
  7156.                 arguments passed to user-defined functions.
  7157.             b)  ARGI - index value in ARGV of next command line argument.
  7158.                 Gives  more  control of command line argument processing.
  7159.             c)  CYCLE_COUNT - count number  of  outer  loop  cycles  with
  7160.                 current input record.
  7161.             d)  DEGREES  - if TRUE, trigonometric functions assume degree
  7162.                 values, radians if FALSE.
  7163.             e)  ENVIRON - array of environment strings  passed  to  QTAwk
  7164.             f)  FALSE - pre-defined with constant value, 0.
  7165.             g)  TRUE - predefined with constant value, 1
  7166.             h)  LONGEST_EXP  - used to control whether the longest or the
  7167.                 first string matching  a  regular  expression  is  found.
  7168.             i)  MAX_CYCLE - maximum number of outer loop cycles permitted
  7169.                 with current input record.
  7170.             j)  NG - equal to the number of the regular expression  in  a
  7171.                 group  matching  a  string  in  the current input record.
  7172.             k)  RETAIN_FS - if TRUE the  original  characters  separating
  7173.                 the  fields  of  the  current  input  record are retained
  7174.                 whenever a field is changed, causing the input record  to
  7175.  
  7176.  
  7177.         QTAwk                       - 17-5 -                        QTAwk
  7178.  
  7179.  
  7180.  
  7181.  
  7182.  
  7183.  
  7184.         Section 17.0                                          Appendix II
  7185.  
  7186.  
  7187.                 be  re-constructed.  If FALSE the output field separator,
  7188.                 OFS, is used to separate  fields  in  the  current  input
  7189.                 record  during reconstruction. The latter practice is the
  7190.                 only method available in Awk.
  7191.             l)  TRACE  -  value  used  to  determine  utility   statement
  7192.                 tracing.
  7193.             m)  TRANS_FROM/TRANS_TO - strings used by 'stran' function if
  7194.                 second and/or third arguments not specified.
  7195.             n)  CLENGTH - similiar to 'RLENGTH' of Awk.  Set  whenever  a
  7196.                 'case' value evaluates to a regular expression.
  7197.             o)  CSTART  -  similiar  to  'RSTART'  of Awk. Set whenever a
  7198.                 'case' value evaluates to a regular expression.
  7199.             p)  MLENGTH - similiar to 'RLENGTH' of Awk.  Set  whenever  a
  7200.                 stand-alone   regular   expression   is   encountered  in
  7201.                 evaluting a pattern.
  7202.             q)  MSTART - similiar to 'RSTART'  of  Awk.  Set  whenever  a
  7203.                 stand-alone   regular   expression   is   encountered  in
  7204.                 evaluting a pattern.
  7205.             r)  vargc - used only in used-defined functions defined  with
  7206.                 a  variable number of arguments. At runtime, set equal to
  7207.                 the actual number of variable arguments passed.
  7208.             s)  vargv - used only in used-defined functions defined  with
  7209.                 a  variable  number  of  arguments. At runtime, an single
  7210.                 dimensioned array with each element set to  the  argument
  7211.                 actually passed.
  7212.             
  7213.         19.  Definition  of  built-in  variable,  RS, expanded to include
  7214.             string form. If RS set to a string longer than one character,
  7215.             then  string  intrepreted  as  a  regular  expression and any
  7216.             string matching regular expression becomes record  separator.
  7217.             
  7218.         20.  In  QTAwk, setting built-in variable, "FILENAME", to another
  7219.             value  will  change  the  current  input  file.  Setting  the
  7220.             variable in Awk, has no effect on current input file.
  7221.             
  7222.         21.  Corrected   admitted   problems   with   Awk.  The  problems
  7223.             mentioned on page 182 of "The Awk Programming Language"  have
  7224.             been   corrected.  Specifically:  1)  true  multi-dimensional
  7225.             arrays have been implemented, 2)  the  'getline'  syntax  has
  7226.             been  made  to  match  that  of other functions, 3) declaring
  7227.             local variables in user-defined functions has been corrected,
  7228.             4)  intervening  blanks are allowed between the function call
  7229.             name and the opening parenthsis (in fact, under QTAwk  it  is
  7230.             permissable  to  have no opening parenthesis or argument list
  7231.             for user-defined functions that have  been  defined  with  no
  7232.             formal arguments).
  7233.  
  7234.  
  7235.         QTAwk                       - 17-6 -                        QTAwk
  7236.  
  7237.  
  7238.  
  7239.  
  7240.  
  7241.  
  7242.         Section 18.0                                         Appendix III
  7243.  
  7244.  
  7245.         E-18.0 Appendix IIIF-Ç
  7246.         
  7247.         
  7248.          The  following QTAwk utility is designed to search C source code
  7249.         files for keywords defined in the ANSI C standard. It is included
  7250.         here to illustrate the use of the the 'GROUP' keyword.
  7251.         
  7252.         # QTAwk utility to scan C source files for keywords
  7253.         # defined in the ANSI C standard keywords:
  7254.         # macro or function names defined in the standard
  7255.         # types or constants defined in the standard
  7256.         #
  7257.         # program to illustrate GROUP pattern keyword
  7258.         #
  7259.         # input: C source file
  7260.         #  output:  all lines containing ANSI C standard defined keywords
  7261.         #
  7262.         # use 'GROUP' pattern keyword to form one large GROUP of
  7263.         # patterns to speed search. Only two actions defined:
  7264.         # 1) action to print macro or function names
  7265.         # 2) action to print types or constants
  7266.         #
  7267.         #
  7268.         BEGIN {
  7269.                 #
  7270.                 # ANSI C key words
  7271.                 #
  7272.                 # expression for leader
  7273.             ldr = /(^|[\s\t])/;
  7274.                 # opening function parenthesis - look-ahead to find
  7275.             o_p = /@[\s\t]*\(/;
  7276.                 #
  7277.                 # define strings for formatted output
  7278.                 #
  7279.             tls = "Total Lines Scanned: %lu\n";
  7280.             tlc = "Total Line containing macro/function names: %lu\n";
  7281.             tlt = "Total Line containing type/constant names: %lu\n";
  7282.         }
  7283.                 #
  7284.                 #
  7285.                 # Following are macro or functions names as defined
  7286.                 # by ANSI C standard
  7287.                 #
  7288.                 # 1
  7289.         GROUP /{ldr}assert{o_p}/
  7290.                 # 2
  7291.  
  7292.  
  7293.         QTAwk                       - 18-1 -                        QTAwk
  7294.  
  7295.  
  7296.  
  7297.  
  7298.  
  7299.  
  7300.         Section 18.0                                         Appendix III
  7301.  
  7302.  
  7303.                 # Following regular expression split across 2 lines
  7304.                 # for documentation only.
  7305.         GROUP /{ldr}is(al(num|pha)|cntrl|x?digit|graph|
  7306.             p(rint|unct)|space|(low|upp)er){o_p}/
  7307.                 # 3
  7308.         GROUP /{ldr}to(low|upp)er{o_p}/
  7309.                 # 4
  7310.         GROUP /{ldr}set(locale|v?buf){o_p}/
  7311.                 # 5
  7312.         GROUP /{ldr}a(cos|sin|tan2?|bort){o_p}/
  7313.                 # 6
  7314.         GROUP /{ldr}(cos|sin|tan)h?{o_p}/
  7315.                 # 7
  7316.         GROUP /{ldr}(fr|ld)?exp{o_p}/
  7317.                 # 8
  7318.         GROUP /{ldr}log(10)?{o_p}/
  7319.                 # 9
  7320.         GROUP /{ldr}modf{o_p}/
  7321.                 # 10
  7322.         GROUP /{ldr}pow{o_p}/
  7323.                 # 11
  7324.         GROUP /{ldr}sqrt{o_p}/
  7325.                 # 12
  7326.         GROUP /{ldr}ceil{o_p}/
  7327.                 # 13
  7328.         GROUP /{ldr}(f|l)?abs{o_p}/
  7329.                 # 14
  7330.         GROUP /{ldr}f(loor|mod){o_p}/
  7331.                 # 15
  7332.         GROUP /{ldr}jmp_buf{o_p}/
  7333.                 # 16
  7334.         GROUP /{ldr}(set|long)jmp{o_p}/
  7335.                 # 17
  7336.         GROUP /{ldr}signal{o_p}/
  7337.                 # 18
  7338.         GROUP /{ldr}raise{o_p}/
  7339.                 # 19
  7340.         GROUP /{ldr}va_(arg|end|list|start){o_p}/
  7341.                 # 20
  7342.         GROUP /{ldr}re(move|name|wind){o_p}/
  7343.                 # 21
  7344.         GROUP /{ldr}tmp(file|nam){o_p}/
  7345.                 # 22
  7346.         GROUP /{ldr}(v?[fs])?printf{o_p}/
  7347.                 # 23
  7348.         GROUP /{ldr}[fs]?scanf{o_p}/
  7349.  
  7350.  
  7351.         QTAwk                       - 18-2 -                        QTAwk
  7352.  
  7353.  
  7354.  
  7355.  
  7356.  
  7357.  
  7358.         Section 18.0                                         Appendix III
  7359.  
  7360.  
  7361.                 # 24
  7362.         GROUP /{ldr}f?get(c(har)?|s|env){o_p}/
  7363.                 # 25
  7364.         GROUP /{ldr}f?put(c(har)?|s){o_p}/
  7365.                 # 26
  7366.         GROUP /{ldr}ungetc{o_p}/
  7367.                 # 27
  7368.                 # Following regular expression split across 2 lines
  7369.                 # for documentation only.
  7370.         GROUP /{ldr}f(close|flush|(re)?open|read|write|
  7371.             [gs]etpos|seek|tell|eof|ree|pos_t){o_p}/
  7372.                 # 28
  7373.         GROUP /{ldr}clearerr{o_p}/
  7374.                 # 29
  7375.         GROUP /{ldr}[fp]error{o_p}/
  7376.                 # 30
  7377.         GROUP /{ldr}ato[fil]{o_p}/
  7378.                 # 31
  7379.                 # Following regular expression split across 2 lines
  7380.                 # for documentation only.
  7381.         GROUP /{ldr}str(to(d|k|u?l)|n?c(py|at|mp)|
  7382.             coll|r?chr|c?spn|pbrk|str|error|len){o_p}/
  7383.                 # 32
  7384.         GROUP /{ldr}s?rand{o_p}/
  7385.                 # 33
  7386.         GROUP /{ldr}(c|m|re)?alloc{o_p}/
  7387.                 # 34
  7388.         GROUP /{ldr}_?exit{o_p}/
  7389.                 # 35
  7390.         GROUP /{ldr}(f|mk|asc|c|gm|local|strf)?time{o_p}/ {
  7391.             printf("Macro/function\n%uE - %luR: %s\n%s\n",NG,FNR,$0,$$0);
  7392.             mf_count++;
  7393.         }
  7394.                 #
  7395.                 # following are types or constants
  7396.                 #
  7397.                 # 36
  7398.         GROUP /errno/
  7399.                 # 37
  7400.         GROUP /NULL/
  7401.                 # 38
  7402.         GROUP /offsetof/
  7403.                 # 39
  7404.         GROUP /(fpos|ptrdiff|size|wchar)_t/
  7405.                 # 41
  7406.         GROUP /NDEBUG/
  7407.  
  7408.  
  7409.         QTAwk                       - 18-3 -                        QTAwk
  7410.  
  7411.  
  7412.  
  7413.  
  7414.  
  7415.  
  7416.         Section 18.0                                         Appendix III
  7417.  
  7418.  
  7419.                 # 42
  7420.         GROUP /LC_(ALL|COLLATE|CTYPE|NUMERIC|TIME)/
  7421.                 # 43
  7422.         GROUP /E(DOM|RANGE|OF)/
  7423.                 # 44
  7424.         GROUP /HUGE_VAL/
  7425.                 # 45
  7426.         GROUP /sig_atomic_t/
  7427.                 # 46
  7428.         GROUP /SIG(_(DFL|ERR|IGN)|ABRT|FPE|ILL|INT|SEGV|TERM)/
  7429.                 # 47
  7430.         GROUP /FILE/
  7431.                 # 48
  7432.         GROUP /_IO[FLN]BF/
  7433.                 # 49
  7434.         GROUP /BUFSIZ/
  7435.                 # 50
  7436.         GROUP /L_tmpnam/
  7437.                 # 51
  7438.         GROUP /(OPEN|RAND|TMP|U(CHAR|INT|LONG|SHRT))_MAX/
  7439.                 # 52
  7440.         GROUP /SEEK_(CUR|END|SET)/
  7441.                 # 53
  7442.         GROUP /std(err|in|out)/
  7443.                 # 54
  7444.         GROUP /l?div_t/
  7445.                 # 55
  7446.         GROUP /CLK_TCK/
  7447.                 # 56
  7448.         GROUP /(clock|time)_t/
  7449.                 # 57
  7450.         GROUP /tm_(sec|min|hour|[mwy]day|mon|year|isdst)/
  7451.                 # 58
  7452.         GROUP /CHAR_(BIT|M(AX|IN))/
  7453.                 # 59
  7454.         GROUP /(INT|LONG|S(CHAR|HRT))_(M(IN|AX))/
  7455.                 # 60
  7456.         GROUP   /(L?DBL|FLT)_((MANT_)?DIG|EPSILON|M(AX|IN)(_(10_)?EXP)?)/
  7457.                 # 61
  7458.         GROUP /FLT_R(ADIX|OUNDS)/ {
  7459.             printf("type/constant\n%uE - %luR: %s\n%s\n",NG,FNR,$0,$$0);
  7460.             tc_count++;
  7461.         }
  7462.         
  7463.         FINAL {
  7464.             printf(tls,FNR);
  7465.  
  7466.  
  7467.         QTAwk                       - 18-4 -                        QTAwk
  7468.  
  7469.  
  7470.  
  7471.  
  7472.  
  7473.  
  7474.         Section 18.0                                         Appendix III
  7475.  
  7476.  
  7477.             printf(tlc,mf_count);
  7478.             printf(tlt,tc_count);
  7479.         }
  7480.         
  7481.  
  7482.  
  7483.  
  7484.  
  7485.  
  7486.  
  7487.  
  7488.  
  7489.  
  7490.  
  7491.  
  7492.  
  7493.  
  7494.  
  7495.  
  7496.  
  7497.  
  7498.  
  7499.  
  7500.  
  7501.  
  7502.  
  7503.  
  7504.  
  7505.  
  7506.  
  7507.  
  7508.  
  7509.  
  7510.  
  7511.  
  7512.  
  7513.  
  7514.  
  7515.  
  7516.  
  7517.  
  7518.  
  7519.  
  7520.  
  7521.  
  7522.  
  7523.  
  7524.  
  7525.         QTAwk                       - 18-5 -                        QTAwk
  7526.  
  7527.  
  7528.  
  7529.  
  7530.  
  7531.  
  7532.  
  7533.  
  7534.  
  7535.  
  7536.  
  7537.  
  7538.  
  7539.  
  7540.  
  7541.  
  7542.  
  7543.  
  7544.  
  7545.  
  7546.  
  7547.  
  7548.  
  7549.  
  7550.  
  7551.  
  7552.  
  7553.  
  7554.  
  7555.  
  7556.  
  7557.  
  7558.  
  7559.  
  7560.  
  7561.  
  7562.  
  7563.  
  7564.  
  7565.  
  7566.  
  7567.  
  7568.  
  7569.  
  7570.  
  7571.  
  7572.  
  7573.  
  7574.  
  7575.  
  7576.  
  7577.  
  7578.  
  7579.  
  7580.  
  7581.  
  7582.  
  7583.         QTAwk                       - 18-6 -                        QTAwk
  7584.  
  7585.  
  7586.  
  7587.  
  7588.  
  7589.  
  7590.         Section 19.0                                          Appendix IV
  7591.  
  7592.  
  7593.         E-19.0 Appendix IVF-Ç
  7594.         
  7595.          This is a complete copy of the data file, states.dta, used in to
  7596.         illustrate QTAwk. The fields of the first record for the  default
  7597.         field  separator  FS  =  /{_z}+/  is  shown below followed by the
  7598.         fields for  the  record  separator  FS  =  /{_w}+[\#()]({_w}+|$)/
  7599.         
  7600.         
  7601.          Fields for Default FS = /{_z}+/
  7602.         1.  US -- country/continent name
  7603.         2.  # -- separator
  7604.         3.  47750 -- area, square miles
  7605.         4.  # -- separator
  7606.         5.  4515 -- population in thousands
  7607.         6.  # -- separator
  7608.         7.  LA -- abbreviation (US & Canada only)
  7609.         8.  # -- separator
  7610.         9.  Baton -- first half capital city name
  7611.         10.  Rouge -- second half capital city name
  7612.         11.  ( -- separator
  7613.         12.  Louisiana -- state/country name
  7614.         13.  ) -- Terminator
  7615.         
  7616.          .so off Fields for FS = /[\s\t]+[\#()]([\s\t]+|$)/:
  7617.         1.  US -- country/continent name
  7618.         2.  47750 -- area, square miles
  7619.         3.  4515 -- population in thousands
  7620.         4.  LA -- abbreviation (US & Canada only)
  7621.         5.  Baton Rouge -- full capital city name
  7622.         6.  Louisiana -- state/country name
  7623.         
  7624.         US # 10461 # 4375 # MD # Annapolis ( Maryland )
  7625.         US # 40763 # 5630 # VA # Richmond ( Virgina )
  7626.         US # 2045 # 620 # DE # Dover ( Delaware )
  7627.         US # 24236 # 1995 # WV # Charleston ( West Virginia )
  7628.         US # 46047 # 12025 # PA # Harrisburg ( Pennsylvania )
  7629.         US # 7787 # 7555 # NJ # Trenton ( New Jersey )
  7630.         US # 52737 # 17895 # NY # Albany ( New York )
  7631.         US # 9614 # 535 # VT # Montpelier ( Vermont )
  7632.         US # 9278 # 975 # NH # Concord ( New Hampshire )
  7633.         US # 33265 # 1165 # ME # Augusta ( Maine )
  7634.         US # 8286 # 5820 # MA # Boston ( Massachusetts )
  7635.         US # 5019 # 3160 # CT # Hartford ( Conneticut )
  7636.         US # 1212 # 975 # RI # Providence ( Rhode Island )
  7637.         US # 52669 # 6180 # NC # Raleigh ( North Carolina )
  7638.         US # 31116 # 3325 # SC # Columbia ( South Carolina )
  7639.  
  7640.  
  7641.         QTAwk                       - 19-1 -                        QTAwk
  7642.  
  7643.  
  7644.  
  7645.  
  7646.  
  7647.  
  7648.         Section 19.0                                          Appendix IV
  7649.  
  7650.  
  7651.         US # 58914 # 5820 # GA # Atlanta ( Georgia )
  7652.         US # 51704 # 4015 # AL # Montgomery ( Alabama )
  7653.         US # 42143 # 4755 # TN # Nashville ( Tennessee )
  7654.         US # 40414 # 3780 # KY # Frankfort ( Kentucky )
  7655.         US # 58668 # 10925 # FL # Tallahassee ( Florida )
  7656.         US # 68139 # 4395 # WA # Olympia ( Washington )
  7657.         US # 412582 # 8985 # OR # Salem ( Oregon )
  7658.         US # 147045 # 830 # MT # Helena ( Montana )
  7659.         US # 83566 # 1020 # ID # Boise ( Idaho )
  7660.         US # 110562 # 945 # NV # Carson City ( Nevada )
  7661.         US # 84902 # 1690 # UT # Salt Lake City ( Utah )
  7662.         US # 97808 # 525 # WY # Cheyenne ( Wyoming )
  7663.         US # 104094 # 3210 # CO # Denver ( Colorado )
  7664.         US # 158704 # 25620 # CA # Sacramento ( California )
  7665.         US # 121594 # 1425 # NM # Sante Fe ( New Mexico )
  7666.         US # 114002 # 3040 # AZ # Phoenix ( Arizona )
  7667.         US # 70702 # 690 # ND # Bismark ( North Dakota )
  7668.         US # 77120 # 715 # SD # Pierre ( South Dakota )
  7669.         US # 77350 # 1615 # NE # Lincoln ( Nebraska )
  7670.         US # 82282 # 2450 # KS # Topeka ( Kansas )
  7671.         US # 69697 # 5040 # MO # Jefferson City ( Missouri )
  7672.         US # 69957 # 3375 # OK # Oklahoma City ( Oklahoma )
  7673.         US # 266805 # 16090 # TX # Austin ( Texas )
  7674.         US # 86614 # 4205 # MN # St Paul ( Minnesota )
  7675.         US # 56275 # 2970 # IA # Des Moines ( Iowa )
  7676.         US # 53191 # 2375 # AR # Little Rock ( Arkansas )
  7677.         US # 47750 # 4515 # LA # Baton Rouge ( Louisiana )
  7678.         US # 47691 # 2640 # MS # Jackson ( Mississippi )
  7679.         US # 57872 # 11620 # IL # Springfield ( Illinois )
  7680.         US # 66213 # 4800 # WI # Madison ( Wisconsin )
  7681.         US # 97107 # 9090 # MI # Lansing ( Michigan )
  7682.         US # 36417 # 5585 # IN # Indianapolis ( Indiana )
  7683.         US # 44786 # 10760 # OH # Columbus ( Ohio )
  7684.         US # 591004 # 515 # AK # Juneau ( Alaska )
  7685.         US # 6473 # 1045 # HI # Honolulu ( Hawaii )
  7686.         Canada # 255285 # 2370 # AB # Edmonton ( Alberta )
  7687.         Canada  #  366255  #  2885  #  BC # Victoria ( British Columbia )
  7688.         Canada # 251000 # 1060 # MB # Winnipeg ( Manitoba )
  7689.         Canada # 251700 # 1010 # SK # Regina ( Saskatchewan )
  7690.         Canada # 21425 # 875 # NS # Halifax ( Nova Scotia )
  7691.         Canada # 594860 # 6585 # PQ # Quebec ( Quebec )
  7692.         Canada # 2184 # 126 # PE # Charlottetown ( Prince Edward Island )
  7693.         Canada # 156185 # 585 # NF # St John's ( New Foundland )
  7694.         Canada # 28354 # 715 # NB # Fredericton ( New Brunswick )
  7695.         Canada # 412582 # 8985 # ON # Toronto ( Ontario )
  7696.         Canada  # 1304903 # 51 # NW # Yellowknife ( Northwest Territories
  7697.  
  7698.  
  7699.         QTAwk                       - 19-2 -                        QTAwk
  7700.  
  7701.  
  7702.  
  7703.  
  7704.  
  7705.  
  7706.         Section 19.0                                          Appendix IV
  7707.  
  7708.  
  7709.         )
  7710.         Canada # 186300 # 23 # YU # Whitehorse ( Yukon Territory )
  7711.         Europe # 92100 # 14030 # Bonn ( West Germany )
  7712.         Europe # 211208 # 55020 # Paris ( France )
  7713.         Europe # 94092 # 56040 # London ( United Kingdom )
  7714.         Europe # 27136 # 3595 # Dublin ( Ireland )
  7715.         Europe # 194882 # 38515 # Madrid ( Spain )
  7716.         Europe # 116319 # 56940 # Rome ( Italy )
  7717.         Europe # 8600383 # 275590 # Moscow ( Russia )
  7718.         Europe # 120728 # 37055 # Warsaw ( Poland )
  7719.         Europe # 32377 # 7580 # Vienna ( Autria )
  7720.         Europe # 35921 # 10675 # Budapest ( Hungary )
  7721.         
  7722.  
  7723.  
  7724.  
  7725.  
  7726.  
  7727.  
  7728.  
  7729.  
  7730.  
  7731.  
  7732.  
  7733.  
  7734.  
  7735.  
  7736.  
  7737.  
  7738.  
  7739.  
  7740.  
  7741.  
  7742.  
  7743.  
  7744.  
  7745.  
  7746.  
  7747.  
  7748.  
  7749.  
  7750.  
  7751.  
  7752.  
  7753.  
  7754.  
  7755.  
  7756.  
  7757.         QTAwk                       - 19-3 -                        QTAwk
  7758.  
  7759.  
  7760.  
  7761.  
  7762.  
  7763.  
  7764.  
  7765.  
  7766.  
  7767.  
  7768.  
  7769.  
  7770.  
  7771.  
  7772.  
  7773.  
  7774.  
  7775.  
  7776.  
  7777.  
  7778.  
  7779.  
  7780.  
  7781.  
  7782.  
  7783.  
  7784.  
  7785.  
  7786.  
  7787.  
  7788.  
  7789.  
  7790.  
  7791.  
  7792.  
  7793.  
  7794.  
  7795.  
  7796.  
  7797.  
  7798.  
  7799.  
  7800.  
  7801.  
  7802.  
  7803.  
  7804.  
  7805.  
  7806.  
  7807.  
  7808.  
  7809.  
  7810.  
  7811.  
  7812.  
  7813.  
  7814.  
  7815.         QTAwk                       - 19-4 -                        QTAwk
  7816.  
  7817.  
  7818.  
  7819.  
  7820.  
  7821.  
  7822.         Section 20.0                                           Appendix V
  7823.  
  7824.  
  7825.         E-20.0 Appendix VF-Ç
  7826.         
  7827.          QTAwk error returns. When QTAwk encounters  an  error  which  it
  7828.         cannot  correct,  it  genmerates and displays an error message in
  7829.         the format:
  7830.         
  7831.         1: Error (xxxx): Error Message Text
  7832.         2: From 'execute' Function.
  7833.         3: Action File line: llll
  7834.         4: Scanning File: utility filename
  7835.         5: Line: llll
  7836.         6: Record: rrrr
  7837.         
  7838.          Line 2 is generated only if the error occured  during  execution
  7839.         of  the 'execute' function. Lines 4 to 6 are displayed only if an
  7840.         input file is currently being scanned.
  7841.         
  7842.          On a normal exit QTAwk returns a value of zero, 0, to PC/MS-DOS.
  7843.         This  value may be set with the 'exit' statement. On encountering
  7844.         an error which generates an error message,  QTAwk  exits  with  a
  7845.         non-zero  value  between 1 and 6. The worning messages below will
  7846.         exit with a value of zero. The exit values generated on detecting
  7847.         an error are:
  7848.         
  7849.         1.  Warning Errors ==> 0 , error value < 1000
  7850.         2.  File Errors ==> 2 , 2000 <= error value < 3000
  7851.         3.  Regular  Expression Errors ==> 3 , 3000 <= error value < 4000
  7852.         4.  Run-Time Errors ==> 4 , 4000 <= error value < 5000
  7853.         5.  Interpretation Errors ==> 5 , 5000  <=  error  value  <  6000
  7854.         6.  Memory Error ==> 6 , 6000 <= error value < 7000
  7855.         
  7856.          The 'error value' range shown in the above list, shown the range
  7857.         of the numeric value shown in the error message for that type  of
  7858.         error.
  7859.         
  7860.          The  error  number  displayed  on line 1 may be used to find the
  7861.         error diagnostic from the following listing.
  7862.         
  7863.         1.  Warning Errors
  7864.             0
  7865.                 Invalid Option.
  7866.                 The only valid command line options are:
  7867.                 -- -> to stop command line option scanning
  7868.                 -f -> to specify a utility filename
  7869.                 -F -> to specify the input record field separator.
  7870.                 
  7871.  
  7872.  
  7873.         QTAwk                       - 20-1 -                        QTAwk
  7874.  
  7875.  
  7876.  
  7877.  
  7878.  
  7879.  
  7880.         Section 20.0                                           Appendix V
  7881.  
  7882.  
  7883.             10
  7884.                 Warning, Attempt To Close File Not Open.
  7885.                 An attempt has been made to close a file with the 'close'
  7886.                 function, that is not currently open.
  7887.             
  7888.         2.  File Errors
  7889.             2000
  7890.             2010
  7891.                 File Not Found: {filename}
  7892.                 The  filename  given  in  the  error  message,  was  been
  7893.                 specified on the command line. The file  named  does  not
  7894.                 exist.  QTAwk  displays this error message and terminates
  7895.                 processing.
  7896.             
  7897.         3.  Regular Expression Errors
  7898.             3000
  7899.                 Stop pattern without a start
  7900.                 The range pattern has the form:
  7901.                 
  7902.                                  expression , expression                 
  7903.                 
  7904.                  The comma, ',', is used to separate the  expressions  of
  7905.                 the  pattern.  The associated action is executed when the
  7906.                 first or start expression is  TRUE.  Execution  continues
  7907.                 for  every  input record until, and including, the second
  7908.                 or stop expression is TRUE. A comma, ',', has been  found
  7909.                 in  a  pattern  without  the  first  expression.  This is
  7910.                 usually caused by  inbalanced  braces,  "{}".  Check  all
  7911.                 prior braces to ensure that every left brace, '{', has an
  7912.                 associated terminating right brace, '}'.
  7913.                 
  7914.             3010
  7915.                 Already have a stop pattern
  7916.                 The range pattern has the form: expression  ,  expression
  7917.                 The  comma,  ',',  is used to separate the expressions of
  7918.                 the pattern. The associated action is executed  when  the
  7919.                 first  or  start  expression is TRUE. Execution continues
  7920.                 for every input record until, and including,  the  second
  7921.                 or stop expression is TRUE. A second comma, ',', has been
  7922.                 found in a pattern. This may be caused by the  unbalanced
  7923.                 braces as for error number 3000 above. A second cause may
  7924.                 stem from the fact that new patterns  for  pattern/action
  7925.                 pairs  must  be  separated  from  previous  patterns by a
  7926.                 new-line if no  action,  i.e.,  the  dafault  action,  is
  7927.                 associated with the previous pattern.
  7928.             
  7929.  
  7930.  
  7931.         QTAwk                       - 20-2 -                        QTAwk
  7932.  
  7933.  
  7934.  
  7935.  
  7936.  
  7937.  
  7938.         Section 20.0                                           Appendix V
  7939.  
  7940.  
  7941.         4.  Run-Time Errors
  7942.             4000
  7943.                 Command Line Variable Set - Not Used.
  7944.                 Only variables defined in the QTAwk utility may be set on
  7945.                 the command line with the form "variable = value"
  7946.                 
  7947.             4010
  7948.                 Missing Opening Parenthesis On 'while'.
  7949.                 The proper syntax for the 'while' statement is:
  7950.                 
  7951.                 while ( conditional_expression ) statement
  7952.                 
  7953.                 The  left  parenthesis,  '(',  starting  the  conditional
  7954.                 expression  was  not found following the 'while' keyword.
  7955.                 Check that the syntax conforms to the form above.
  7956.                 
  7957.             4020
  7958.                 Missing Opening Parenthesis On 'switch'.
  7959.                 The form of the 'switch' construct is:
  7960.                 
  7961.                 switch ( switch_expression ) statement
  7962.                 
  7963.                 The left parenthesis, '(', was not  found  following  the
  7964.                 'switch' keyword.
  7965.                 
  7966.             4030
  7967.                 Unable to compile regular Expression
  7968.                 QTAwk  was  unable  to  convert  a  regular expression to
  7969.                 internal form.  Please  contact  the  QTAwk  author  with
  7970.                 information  on  the circumstances of this error message.
  7971.                 
  7972.             4040
  7973.                 Internal Array Error.
  7974.                 Internal error. Please  contact  the  QTAwk  author  with
  7975.                 information  on  the circumstances of this error message.
  7976.                 
  7977.             4050
  7978.                 pre/post '++' or '--' Needs a Variable.
  7979.                 The pre/post ++/-- operators operate on  variables  only.
  7980.                 This  error  is usually generated because of an incorrect
  7981.                 understanding of the precedence rules. The  operator  was
  7982.                 associated by QTAwk when the utility line was parsed than
  7983.                 the user expected. Check the  precedence  rules  and  the
  7984.                 syntax of the line cited.
  7985.                 
  7986.             4060
  7987.  
  7988.  
  7989.         QTAwk                       - 20-3 -                        QTAwk
  7990.  
  7991.  
  7992.  
  7993.  
  7994.  
  7995.  
  7996.         Section 20.0                                           Appendix V
  7997.  
  7998.  
  7999.                 '$$' will accept '0' argument only.
  8000.                 The '$$' operator assumes the value of the string matched
  8001.                 by the last explicit or implicit match operator, '~~'  or
  8002.                 '!~'.  Implicit  matching  is  done in patterns. The only
  8003.                 value which is permissable for the '$$' operator is zero.
  8004.                 
  8005.             4070
  8006.                 Undefined Symbol.
  8007.                 A  symbol  has been found which QTAwk does not recognize.
  8008.                 This error should not occur and  represents  an  internal
  8009.                 error.  Please  contact the QTAwk author with information
  8010.                 on the circumstances of this error message.
  8011.                 
  8012.             4080
  8013.                 Internal Error #200
  8014.                 Internal error. Please  contact  the  QTAwk  author  with
  8015.                 information  on  the circumstances of this error message.
  8016.                 
  8017.             4090
  8018.                 Attempt To Delete Non-existent Array Element.
  8019.                 The 'delete' statement was followed with a  reference  to
  8020.                 an array element that does not exist.
  8021.                 
  8022.             4100
  8023.                 Internal GROUP parse error 1001.
  8024.                 Internal  error.  Please  contact  the  QTAwk author with
  8025.                 information on the circumstances of this  error  message.
  8026.                 
  8027.             4100
  8028.                 Warning, Attempt To Close File Not Successful.
  8029.                 An attempt has been made to close a file with the 'close'
  8030.                 function. The  close  action  has  not  been  successful,
  8031.                 usually  because the file named does not exist. Check the
  8032.                 name specified.
  8033.                 
  8034.             4110
  8035.                 'strim' Function Result Exceeds Limits.
  8036.                 The built-in function 'strim'  has  been  called  with  a
  8037.                 string  to  trim which exceeds the maximum limits of 4096
  8038.                 characters.
  8039.                 
  8040.             4120
  8041.                 Cannot Nest 'execute' Function.
  8042.                 The  'execute'  function  cannot  be  executed   with   a
  8043.                 string/array  executed  by  this function. An attempt has
  8044.                 been made to do this. Check the  string/array  which  was
  8045.  
  8046.  
  8047.         QTAwk                       - 20-4 -                        QTAwk
  8048.  
  8049.  
  8050.  
  8051.  
  8052.  
  8053.  
  8054.         Section 20.0                                           Appendix V
  8055.  
  8056.  
  8057.                 executed.
  8058.                 
  8059.             4130
  8060.                 '(g)sub' Function Result Exceeds Limits.
  8061.                 The  function  'sub' or 'gsub' has been called to replace
  8062.                 matching  strings  and   the   resultant   string   after
  8063.                 replacement  would  exceed  the limit of 4096 characters.
  8064.                 
  8065.             4140
  8066.                 Missing ')' for Function Call.
  8067.                 A  built-in  function  has  been  called  with   a   left
  8068.                 parenthesis  starting  the  argument  list,  but no right
  8069.                 parenthesis terminating the argument list. Check the line
  8070.                 in question.
  8071.                 
  8072.             4150
  8073.                 [sf]printf functions take a minimum of 1 argument.
  8074.                 The  first  arguments  for  the  'fprintf'  and 'sprintf'
  8075.                 functions are necessary to specify  the  file  or  string
  8076.                 respectively as the target for the output string.
  8077.                 
  8078.             4160
  8079.                 [sf]printf needs format string as first argument
  8080.                 The  'fprintf'  and  'sprintf'  functions  need  a format
  8081.                 string which specifies the output. The format  string  is
  8082.                 the  second  argument  and  must  be  specified for these
  8083.                 functions.
  8084.                 
  8085.             4170
  8086.             4180
  8087.             4190
  8088.                 Format Specifications Exceed Arguments To Print.
  8089.                 The 'printf', fprintf'  and  'sprintf'  functions  use  a
  8090.                 format  string  to control the output. Certain characters
  8091.                 strings in the format control the output of numerics  and
  8092.                 imbedded   strings.  There  must  be  exactly  one  extra
  8093.                 argument for each of  these  character  control  strings.
  8094.                 This  error  occurs  when  there are more control strings
  8095.                 than extra arguments.
  8096.                 
  8097.             4220
  8098.                 Third Argument For '(g)sub' Function Must Be A  Variable.
  8099.                 The  optional  third  argument  of  the  'sub' and 'gsub'
  8100.                 functions must be a variable. The string  value  of  this
  8101.                 variable  is  replaced after string substitution has been
  8102.                 accomplished.
  8103.  
  8104.  
  8105.         QTAwk                       - 20-5 -                        QTAwk
  8106.  
  8107.  
  8108.  
  8109.  
  8110.  
  8111.  
  8112.         Section 20.0                                           Appendix V
  8113.  
  8114.  
  8115.             4230
  8116.                 Excessive Length Specified 'substr' Function.
  8117.                 The form of the 'substr'  function  is:  substr(s,p[,n]).
  8118.                 The  third  argument is optional, but if specified cannot
  8119.                 exceed 4096.
  8120.                 
  8121.             4240
  8122.                 Start Position Specified Too  Great,  'substr'  Function.
  8123.                 The  form  of  the 'substr' function is: substr(s,p[,n]).
  8124.                 The second argument cannot exceed 4096.
  8125.                 
  8126.             4250
  8127.                 Incorrect Time Format.
  8128.                 he form of the time function is: stime(fmt) here  fmt  is
  8129.                 converted to an integer and must be in the range:
  8130.                 
  8131.                 0 <= fmt <= 4
  8132.                 
  8133.             4260
  8134.                 Incorrect Date Format.
  8135.                 The form of the time function is: sdate(fmt) where fmt is
  8136.                 converted to an integer and must be in the range:
  8137.                 
  8138.                 0 <= fmt <= 16
  8139.                 
  8140.             4270
  8141.                 'rotate' Function Needs Array Member As Argument.
  8142.                 The argument for the 'rotate' function must be an  array.
  8143.                 If a variable is used, make sure that it is an array when
  8144.                 the function is called.
  8145.                 
  8146.             4280
  8147.                 Excessive Width Specified 'center' Function.
  8148.                 The second argument specifies the width of  the  line  in
  8149.                 which  to  center the string value of the first argument.
  8150.                 The width specified cannot exceed 4096.
  8151.                 
  8152.             4290
  8153.                 Excessive Copies Specified 'copies' Function.
  8154.                 The second argument of the  'copies'  function  specifies
  8155.                 the  number  of  copies  of the string value of the first
  8156.                 argument to return. The number of copies specified cannot
  8157.                 exceed 65,536. See error number 4300 below also.
  8158.                 
  8159.             4300
  8160.                 'copies' Function Return Exceeds Limits.
  8161.  
  8162.  
  8163.         QTAwk                       - 20-6 -                        QTAwk
  8164.  
  8165.  
  8166.  
  8167.  
  8168.  
  8169.  
  8170.         Section 20.0                                           Appendix V
  8171.  
  8172.  
  8173.                 The  'copies'  function  returns  the string value of the
  8174.                 first argument, copied the number of times  specified  by
  8175.                 the  second  argument.  The  total length of the returned
  8176.                 string:
  8177.                 
  8178.                 arg2 * length(arg1)
  8179.                 
  8180.                 cannot exceed 4096 characters.
  8181.                 
  8182.             4310
  8183.                 Excessive Characters Specified 'deletec' Function.
  8184.                 The 'deletec' function deletes the number  of  characters
  8185.                 specified  by the third argument starting at the position
  8186.                 specified by the second argument from the string value of
  8187.                 the first argument. The form of the function is:
  8188.                 
  8189.                 deletec(string,start,num)
  8190.                 
  8191.                 The  number  of  characters  specified  to delete, 'num',
  8192.                 cannot exceed 65,536. If 'num' is  zero  or  exceeds  the
  8193.                 number  of  characters  remaining  in the string from the
  8194.                 start position, then  the  remainder  of  the  string  is
  8195.                 deleted. See also error 4320 below.
  8196.                 
  8197.             4320
  8198.                 Excessive Characters Specified 'deletec' Function.
  8199.                 The  'deletec'  function deletes the number of characters
  8200.                 specified by the third argument starting at the  position
  8201.                 specified by the second argument from the string value of
  8202.                 the first argument. The form of the function is:
  8203.                 
  8204.                 deletec(string,start,num)
  8205.                 
  8206.                 The start is negative or greater than the length  of  the
  8207.                 string  value  of  the first argument, then no characters
  8208.                 are deleted.
  8209.                 
  8210.             4330
  8211.                 'deletec' Intermediate Result Exceeds Limits.
  8212.                 The 'deletec' function deletes the number  of  characters
  8213.                 specified  by the third argument starting at the position
  8214.                 specified by the second argument from the string value of
  8215.                 the first argument. The form of the function is:
  8216.                 
  8217.                 deletec(string,start,num)
  8218.                 
  8219.  
  8220.  
  8221.         QTAwk                       - 20-7 -                        QTAwk
  8222.  
  8223.  
  8224.  
  8225.  
  8226.  
  8227.  
  8228.         Section 20.0                                           Appendix V
  8229.  
  8230.  
  8231.                 If  the  length of the string value of the first argument
  8232.                 exceeds 4096 then this error is triggered.
  8233.                 
  8234.             4340
  8235.                 Start Position Specified Too  Great,  'insert'  Function.
  8236.                 The  'insert'  function  inserts  the string value of the
  8237.                 second argument  into  the  string  value  of  the  frist
  8238.                 argument, starting at the position specified by the third
  8239.                 argument. The form of the function is:
  8240.                 
  8241.                 insert(string1,string2,start)
  8242.                 
  8243.                 The  third  argument  cannot  exceed  65,536.  If   start
  8244.                 exceeds the length of the string value of 'string1', then
  8245.                 the string value of 'string2' is  concatenated  onto  the
  8246.                 string value of 'string1'
  8247.                 
  8248.             4350
  8249.                 'insert'  Function  Intermediate  Result  Exceeds Limits.
  8250.                 The 'insert' function inserts the  string  value  of  the
  8251.                 second  argument  into  the  string  value  of  the frist
  8252.                 argument, starting at the position specified by the third
  8253.                 argument. The form of the function is:
  8254.                 
  8255.                 insert(string1,string2,start)
  8256.                 
  8257.                 The  length of the string value value of 'string1' cannot
  8258.                 exceed 4096 in length. The  result  of  insert  'string2'
  8259.                 into  'string1' cannot exceed 4096 also. See error number
  8260.                 4360 below.
  8261.                 
  8262.             4360
  8263.                 'insert' Function Return Exceeds Limits.
  8264.                 The 'insert' function inserts the  string  value  of  the
  8265.                 second  argument  into  the  string  value  of  the frist
  8266.                 argument, starting at the position specified by the third
  8267.                 argument. The form of the function is:
  8268.                 
  8269.                 insert(string1,string2,start)
  8270.                 
  8271.                 The  length of the string value value of 'string1' cannot
  8272.                 exceed 4096 in length. The  result  of  insert  'string2'
  8273.                 into  'string1' cannot exceed 4096 also. See error number
  8274.                 4350 above.
  8275.                 
  8276.             4370
  8277.  
  8278.  
  8279.         QTAwk                       - 20-8 -                        QTAwk
  8280.  
  8281.  
  8282.  
  8283.  
  8284.  
  8285.  
  8286.         Section 20.0                                           Appendix V
  8287.  
  8288.  
  8289.                 Start Position Specified Too Great,  'overlay'  Function.
  8290.                 The  'overlay'  function overlays the string value of the
  8291.                 second argument  into  the  string  value  of  the  frist
  8292.                 argument, starting at the position specified by the third
  8293.                 argument. The form of the function is:
  8294.                 
  8295.                 overlay(string1,string2,start)
  8296.                 
  8297.                 The  third  argument  cannot  exceed  65,536.  If   start
  8298.                 exceeds the length of the string value of 'string1', then
  8299.                 blanks are appended to 'string1' to create  a  string  of
  8300.                 length 'start'. The second string is then concatenated to
  8301.                 this string. See also error numbers 4380, 4390, and  4400
  8302.                 below.
  8303.                 
  8304.             4380
  8305.                 'overlay' Function Result Exceeds Limits.
  8306.                 The  'overlay'  function overlays the string value of the
  8307.                 second argument  into  the  string  value  of  the  frist
  8308.                 argument, starting at the position specified by the third
  8309.                 argument. The form of the function is:
  8310.                 
  8311.                 overlay(string1,string2,start)
  8312.                 
  8313.                 The third argument cannot exceed 4096. If  start  exceeds
  8314.                 the  length of the string value of 'string1', then blanks
  8315.                 are appended to 'string1' to create a  string  of  length
  8316.                 'start'.  The  second string is then concatenated to this
  8317.                 string. See also error number 4370  above  and  4390  and
  8318.                 4400 below.
  8319.                 
  8320.             4390
  8321.                 'overlay'  Function  Intermediate  Result Exceeds Limits.
  8322.                 The 'overlay' function overlays the string value  of  the
  8323.                 second  argument  into  the  string  value  of  the frist
  8324.                 argument, starting at the position specified by the third
  8325.                 argument. The form of the function is:
  8326.                 
  8327.                 overlay(string1,string2,start)
  8328.                 
  8329.                 The  length  of  the  string  value  of  'string1' cannot
  8330.                 exceed 4096 characters. See also error  number  4370  and
  8331.                 4380 above and 4400 below.
  8332.                 
  8333.             4400
  8334.                 'overlay' Function Result Exceeds Limits.
  8335.  
  8336.  
  8337.         QTAwk                       - 20-9 -                        QTAwk
  8338.  
  8339.  
  8340.  
  8341.  
  8342.  
  8343.  
  8344.         Section 20.0                                           Appendix V
  8345.  
  8346.  
  8347.                 The  'overlay'  function overlays the string value of the
  8348.                 second argument  into  the  string  value  of  the  frist
  8349.                 argument, starting at the position specified by the third
  8350.                 argument. The form of the function is:
  8351.                 
  8352.                 overlay(string1,string2,start)
  8353.                 
  8354.                 The length  of  the  resultant  string  after  overlaying
  8355.                 'string2'  onto  'string1'  cannot  exceed 4096. See also
  8356.                 error numbers 4370, 4380, and 4390 above.
  8357.                 
  8358.             4410
  8359.                 'remove' Function  Intermediate  Result  Exceeds  Limits.
  8360.                 The 'remove' function removes all characters specified by
  8361.                 the second argument from the string value  of  the  first
  8362.                 argument. The form of the function is:
  8363.                 
  8364.                 remove(string,char)
  8365.                 
  8366.                 The  length  of 'string' before any character are removed
  8367.                 cannot exceed 4096.
  8368.                 
  8369.             4420
  8370.                 Excessive Width Specified 'justify' Function.
  8371.                 The 'justify' function forms a string from  the  elements
  8372.                 of  the array specified by the first argument. The string
  8373.                 will have a length specified by the integer value of  the
  8374.                 third  arugument  and  will  be formed from the number of
  8375.                 array elements specified  by  the  second  argument.  Any
  8376.                 padding  characters  necessary between array elements can
  8377.                 be specified by the optional fourth argument. The form of
  8378.                 the function is:
  8379.                 
  8380.                 justify(array_var,count,width [,pad_char] );
  8381.                 
  8382.                 The  width specified cannot exceed 65,536. See also error
  8383.                 number 4430 below.
  8384.                 
  8385.             4430
  8386.                 Excessive Number Of Array  Elements  Specified  'justify'
  8387.                 Function.
  8388.                 The  'justify'  function forms a string from the elements
  8389.                 of the array specified by the first argument. The  string
  8390.                 will  have a length specified by the integer value of the
  8391.                 third arugument and will be formed  from  the  number  of
  8392.                 array  elements  specified  by  the  second argument. Any
  8393.  
  8394.  
  8395.         QTAwk                       - 20-10 -                       QTAwk
  8396.  
  8397.  
  8398.  
  8399.  
  8400.  
  8401.  
  8402.         Section 20.0                                           Appendix V
  8403.  
  8404.  
  8405.                 padding characters necessary between array  elements  can
  8406.                 be specified by the optional fourth argument. The form of
  8407.                 the function is:
  8408.                 
  8409.                 justify(array_var,count,width [,pad_char] );
  8410.                 
  8411.                 The count of array elements to use cannot exceed  65,536.
  8412.                 See also error number 4420 above.
  8413.                 
  8414.             4440
  8415.                 Bad Function Call - Internal Error.
  8416.                 An  internal  error  has  occured  in  calling a built-in
  8417.                 function.  Please   contact   the   QTAwk   author   with
  8418.                 information on the circumstances of this error.
  8419.                 
  8420.             4450
  8421.                 Missing ')' for Function Call.
  8422.                 A  user-defined function has been called with an argument
  8423.                 list and  no  right  parenthesis,  ')',  terminating  the
  8424.                 argument list.
  8425.                 
  8426.             4460
  8427.                 More  Arguments  For  Function  Than  Defined.  Function:
  8428.                 {User_Function_Name}.
  8429.                 More argument are passed to  the  user  defined  function
  8430.                 named  in  the  error  message  than were defined for the
  8431.                 function. Check the user function name or the  definition
  8432.                 of the function for necessary extra arguments.
  8433.                 
  8434.             4470
  8435.                 Less  Arguments For User Function Than Defined. Function:
  8436.                 '{User_Function_Name}'.
  8437.                 Less arguments are passed to the  user  defined  function
  8438.                 named  in  the  error  message  than were defined for the
  8439.                 function. This error message is  generated  ONLY  if  the
  8440.                 built-in  variable '_arg_chk' has a TRUE value. Variables
  8441.                 local to a user-defined function should be  defined  with
  8442.                 the 'local' keyword.
  8443.                 
  8444.             4480
  8445.                 Constant Passed For Function Array Parameter.
  8446.                 A  parameter  to a user defined function used as an array
  8447.                 within the function cannot be passed  a  constant  value.
  8448.                 Only  a variable can be passed for this parameter. If the
  8449.                 statement where the variable is indexed as  an  array  is
  8450.                 executed,  the variable will be an array upon return from
  8451.  
  8452.  
  8453.         QTAwk                       - 20-11 -                       QTAwk
  8454.  
  8455.  
  8456.  
  8457.  
  8458.  
  8459.  
  8460.         Section 20.0                                           Appendix V
  8461.  
  8462.  
  8463.                 the function.
  8464.                 
  8465.             4490
  8466.                 Internal Error - Misalignment Of Local List ( ).
  8467.                 This is an internal QTAwk error. It should ideally  never
  8468.                 happen.  If  this  error  message  is  generated,  please
  8469.                 contact  the  QTAwk  author  with  information   on   the
  8470.                 circumstances.
  8471.                 
  8472.             4500
  8473.                 Cannot Assign Array To Array Element.
  8474.                 Arrays  can  be  assigned to variables, however, it is an
  8475.                 error it attempt to assign an array to a  single  element
  8476.                 of another array.
  8477.                 
  8478.             4510
  8479.                 Array Cannot Operate on Scalar.
  8480.                 A  scalar may operate on an array, but the reverse is not
  8481.                 true.
  8482.                 
  8483.             4520
  8484.                 Assignment Operator needs a Variable on left.
  8485.                 The   assignment   operator,   '=',   or   any   of   the
  8486.                 operator/assignment  operators,  'op=', only operate on a
  8487.                 variable to the left of the operator.
  8488.                 
  8489.             4530
  8490.                 Stack Underflow
  8491.                 Internal stack error. Please  contact  the  QTAwk  author
  8492.                 with  information  on  the  circumstances  of  this error
  8493.                 message.
  8494.             
  8495.         5.  Interpretation Errors
  8496.             5000
  8497.                 Expecting Filename After 'f' Option.
  8498.                 QTAwk utility files are specified  on  the  command  line
  8499.                 with   the  'f'  option.  The  filename  of  the  utility
  8500.                 immediately follows the 'f' flag.  A  blank  between  the
  8501.                 flag  and  the  filename  is  optional.  This  message is
  8502.                 generated when no arguments follow the 'f' flag.
  8503.                 
  8504.             5010
  8505.                 Unable To Compile Regular Expression
  8506.                 The input record field separator may be specified on  the
  8507.                 command line with the 'F' option. If the string specified
  8508.                 for FS is longer  than  a  single  character,  a  regular
  8509.  
  8510.  
  8511.         QTAwk                       - 20-12 -                       QTAwk
  8512.  
  8513.  
  8514.  
  8515.  
  8516.  
  8517.  
  8518.         Section 20.0                                           Appendix V
  8519.  
  8520.  
  8521.                 expression  is  assumed.  This error message is generated
  8522.                 when QTAwk is unable to convert the string into a regular
  8523.                 expression internal form for whatever reason.
  8524.                 
  8525.             5020
  8526.                 '-F' command line option specified more than once.
  8527.                 The  command line 'F' option to specifiy the input record
  8528.                 field separator, FS, may be specified only once.
  8529.                 
  8530.             5030
  8531.                 Internal Error #3.
  8532.                 Internal error. Please  contact  the  QTAwk  author  with
  8533.                 information  on  the circumstances of this error message.
  8534.                 
  8535.             5040
  8536.                 Internal Error #2.
  8537.                 Internal error. Please  contact  the  QTAwk  author  with
  8538.                 information  on  the circumstances of this error message.
  8539.                 
  8540.             5050
  8541.                 BEGIN/END/NOMATCH/INITIAL/FINAL Patterns or User Function
  8542.                 Require An Action.
  8543.                 The pre-defined patterns:
  8544.                 
  8545.                 BEGIN
  8546.                 INITIAL
  8547.                 NOMATCH
  8548.                 FINAL
  8549.                 END
  8550.                 
  8551.                 must   have  actions  associated  with  them.  The  brace
  8552.                 opening the action must  be  on  the  same  line  as  the
  8553.                 pre-defined pattern.
  8554.                 
  8555.             5060
  8556.                 Exceeded Internal Stack Size on Scan.
  8557.                 The  internal stack for containing parsed tokens has been
  8558.                 exceeded. Attempt to simplify the  utility  in  the  area
  8559.                 where this error occurred.
  8560.                 
  8561.             5070
  8562.                 Underflow Internal Stack on Scan.
  8563.                 This  is  an  internal error. If this error occurs please
  8564.                 contact  the  QTAwk  author  with  information   on   the
  8565.                 circumstances of this error message.
  8566.                 
  8567.  
  8568.  
  8569.         QTAwk                       - 20-13 -                       QTAwk
  8570.  
  8571.  
  8572.  
  8573.  
  8574.  
  8575.  
  8576.         Section 20.0                                           Appendix V
  8577.  
  8578.  
  8579.             5080
  8580.                 Missing ')' For Function Call.
  8581.                 A  used defined function argument list must be terminated
  8582.                 with a right parenthesis, ')'. A symbol  has  been  found
  8583.                 which  cannot  be  part of the argument list and is not a
  8584.                 right parenthesis.
  8585.                 
  8586.             5090
  8587.                 Function Call Without Parenthisized Argument List.
  8588.                 A  user  defined  function  definition  must  include  an
  8589.                 argument  list.  The  argument  list  may be empty, e.g.,
  8590.                 "()", if there are no formal arguments.
  8591.                 
  8592.             5100
  8593.                 'fprint' Function Takes A minimum Of 1 Argument.
  8594.                 The 'fprint' built-in function must  have  at  least  the
  8595.                 name name of the output file specified.
  8596.                 
  8597.             5110
  8598.                 printf  and  'sprintf'  Functions  Take  A  Minimum  Of 1
  8599.                 Argument.
  8600.                 These functions  must  have  at  least  a  format  string
  8601.                 defined.
  8602.                 
  8603.             5120
  8604.                 'fprintf'  Function  Needs  A  Minimum  of Two Arguments.
  8605.                 This function needs an output  file  name  and  a  format
  8606.                 string.
  8607.                 
  8608.             5130
  8609.                 Second  Argument  Of  'fgetline'  Has  To  Be A Variable.
  8610.                 If  two  arguments  are  specified  for  the   'fgetline'
  8611.                 built-in function, the second must be a variable.
  8612.                 
  8613.             5140
  8614.                 Argument Of 'getline' Has To Be A Variable.
  8615.                 If  an  argument for the 'getline' function is specified,
  8616.                 it must be a variable.
  8617.                 
  8618.             5150
  8619.                 split Function Needs Variable Name  As  Second  Argument.
  8620.                 The  second second argument for the 'split' function must
  8621.                 be a variable. The peices into which the  first  argument
  8622.                 is  split  will  be  returned  as  array  elements of the
  8623.                 variable specified.
  8624.                 
  8625.  
  8626.  
  8627.         QTAwk                       - 20-14 -                       QTAwk
  8628.  
  8629.  
  8630.  
  8631.  
  8632.  
  8633.  
  8634.         Section 20.0                                           Appendix V
  8635.  
  8636.  
  8637.             5160
  8638.                 'rotate' Function Needs Variable As Argument.
  8639.                 The argument of the 'rotate' function has to be an  array
  8640.                 variable.
  8641.                 
  8642.             5170
  8643.                 'justify'  Function  Needs  Variable  As  First Argument.
  8644.                 The format of the 'justify' built-in function is:
  8645.                 
  8646.                 justify(a,n,w)
  8647.                 
  8648.                  or
  8649.                 
  8650.                 justify(a,n,w,c)
  8651.                 
  8652.                 The first argument, 'a', must be an array  variable.  The
  8653.                 first  n elements of the array are concatenated to form a
  8654.                 string 'w' characters long. a single  space  is  used  to
  8655.                 separate the concatenated elements. If the optional third
  8656.                 argument is specified, it is  converted  to  a  character
  8657.                 value and used to separate the elements.
  8658.                 
  8659.             5180
  8660.                 '[pu]_sym'  Function  Needs  Variable As Second Argument.
  8661.                 The second argument must be variable whose value  can  be
  8662.                 changed  to  equal  the string value of the name variable
  8663.                 specified.
  8664.                 
  8665.             5190
  8666.                 Bad Function Call
  8667.                 Internal QTAwk error. Please  contact  the  QTAwk  author
  8668.                 with  information  on  the  circumstances  of this error.
  8669.                 
  8670.             5200
  8671.                 Improper Number Of Arguments, {Funcation_Name}  Function.
  8672.                 The  built-in  function specified has been called with an
  8673.                 improper number of arguments for the function. Check  the
  8674.                 user manual for the correct use of the intended function.
  8675.                 
  8676.             5210
  8677.                 Need Variable On Left Side Of Assignment.
  8678.                 In an assignment statement of the form:
  8679.                 
  8680.                 variable = expression;
  8681.                 
  8682.                 a variable must be specified on  the  left  side  of  the
  8683.  
  8684.  
  8685.         QTAwk                       - 20-15 -                       QTAwk
  8686.  
  8687.  
  8688.  
  8689.  
  8690.  
  8691.  
  8692.         Section 20.0                                           Appendix V
  8693.  
  8694.  
  8695.                 assignment   operator   to   receive  the  value  of  the
  8696.                 expression on the right side of the operator.
  8697.                 
  8698.             5220
  8699.                 Conditional Expression Error - Missing ':'
  8700.                 The form of the conditional expression is :
  8701.                 
  8702.                 test_expression ? expression_1 : expression_2;
  8703.                 
  8704.                 test_expression is  evaluated,  if  the  result  is  TRUE
  8705.                 (non-zero  numeric  or  non-null string), expression_1 is
  8706.                 evaluated  and  the  value  becomes  the  value  of   the
  8707.                 conditional  expression.  If the value of test_expression
  8708.                 is FALSE (zero numeric or null string),  expression_2  is
  8709.                 evaluated   and  the  value  becomes  the  value  of  the
  8710.                 conditional expression.
  8711.                 
  8712.             5230
  8713.                 'in' Operator Needs Array As Right Operand
  8714.                 The form of the 'in' operator is:
  8715.                 
  8716.                 expression in array_var
  8717.                 
  8718.                 The operand to the right of 'in', array_var here, has  to
  8719.                 be  a variable. If the variable is not an array, then the
  8720.                 value of the expression is FALSE.
  8721.                 
  8722.             5240
  8723.                 Missing ')' in Expression Grouping.
  8724.                 An  expression   has   been   scanned   with   unbalanced
  8725.                 parenthesis.   Check  for  a  missing  terminating  right
  8726.                 parenthesis.
  8727.                 
  8728.             5250
  8729.                 Pre-Increment/Decrement Operators Need Variable.
  8730.                 The increment and decrement  operators,  '++'  and  '--',
  8731.                 only  operate on variables. An instance has been found in
  8732.                 which the operator has been used as a pre-fix operator on
  8733.                 something  other than a variable. Check that grouping has
  8734.                 not changed a post-fix operator into a pre-fix  operator.
  8735.                 
  8736.             5260
  8737.                 Undefined Symbol.
  8738.                 A  symbol  has  been found which matches no defined QTAwk
  8739.                 syntax. This usually, but not  always,  occurs  when  the
  8740.                 terminating   semi-colon,   ';',  has  been  left  off  a
  8741.  
  8742.  
  8743.         QTAwk                       - 20-16 -                       QTAwk
  8744.  
  8745.  
  8746.  
  8747.  
  8748.  
  8749.  
  8750.         Section 20.0                                           Appendix V
  8751.  
  8752.  
  8753.                 statement.
  8754.                 
  8755.             5270
  8756.                 Need Variable for Array Reference
  8757.                 A  left  bracket  for  indexing   an   array   has   been
  8758.                 encountered.  However,  the  preceeding  symbol was not a
  8759.                 variable. Only  variables  may  be  arrays  and  indexed.
  8760.                 
  8761.             5280
  8762.                 Missing Index For Array
  8763.                 A   left   bracket   for   indexing  an  array  has  been
  8764.                 encountered. However, the index  expression  is  missing:
  8765.                 var[] a null index is not allowed in QTAwk.
  8766.                 
  8767.             5290
  8768.                 Missing ']' Terminating array index.
  8769.                 A  left  bracket  and an index expression for indexing an
  8770.                 array have been encountered. However, the  right  bracket
  8771.                 terminating  the  index  expression  was  not recognized.
  8772.                 Check that the array index follows the form:
  8773.                 
  8774.                 var[index_expression]
  8775.                 
  8776.             5300
  8777.                 Post-Increment/Decrement Operators Need Variable.
  8778.                 The increment and decrement  operators,  '++'  and  '--',
  8779.                 only  operate on variables. An instance has been found in
  8780.                 which the operator has been used as a  post-fix  operator
  8781.                 on  something  other than a variable. Check that grouping
  8782.                 has not  changed  a  pre-fix  operator  into  a  post-fix
  8783.                 operator.
  8784.                 
  8785.             5310
  8786.                 'if' Keyword - No Expression To Test.
  8787.                 The proper syntax for the 'if' statement is:
  8788.                 
  8789.                 if ( conditional_expression ) statement
  8790.                 
  8791.                 The  left  parenthesis,  '(',  starting  the  conditional
  8792.                 expression was not  found  following  the  'if'  keyword.
  8793.                 Check that the syntax conforms to the form above.
  8794.                 
  8795.             5320
  8796.                 'if'  Keyword  -  No  Terminating ')' On Test Expression.
  8797.                 The proper syntax for the 'if' statement is:
  8798.                 
  8799.  
  8800.  
  8801.         QTAwk                       - 20-17 -                       QTAwk
  8802.  
  8803.  
  8804.  
  8805.  
  8806.  
  8807.  
  8808.         Section 20.0                                           Appendix V
  8809.  
  8810.  
  8811.                 if ( conditional_expression ) statement
  8812.                 
  8813.                 The right parenthesis, ')', terminating  the  conditional
  8814.                 expression  was  not  found.  Check  that  the  syntax to
  8815.                 conforms the form above.
  8816.                 
  8817.             5330
  8818.                 'while' Keyword - No Terminating ')' On Test  Expression.
  8819.                 The proper syntax for the 'while' statement is:
  8820.                 
  8821.                 while ( conditional_expression ) statement
  8822.                 
  8823.                 The  right  parenthesis, ')', terminating the conditional
  8824.                 expression was  not  found.  Check  that  the  syntax  to
  8825.                 conforms the form above.
  8826.                 
  8827.             5340
  8828.                 Missing 'while' Part Of 'do'.
  8829.                 The proper syntax for the 'do' statement is:
  8830.                 
  8831.                 do statement while ( conditional_expression );
  8832.                 
  8833.                 The   'while'   keyword   was  not  found  following  the
  8834.                 statement portion. Check that a possible left brace, '{',
  8835.                 starting  a  compound  statement may have been deleted or
  8836.                 for the possible misuse  of  a  keyword  as  a  variable.
  8837.                 
  8838.             5350
  8839.                 Missing '(' On 'while' Part Of 'do'.
  8840.                 The proper syntax for the 'do' statement is:
  8841.                 
  8842.                 do statement while ( conditional_expression );
  8843.                 
  8844.                 The  left  parenthesis,  '(',  starting  the  conditional
  8845.                 expression was not found following the  'while'  keyword.
  8846.                 Check that the syntax conforms to the form above.
  8847.                 
  8848.             5360
  8849.                 Missing ')' On 'while' Part Of 'do'.
  8850.                 The proper syntax for the 'do' statement is:
  8851.                 
  8852.                 do statement while ( conditional_expression );
  8853.                 
  8854.                 The  right  parenthesis, ')', terminating the conditional
  8855.                 expression was  not  found.  Check  that  the  syntax  to
  8856.                 conforms the form above.
  8857.  
  8858.  
  8859.         QTAwk                       - 20-18 -                       QTAwk
  8860.  
  8861.  
  8862.  
  8863.  
  8864.  
  8865.  
  8866.         Section 20.0                                           Appendix V
  8867.  
  8868.  
  8869.             5370
  8870.                 Missing ';' Terminating 'do - while'.
  8871.                 The proper syntax for the 'do' statement is:
  8872.                 
  8873.                 do statement while ( conditional_expression );
  8874.                 
  8875.                 Note   the  semicolon  following  the  right  parenthesis
  8876.                 terminating the conditional expression. The semicolon  is
  8877.                 necessary here.
  8878.                 
  8879.             5380
  8880.                 Missing Opening Parenthesis On 'for'.
  8881.                 The proper syntax for the 'for' statement is:
  8882.                 
  8883.                 for   (   intial_expression  ;  conditional_expression  ;
  8884.                 loop_expression )
  8885.                 statement
  8886.                 
  8887.                 or
  8888.                 
  8889.                 for ( variable_name in array_name ) statement
  8890.                 
  8891.                 The left parenthesis, '(', was not  found  following  the
  8892.                 'for' keyword. Check that the syntax conforms to the form
  8893.                 above.
  8894.                 
  8895.                  ;li. 5390
  8896.             5400
  8897.             5420
  8898.                 Improper Syntax - 'for' Conditional.
  8899.                 The proper syntax for the 'for' statement is:
  8900.                 
  8901.                 for  (  intial_expression  ;   conditional_expression   ;
  8902.                 loop_expression )
  8903.                 statement
  8904.                 
  8905.                 One  of  the  semicolons separating the three expressions
  8906.                 or the terminating right parenthesis was not found. Check
  8907.                 that the syntax follows the form above
  8908.                 
  8909.             5410
  8910.                 'in'  Operator  Needs  Variable  As Left Operand in 'for'
  8911.                 Expression.
  8912.                 The proper syntax for the 'for' statement is:
  8913.                 
  8914.                 for ( variable_name in array_name ) statement
  8915.  
  8916.  
  8917.         QTAwk                       - 20-19 -                       QTAwk
  8918.  
  8919.  
  8920.  
  8921.  
  8922.  
  8923.  
  8924.         Section 20.0                                           Appendix V
  8925.  
  8926.  
  8927.                 the symbol following the left parenthesis and  preceeding
  8928.                 the 'in' keyword must be a valid variable name.
  8929.                 
  8930.             5430
  8931.                 break/continue Keyword Outside Of Loop.
  8932.                 Either  of  these  keywords  must  be  used  inside  of a
  8933.                 'while', 'for' or 'do' loop.  In  addition,  the  'break'
  8934.                 statement may be used inside a 'switch-case' construct to
  8935.                 terminate execution flow. One of the  keywords  has  been
  8936.                 found outside of such a construct. Check for an imbalance
  8937.                 of braces, '{}', enclosing compund statements.
  8938.                 
  8939.             5440
  8940.                 'return' Statement Outside Of User Function.
  8941.                 The 'return' statement may  only  be  used  inside  of  a
  8942.                 user-defined  function  to  terminate  execution  of  the
  8943.                 function and cause execution to return to the place where
  8944.                 the   function  was  called.  The  'return'  keyword  was
  8945.                 encountered outside of the definition of such a function.
  8946.                 Check  for  the  use  of the keyword as a variable or for
  8947.                 unbalanced braces, '{}', enclosing the statements of  the
  8948.                 function.
  8949.                 
  8950.             5450
  8951.                 Exceeded  Limits  on Number of Local Variable Definitions
  8952.                 (1).
  8953.                 QTAwk places a limit of 256 local  variables  within  any
  8954.                 compound  statement.  An  attempt has been made to define
  8955.                 more local variables than this limit allows.
  8956.                 
  8957.             5460
  8958.                 No Variables Defined With 'local' Keyword.
  8959.                 The form of local variable definition  with  the  'local'
  8960.                 keyword follows the form:
  8961.                 
  8962.                 local var1, var2 = optional_expression;
  8963.                 
  8964.                 The  'local' keyword was encountered followed immediately
  8965.                 by a semicolon. Check that the syntax follows  the  above
  8966.                 form.
  8967.                 
  8968.             5470
  8969.                 'switch'  Keyword  -  No  Terminating  ')' On Expression.
  8970.                 The form of the 'switch' construct is:
  8971.                 
  8972.                 switch ( switch_expression ) statement
  8973.  
  8974.  
  8975.         QTAwk                       - 20-20 -                       QTAwk
  8976.  
  8977.  
  8978.  
  8979.  
  8980.  
  8981.  
  8982.         Section 20.0                                           Appendix V
  8983.  
  8984.  
  8985.                 The   right    parenthesis,    ')',    terminating    the
  8986.                 switch_expression was not found.
  8987.                 
  8988.             5480
  8989.                 'case/default Statement Without Switch Statement.
  8990.                 The  'case' keyword is used within the 'switch' statement
  8991.                 to specify case expressions  to  which  execution  should
  8992.                 transfer  after  matching the switch expression. A 'case'
  8993.                 keyword was found  outside  of  the  'switch'  statement.
  8994.                 Check  for  the  use  of the keyword as a variable or for
  8995.                 unbalanced   braces   enclosing   a   compound   'switch'
  8996.                 statement.
  8997.                 
  8998.             5490
  8999.                 Multiple 'default' Statements in 'switch'.
  9000.                 The 'default' keyword is used within a 'switch' statement
  9001.                 to specify a transfer point at execution  should  proceed
  9002.                 when   the   switch_expression   fails   to   match   any
  9003.                 case_expression. Only one  'default'  transfer  point  is
  9004.                 allowed   per  'switch'  statement.  Check  for  possible
  9005.                 unbalanced braces, '{}', enclosing a  compound  statement
  9006.                 in previous 'case' statements.
  9007.                 
  9008.             5500
  9009.                 Missing ':' Following Expression On Case Label.
  9010.                 The form of the 'case' statement is:
  9011.                 
  9012.                 case case_expression:
  9013.                 
  9014.                 A  colon,  ':', must terminate the case expression. QTAwk
  9015.                 did not find the terminating colon.
  9016.                 
  9017.             5510
  9018.                 Need Variable For 'delete' Reference
  9019.                 The form of the 'delete' statement is:
  9020.                 
  9021.                 delete variable_name;
  9022.                 
  9023.                 or
  9024.                 
  9025.                 delete (variable_name);
  9026.                 
  9027.                 or
  9028.                 
  9029.                 delete variable_name[index];
  9030.                 
  9031.  
  9032.  
  9033.         QTAwk                       - 20-21 -                       QTAwk
  9034.  
  9035.  
  9036.  
  9037.  
  9038.  
  9039.  
  9040.         Section 20.0                                           Appendix V
  9041.  
  9042.  
  9043.                 or
  9044.                 
  9045.                 delete (variable_name[index]);
  9046.                 
  9047.                 where variable  must  be  a  global  or  local  variable.
  9048.                 
  9049.             5520
  9050.                 'deletea' Statement Variable Cannot Be Indexed.
  9051.                 The form of the 'deletea' statement is:
  9052.                 
  9053.                 deletea variable_name;
  9054.                 
  9055.                 or
  9056.                 
  9057.                 deletea (variable_name);
  9058.                 
  9059.                 where  variable  must  be  a global or local variable and
  9060.                 cannot be indexed.
  9061.                 
  9062.             5530
  9063.                 Need Variable For 'deletea' Reference
  9064.                 The form of the 'deletea' statement is:
  9065.                 
  9066.                 deletea variable_name;
  9067.                 
  9068.                 or
  9069.                 
  9070.                 deletea (variable_name);
  9071.                 
  9072.                 where variable  must  be  a  global  or  local  variable.
  9073.                 
  9074.             5540
  9075.                 No ';' Terminating Statement.
  9076.                 All  statements  in  QTAwk are terminated by a semicolon.
  9077.                 The terminating semicolon was not found by QTAwk.
  9078.                 
  9079.             5550
  9080.                 Internal Compilation Error - Action Strings.
  9081.                 This is an QTAwk internal error that should never happen.
  9082.                 If  this error message in encountered, please contact the
  9083.                 QTAwk author with information  on  the  circumstances  of
  9084.                 this error.
  9085.                 
  9086.             5560
  9087.                 Error On Single Line Action. No Termination.
  9088.                 In  parsing/compiling  an action entered from the command
  9089.  
  9090.  
  9091.         QTAwk                       - 20-22 -                       QTAwk
  9092.  
  9093.  
  9094.  
  9095.  
  9096.  
  9097.  
  9098.         Section 20.0                                           Appendix V
  9099.  
  9100.  
  9101.                 line or by executing the 'execute' built-in function, the
  9102.                 end  of  the line was reached without reaching the end of
  9103.                 the action expression(s). Typically caused by  a  missing
  9104.                 right  bracket,  '}'  (or unbalanced brackets - more left
  9105.                 brackets than right brackets).
  9106.                 
  9107.             5570
  9108.                 Too Many User Functions Defined.
  9109.                 QTAwk  currently  has  a  limit  of  256   user   defined
  9110.                 functions.  The currently utility has attempted to define
  9111.                 more than that limit. Please  contact  the  QTAwk  author
  9112.                 with  information  on  the  circumstances  of  this error
  9113.                 message.
  9114.                 
  9115.             5580
  9116.                 Exceeded Limits on Number of Local  Variable  Definitions
  9117.                 (2).
  9118.                 QTAwk  currently  has  a  limit  of 256 'local' variables
  9119.                 defined  within  any  single  compound   statement.   The
  9120.                 currently  utility has attempted to define more than that
  9121.                 limit. Please contact the QTAwk author  with  information
  9122.                 on the circumstances of this error message.
  9123.                 
  9124.             5590
  9125.                 Expecting  Function  Name To Follow 'function' Keyword In
  9126.                 Pattern.
  9127.                 The 'function' keyword has been encountered in a  pattern
  9128.                 without  a  function  name  immediately  following.  This
  9129.                 syntax error may be corrected by  inserting  the  missing
  9130.                 name  or  by  removing  the  function  keyword  from  the
  9131.                 pattern.
  9132.                 
  9133.             5600
  9134.                 Multi-Defined Function Name.
  9135.                 The name supplied for a user defined  function  has  been
  9136.                 used  previously.  The current usage attempts to redefine
  9137.                 the name. Change either the first use of the name or  the
  9138.                 present.
  9139.                 
  9140.             5610
  9141.                 Unexpected  Symbol  -  Function Argument List Definition.
  9142.                 A user defined function  has  been  encoutered  with  the
  9143.                 accompanying list defining the passed argument names. The
  9144.                 form of the list is a variable  name  followed  by  1)  a
  9145.                 comma and more names, 2) an ellipses, '...' followed by a
  9146.                 right parenthesis, or 3) a right parenthesis  ending  the
  9147.  
  9148.  
  9149.         QTAwk                       - 20-23 -                       QTAwk
  9150.  
  9151.  
  9152.  
  9153.  
  9154.  
  9155.  
  9156.         Section 20.0                                           Appendix V
  9157.  
  9158.  
  9159.                 list.  A  symbol  other than a comma or right parenthesis
  9160.                 has been found following a variable name.
  9161.                 
  9162.             5620
  9163.                 Expecting  ')'  To  Terminate  Function  Parameter  List.
  9164.                 A  user  defined  function  has  been encoutered with the
  9165.                 accompanying list defining the passed argument names. The
  9166.                 form  of  the  list  is  a variable name followed by 1) a
  9167.                 comma and more names, 2) an ellipses, '...' followed by a
  9168.                 right  parenthesis,  or 3) a right parenthesis ending the
  9169.                 list. A symbol  has  been  found  other  than  the  right
  9170.                 parenthesis following the ellipses.
  9171.                 
  9172.             5630
  9173.                 Unexpected  Symbol  -  Function Argument List Definition.
  9174.                 A user defined function  has  been  encoutered  with  the
  9175.                 accompanying list defining the passed argument names. The
  9176.                 form of the list is a variable  name  followed  by  1)  a
  9177.                 comma and more names, 2) an ellipses, '...' followed by a
  9178.                 right parenthesis, or 3) a right parenthesis  ending  the
  9179.                 list.  A  symbol  other than a comma or right parenthesis
  9180.                 has been found following a variable name.
  9181.                 
  9182.             5640
  9183.                 Expecting  Parenthesized  Argument  Definition  List  For
  9184.                 Function.
  9185.                 A  user defined function has the following form: function
  9186.                 function_name ( argument_list ) The left  parenthesis  of
  9187.                 the argument list was not found.
  9188.                 
  9189.             5650
  9190.                 Improper Syntax - Improper Ending For Pattern
  9191.                 A  pattern  expression  must be ended by: 1) a comma (the
  9192.                 first expression in a range expression only), 2) the left
  9193.                 brace,   '{',  starting  the  associated  action,  3)  an
  9194.                 End-of-File, or 4) new line. a symbol  other  than  above
  9195.                 has been encountered.
  9196.                 
  9197.             5660
  9198.                 GROUP Pattern Only Accepts a Regular Expression, a String
  9199.                 or a Variable.
  9200.                 The GROUP pattern keyword  may  only  be  followed  by  a
  9201.                 regular  expression  constant,  a  string  constant  or a
  9202.                 variable. A symbol other than one of these three has been
  9203.                 encountered.
  9204.                 
  9205.  
  9206.  
  9207.         QTAwk                       - 20-24 -                       QTAwk
  9208.  
  9209.  
  9210.  
  9211.  
  9212.  
  9213.  
  9214.         Section 20.0                                           Appendix V
  9215.  
  9216.  
  9217.             5670
  9218.                 Internal Parse Error: 1001.
  9219.                 Internal  parser  error.  Please contact the QTAwk author
  9220.                 with information  on  the  circumstances  of  this  error
  9221.                 message.
  9222.                 
  9223.             5680
  9224.                 Local Variable With Reserved Name.
  9225.                 An  attempt  has been made to defione a local variable in
  9226.                 either a user defined function argument list or with  the
  9227.                 'local'  keyword,  with  a name equal to a reserved word.
  9228.                 
  9229.             5690
  9230.                 Improper Use of Keyword.
  9231.                 A pattern keyword  has  been  encountered  in  an  action
  9232.                 statement.
  9233.                 
  9234.             5700
  9235.                 User  Function  Variable Argument Keyword Outside Of User
  9236.                 Function.
  9237.                 The two predefined local variables: vargc and  vargv  can
  9238.                 only  be  used  within  user defined functions which have
  9239.                 been defined with a variable length argument  list  using
  9240.                 the  ellipsis,  '...'.  One  of  these variables has been
  9241.                 encountered outside of a user defined function.
  9242.                 
  9243.             5710
  9244.                 Variable  Argument  Keyword  In  User  Function   Defined
  9245.                 Without Variable Number Of Arguments.
  9246.                 The  two  predefined local variables: vargc and vargv can
  9247.                 only be used within user  defined  functions  which  have
  9248.                 been  defined  with a variable length argument list using
  9249.                 the ellipsis, '...'. One  of  these  variables  has  been
  9250.                 encountered  inside  of a user defined function which was
  9251.                 not defined with a variable length argument list.
  9252.                 
  9253.             5720
  9254.                 Internal Error - Variable Argument List Variable.
  9255.                 The two predefined local variables: vargc and  vargv  can
  9256.                 only  be  used  within  user defined functions which have
  9257.                 been defined with a variable length argument  list  using
  9258.                 the  ellipsis,  '...'.  One  of  these variables has been
  9259.                 previously defined as a local variable within the current
  9260.                 compound statement.
  9261.                 
  9262.             5730
  9263.  
  9264.  
  9265.         QTAwk                       - 20-25 -                       QTAwk
  9266.  
  9267.  
  9268.  
  9269.  
  9270.  
  9271.  
  9272.         Section 20.0                                           Appendix V
  9273.  
  9274.  
  9275.                 Internal Error - Variable Argument List Variable.
  9276.                 The  two  predefined local variables: vargc and vargv can
  9277.                 only be used within user  defined  functions  which  have
  9278.                 been  defined  with a variable length argument list using
  9279.                 the ellipsis, '...'. One  of  these  variables  has  been
  9280.                 previously defined as a global variable.
  9281.                 
  9282.             5740
  9283.                 Internal Parse Error: 1002.
  9284.                 Internal  parser  error.  Please contact the QTAwk author
  9285.                 with information  on  the  circumstances  of  this  error
  9286.                 message.
  9287.                 
  9288.             5750
  9289.                 Internal Parse Error: 1003.
  9290.                 Internal  parser  error.  Please contact the QTAwk author
  9291.                 with information  on  the  circumstances  of  this  error
  9292.                 message.
  9293.                 
  9294.             5760
  9295.                 Empty Regular Expression.
  9296.                 A  regular  expression  must have some characters between
  9297.                 the beginning and ending slashes.  A  regular  expression
  9298.                 has been encountered with none.
  9299.                 
  9300.             5770
  9301.                 Regular Expression - No Terminating /.
  9302.                 A  regular  expression  constant must be contained on one
  9303.                 line and be terminated by a slash. A  regular  expression
  9304.                 has  been  been  found with a no terminating slash before
  9305.                 encountering a new line.
  9306.                 
  9307.             5780
  9308.                 Internal Parse Error: 1004.
  9309.                 Internal parser error. Please contact  the  QTAwk  author
  9310.                 with  information  on  the  circumstances  of  this error
  9311.                 message.
  9312.                 
  9313.             5790
  9314.                 String Constant - No Terminating ".
  9315.                 A string constant must be contained on one  line  and  be
  9316.                 terminated  by a double quote. A string constant has been
  9317.                 been found with a  no  terminating  double  qoute  before
  9318.                 encountering a new line.
  9319.                 
  9320.             5800
  9321.  
  9322.  
  9323.         QTAwk                       - 20-26 -                       QTAwk
  9324.  
  9325.  
  9326.  
  9327.  
  9328.  
  9329.  
  9330.         Section 20.0                                           Appendix V
  9331.  
  9332.  
  9333.                 Internal Parse Error: 1005.
  9334.                 Internal  parser  error.  Please contact the QTAwk author
  9335.                 with information  on  the  circumstances  of  this  error
  9336.                 message.
  9337.                 
  9338.             5810
  9339.                 Character Constant - No Terminating '.
  9340.                 a character constant must be contained on one line and be
  9341.                 terminated by a single quote. A  character  constant  has
  9342.                 been been found with a no terminating single qoute before
  9343.                 encountering a new line.
  9344.                 
  9345.             5820
  9346.                 Character Constant Longer Than One Character
  9347.                 A character constant is a  single  character  bounded  by
  9348.                 single  quotes  as  in  'A'. Escape sequences may also be
  9349.                 used  for  specifying  the  character  for  a   character
  9350.                 constant,  e.g., '\f' or '\x012' or '\022' are three ways
  9351.                 to specify a  single  form  feed  character.  This  error
  9352.                 reports  that  an  attempt  has  been  made to use single
  9353.                 quotes to bound more than a single character.
  9354.                 
  9355.             5830
  9356.                 Lexical Error - Illegal '.'
  9357.                 Periods are used only in floating point  numerics,  e.g.,
  9358.                 0.88  or  .33, or in user defined function definitions to
  9359.                 indicate a variable number of arguments, e.g.,
  9360.                 
  9361.                 function max(...) {
  9362.                 
  9363.                 A period has been found which does not  match  either  of
  9364.                 these uses.
  9365.                 
  9366.             5840
  9367.                 Lexical Error
  9368.                 A  character  has been read which does not fit any syntax
  9369.                 for a valid utility.
  9370.                 
  9371.             5850
  9372.                 Exceeded Max. Limits On Number Of Variables.
  9373.                 A amximum of 256 global variables may be defined  in  any
  9374.                 single QTAwk utility.
  9375.             
  9376.         6.  Memory Errors
  9377.             6000
  9378.                 Out of Memory (n: , s: )
  9379.  
  9380.  
  9381.         QTAwk                       - 20-27 -                       QTAwk
  9382.  
  9383.  
  9384.  
  9385.  
  9386.  
  9387.  
  9388.         Section 20.0                                           Appendix V
  9389.  
  9390.  
  9391.                 The  QTAwk  utility  has  used  all  available memory and
  9392.                 attempted to exceed that limit. It  is  recommended  that
  9393.                 the  utility  be  made  shorter,  or  split into multiple
  9394.                 utilities run separately.
  9395.                 
  9396.             6010
  9397.                 Insufficient Memory.
  9398.                 The QTAwk utility  has  used  all  available  memory  and
  9399.                 attempted  to  exceed  that limit. It is recommended that
  9400.                 the utility be  made  shorter,  or  split  into  multiple
  9401.                 utilities run separately.
  9402.                 
  9403.             6020
  9404.             6030
  9405.                 Action Too Long
  9406.                 An  action  has been defined which exceeds the limits set
  9407.                 for the internal  length.  The  maximum  length  for  the
  9408.                 internal form of any action is 409,600 characters.
  9409.                 
  9410.             6040
  9411.             6050
  9412.             6060
  9413.                 Out of Memory
  9414.                 The  QTAwk  utility  has  used  all  available memory and
  9415.                 attempted to exceed that limit. It  is  recommended  that
  9416.                 the  utility  be  made  shorter,  or  split into multiple
  9417.                 utilities run separately.
  9418.         
  9419.         
  9420.  
  9421.  
  9422.  
  9423.  
  9424.  
  9425.  
  9426.  
  9427.  
  9428.  
  9429.  
  9430.  
  9431.  
  9432.  
  9433.  
  9434.  
  9435.  
  9436.  
  9437.  
  9438.  
  9439.         QTAwk                       - 20-28 -                       QTAwk
  9440.  
  9441.  
  9442.  
  9443.  
  9444.  
  9445.  
  9446.                                                         Table of Contents
  9447.  
  9448.  
  9449.         Table of Contents
  9450.         
  9451.         QTAwk License ............................................... iii
  9452.         == Registration Information ................................. iii
  9453.         == Upgrade Information ...................................... iii
  9454.         == QTAwk License Agreement ................................... iv
  9455.         QTAwk 4.20 Order Form ....................................... vii
  9456.         == Order Information ....................................... viii
  9457.         == International Orders: ................................... viii
  9458.         == Company Purchase Orders: ................................ viii
  9459.         == Multi-System Licenses: .................................. viii
  9460.         Update History ............................................... ix
  9461.         Introduction ................................................. xi
  9462.         
  9463.         1.0 TUTORIAL ................................................ 1-1
  9464.         1.1 Data .................................................... 1-1
  9465.         1.2 Running QTAwk ........................................... 1-2
  9466.         
  9467.         2.0 REGULAR EXPRESSIONS ..................................... 2-1
  9468.         2.1 'OR' Operator ........................................... 2-2
  9469.         2.2 Character Classes ....................................... 2-2
  9470.         2.3 Closure ................................................. 2-4
  9471.         2.4 Repetition Operator ..................................... 2-6
  9472.         2.5 Escape Sequences ........................................ 2-8
  9473.         2.6 Position Operators ...................................... 2-9
  9474.         2.7 Examples ................................................ 2-9
  9475.         2.8 Look Ahead Operator .................................... 2-11
  9476.         2.9 Match Classes .......................................... 2-11
  9477.         2.10 Named Expressions ..................................... 2-12
  9478.         2.11 Predefined Names ...................................... 2-15
  9479.         2.12 Operator Summary ...................................... 2-17
  9480.         
  9481.         3.0 EXPRESSIONS ............................................. 3-1
  9482.         3.1 New/Changed Operators ................................... 3-2
  9483.         3.2 Sequence Operator ....................................... 3-4
  9484.         3.3 Match Operator Variables ................................ 3-5
  9485.         3.4 Constants ............................................... 3-5
  9486.         
  9487.         4.0 STRINGS and REGULAR EXPRESSIONS ......................... 4-1
  9488.         4.1 Regular Expression and String Translation ............... 4-1
  9489.         4.2 Regular Expressions in Patterns ......................... 4-1
  9490.         
  9491.         5.0 PATTERN-ACTIONS ......................................... 5-1
  9492.         5.1 QTAwk Patterns .......................................... 5-1
  9493.         5.2 QTAwk Predefined Patterns ............................... 5-2
  9494.         
  9495.  
  9496.  
  9497.         .............................- xiv -.............................
  9498.  
  9499.  
  9500.  
  9501.  
  9502.  
  9503.  
  9504.         ................................................Table of Contents
  9505.  
  9506.  
  9507.         6.0 VARIABLES and ARRAYS .................................... 6-1
  9508.         6.1 QTAwk Arrays ............................................ 6-2
  9509.         6.2 QTAwk Arrays in Arithmetic Expressions .................. 6-3
  9510.         
  9511.         7.0 GROUP PATTERNS .......................................... 7-1
  9512.         7.1 GROUP Pattern Advantage ................................. 7-1
  9513.         7.2 GROUP Pattern Disadvantage .............................. 7-1
  9514.         7.3 GROUP Pattern Regular Expressions ....................... 7-2
  9515.         
  9516.         8.0 STATEMENTS .............................................. 8-1
  9517.         8.1 QTAwk Keywords .......................................... 8-1
  9518.         8.2 'cycle' and 'next' ...................................... 8-1
  9519.         8.3 'delete' and 'deletea' .................................. 8-3
  9520.         8.4 'if'/'else' ............................................. 8-5
  9521.         8.5 'in' .................................................... 8-5
  9522.         8.6 'switch', 'case', 'default' ............................. 8-5
  9523.         8.7 Loops ................................................... 8-7
  9524.         8.8 'while' ................................................. 8-7
  9525.         8.9 'for' ................................................... 8-7
  9526.         8.10 'do'/'while' ........................................... 8-8
  9527.         8.11 'local' ................................................ 8-8
  9528.         8.12 'endfile' .............................................. 8-9
  9529.         8.13 'break' ............................................... 8-10
  9530.         8.14 'continue' ............................................ 8-10
  9531.         8.15 'exit opt_expr_list' .................................. 8-10
  9532.         8.16 'return opt_expr_list' ................................ 8-10
  9533.         
  9534.         9.0 BUILT-IN FUNCTIONS ...................................... 9-1
  9535.         9.1 Arithmetic Functions .................................... 9-1
  9536.         9.2 String Functions ........................................ 9-3
  9537.         9.3 I/O Functions ........................................... 9-9
  9538.         9.4 Miscellaneous Functions ................................ 9-11
  9539.         9.4.1 Expression Type ...................................... 9-11
  9540.         9.4.2 Execute String ....................................... 9-11
  9541.         9.4.3 Array Function ....................................... 9-13
  9542.         9.4.4 System Control Function .............................. 9-14
  9543.         9.4.5 Variable Access ...................................... 9-14
  9544.         
  9545.         10.0 FORMAT SPECIFICATION .................................. 10-1
  9546.         10.1 Output Types .......................................... 10-2
  9547.         10.2 Output Flags .......................................... 10-3
  9548.         10.3 Output Width .......................................... 10-4
  9549.         10.4 Output Precision ...................................... 10-4
  9550.         
  9551.         11.0 USER-DEFINED FUNCTIONS ................................ 11-1
  9552.         11.1 Local Variables ....................................... 11-1
  9553.  
  9554.  
  9555.         .............................- xv -..............................
  9556.  
  9557.  
  9558.  
  9559.  
  9560.  
  9561.  
  9562.         ................................................Table of Contents
  9563.  
  9564.  
  9565.         11.2 Argument Checking ..................................... 11-1
  9566.         11.3 Variable Length Argument Lists ........................ 11-2
  9567.         11.4 Null Argument List .................................... 11-3
  9568.         11.5 Arrays and Used-Defined Functions ..................... 11-3
  9569.         
  9570.         12.0 TRACE STATEMENTS ...................................... 12-1
  9571.         12.1 Selective Statement Tracing ........................... 12-1
  9572.         12.2 Trace Output .......................................... 12-1
  9573.         
  9574.         13.0 BUILT-IN VARIABLES .................................... 13-1
  9575.         13.1 User Function Variable Argument Lists ................. 13-5
  9576.         
  9577.         14.0 COMMAND LINE INVOCATION ............................... 14-1
  9578.         14.1 Multiple QTAwk Utilities .............................. 14-1
  9579.         14.2 Setting the Field Separator ........................... 14-2
  9580.         14.3 Setting Variables on the Command Line ................. 14-2
  9581.         14.4 QTAwk Execution Sequence .............................. 14-3
  9582.         
  9583.         15.0 LIMITS ................................................ 15-1
  9584.         
  9585.         16.0 Appendix I ............................................ 16-1
  9586.         
  9587.         17.0 Appendix II ........................................... 17-1
  9588.         
  9589.         18.0 Appendix III .......................................... 18-1
  9590.         
  9591.         19.0 Appendix IV ........................................... 19-1
  9592.         
  9593.         20.0 Appendix V ............................................ 20-1
  9594.  
  9595.  
  9596.  
  9597.  
  9598.  
  9599.  
  9600.  
  9601.  
  9602.  
  9603.  
  9604.  
  9605.  
  9606.  
  9607.  
  9608.  
  9609.  
  9610.  
  9611.  
  9612.  
  9613.                                      - xvi -                             
  9614.