home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
qtawk
/
diffdoc.fmt
< prev
next >
Wrap
Text File
|
1990-11-04
|
13KB
|
274 lines
QTAwk
A new shareware program, QTAwk. The program is a "derivative" of "The
Awk Programming Language." Four versions of the program exist for the
IBM PC and clones depending on the h/w configuration: 8086/8088, or
80286+ and with or without 80x87 numeric co-processor.
The QTAwk package contains many complete and sample utilities which run
under QTAwk.
----------------------------------------------------------------------------
The major differences between QTAwk and Awk are summarized below:
Major differences between QTAwk (version 4.20) and Awk.
1. Expanded Regular Expressions
All of the Awk regular expression operators are allowed plus the
following:
a) complemented character class using the Awk notation, '[^...]', as
well as the Awk/QTAwk and C logical negation operator, '[!...]'.
b) Matched character classes, '[#...]'. These classes are used in
pairs. The position of the character matched in the first class of
the pair, determines the character which must match in the position
occupied by the second class of the pair.
c) Look-ahead Operator. r@t regular expression r is matched only when
followed by regular expression t.
d) Repetition Operator. r{n1,n2} at least n1 and up to n2 repetitions
of regular expression r. 1 <= n1 <= n2
e) Named Expressions.
{named_expr} is replaced by the string value of the corrsponding
variable.
2. Consistent statement termination syntax. The QTAwk Utility Creation
Tool utilizes the semi-colon, ';', to terminate all statements. The
practice in Awk of using newlines to "sometimes" terminate statements
is no longer allowed.
3. Expanded Operator Set
The Awk set of operators has been changed to more closely match those
of C. The Awk match operator, '~', has been changed to '~~' so that the
similarity between the match operators, '~~' and '!~', to the equality
operators, '==' and '!=", is complete. The single tilde symbol, '~',
reverts to the C one's complement operator, an addition to the operator
set over Awk. The introduction of the explicit string concatenation
operator. The remaining "new" operators to QTAwk are:
Operation Operator
--------- --------
tag $$
one's complement ~
concatenation ∩ ( ASCII 239, 0xef character)
shift left/right << >>
matching ~~ !~
bit-wise AND &
bit-wise XOR @
bit-wise OR |
sequence ,
The carot, '^', remains as the expoentiation operator. The symbol '@'
is used for the exclusive OR operator.
4. Expanded set of recognized constants in QTAwk utilities:
a) decimal integers,
b) octal integers,
c) hexadecimal integers,
d) character constants, and
e) floating point constants.
5. Expanded Pre-defined patterns giving more control:
a) INIITAL - similar to BEGIN. Actions executed after opening each
input file and before reading first record.
b) FINAL - similar to END. Actions executed after reading last record
of each input file and before closing file.
c) NOMATCH - actions executed for each input record for which no
pattern was matched.
d) GROUP - used to group multiple regular expressions for search
optimization. Can speed search by a factor of six.
6. True multi-dimensional arrays
The use of the comma in index expressions to simulate multiple array
indices is no longer supported. True multiple indices are supported.
Indexing is in the C manner, 'a[i1][i2]'. The SUBSEP built-in variable
of AWK has been dropped since it is no longer necessary.
7. Integer array indices as well as string indices
Array indices have been expanded to include integers as well as the
string indices of Awk. Indices are not automatically converted to
strings as in Awk. Thus, for true integer indices, the index ordering
follows the numeric sequence with an integer index value of '10'
following a value of '2' instead of preceeding it.
8. Arrays integrated into QTAwk
QTAwk integrates arrays with arithmetic operators so that the
operations are carried out on the entire array. QTAwk also integrates
arrays into user-defined functions so that they can be passed to and
returned from such functions in a natural and intuitive manner. Awk
does not allow returning arrays from user-defined functions or allow
arithmetic operators to operate on whole arrays.
9. NEW keywords:
a) cycle
similar to 'next' except that may use current record in restarting
outer pattern matching loop.
b) deletea
similiar to 'delete' except that ALL array values deleted.
c) switch, case, default
similiar to C syntax with the allowed 'switch' and 'case' values
expanded to include any legal QTAwk expression, evaluated at
run-time. The expressions may evaluate to any value including any
numeric value, string or regular expression.
d) local
new keyword to allow the declaration and use of local variables
within compound statements, including user-defined functions. Its
use in user defined functions instead of the Awk practice of
defining excess formal parameters, leads to easier to read and
maintain functions. The C 'practice' of allowing initialization in
the 'local' statement is followed.
e) endfile
similar to 'exit'. Simulates end of current input file only, any
remaining input files are still processed.
10. Expanded arithmetic functions
QTAwk includes 18 built-in arithmetic functions. All of the functions
supported by Awk plus the following:
a) acos(x)
b) asin(x)
c) cosh(x)
d) fract(x)
e) log10(x)
f) pi() or pi
g) sinh(x)
11. Expanded string functions
QTAwk includes 33 built-in string functions. All of the functions
supported by Awk plus the following:
a) center(s,w) or center(s,w,c)
b) copies(s,n)
c) deletec(s,p,n)
d) insert(s1,s2,p)
e) justify(a,n,w) or justify(a,n,w,c)
f) overlay(s1,s2,p)
g) remove(s,c)
h) replace(s)
i) sdate(fmt)
j) srange(c1,c2)
k) srev(s)
l) stime(fmt)
m) stran(s) or stran(s,st) or stran(s,st,sf)
n) strim(s) or strim(s,c) or strim(s,c,d)
o) strlwr(s)
p) strupr(s)
12. New Miscellaneous functions
a) The function 'rotate(a)' is provided to rotate the elements of the
array a.
b) execute(s) or execute(s,se) or execute(s,se,rf) - execute string s
c) execute(a) or execute(a,se) or execute(a,se,rf) - execute array a
d) pd_sym - access pre-defined symbols
e) ud_sym - access user defined symbols
13. New I/O Functions
I/O function syntax has been made consistent with syntax of other
functions. The redirection operators, '<', '>' and '>>', and pipeline
operator, '|', have been deleted as excessively error prone in
expressions. The functional syntax of the 'getline' function has been
made identical to that of the other built-in functions. The new
functions 'fgetline', 'fprint' and 'fprintf' have been introduced for
reading and writing to files other than the current input file. Single
Character input functions, 'getc' and 'fgetc' have been added to read
files (and the keyboard) a single character at a time.
14. Expanded capability of formatted I/O.
The limited output formatting available with the Awk 'printf' function
has been expanded by adopting the complete output format specification
of the draft ANSI C standard.
15. Use of 'local' keyword
The 'local' keyword has been introduced to allow for variables local to
user-defined functions (and any compound statement). This expansion
makes the Awk practice of defining 'extra' formal parameters no longer
necessary.
16. Expanded user-defined functions
With the 'local' keyword, QTAwk allows the user to define functions
that may accept a variable number of arguments. Functions, such as
finding the minimum/maximum of a variable number of variables, are
possible with one function rather than defining separate functions for
each possible combination of arguments.
17. User controlled trace capability
A user controlled statement trace capability has been added. This gives
the user a simple to use mechanism to trace utility execution. Rather
than adding 'print' statements, merely re-defining the value of a
built-in variable will give utility execution trace information,
including utility line number.
18. Expanded built-in variable list
With 30 built-in variables, QTAwk includes all (with the exception of
SUBSEP) of the built-in variables of Awk plus the following:
a) _arg_chk - used to determine whether to check number of arguments
passed to user-defined functions.
b) ARGI - index value in ARGV of next command line argument. Gives
more control of command line argument processing.
c) CYCLE_COUNT - count number of outer loop cycles with current input
record.
d) DEGREES - if TRUE, trigonometric functions assume degree values,
radians if FALSE.
e) ENVIRON - array of environment strings passed to QTAwk
f) FALSE - pre-defined with constant value, 0.
g) TRUE - predefined with constant value, 1
h) LONGEST_EXP - used to control whether the longest or the first
string matching a regular expression is found.
j) MAX_CYCLE - maximum number of outer loop cycles permitted with
current input record.
k) NG - equal to the number of the regular expression in a group
matching a string in the current input record.
k) RETAIN_FS - if TRUE the original characters separating the fields
of the current input record are retained whenever a field is
changed, causing the input record to be re-constructed. If FALSE
the output field separator, OFS, is used to separate fields in the
current input record during reconstruction. The latter practice is
the only method available in Awk.
l) TRACE - value used to determine utility tracing.
m) TRANS_FROM/TRANS_TO - strings used by 'stran' function if second
and/or third arguments not specified.
n) CLENGTH - similiar to 'RLENGTH' of Awk. Set whenever a 'case' value
evaluates to a regular expression.
o) CSTART - similiar to 'RSTART' of Awk. Set whenever a 'case' value
evaluates to a regular expression.
p) MLENGTH - similiar to 'RLENGTH' of Awk. Set whenever a stand-alone
regular expression is encountered in evaluting a pattern.
q) MSTART - similiar to 'RSTART' of Awk. Set whenever a stand-alone
regular expression is encountered in evaluting a pattern.
r) vargc - used only in used-defined functions defined with a variable
number of arguments. At runtime, set equal to the actual number of
variable arguments passed.
s) vargv - used only in used-defined functions defined with a variable
number of arguments. At runtime, an single dimensioned array with
each element set to the argument actually passed.
19. Definition of built-in variable, RS, expanded to mimic the FS built-in
variable. For A single character string, the single character becomes
the input record separator. If the string is longer than a single
character, it is treated as a regular expression, and any string
matching the regular expression becomes a record separator. Awk will
recognize first character only of RS string as record delimitor.
20. In QTAwk, setting built-in variable, "FILENAME", to another value will
change the current input file. Setting the variable in Awk, has no
effect on current input file.
21. New character input functions, 'getc' and 'fgetc', can accept keyboard
input also.
22. Corrected admitted problems with Awk. The problems mentioned on page
182 of "The Awk Programming Language" have been corrected.
Specifically: 1) true multi-dimensional arrays have been implemented,
2) the 'getline' syntax has been made to match that of other functions,
3) declaring local variables in user-defined functions has been
corrected, 4) intervening blanks are allowed between the function call
name and the opening parenthsis (in fact, under QTAwk it is permissable
to have no opening parenthesis or argument list for user-defined
functions that have been defined with no formal arguments).