User Guide
Chapters
Table of Contents
Variables
Expressions

Built-In Variables


QTAwk offers the following built-in variables. The variables may be set by the user. Section Built In Variable List contains a list of all built-in variables for reference.
_arg_chk ARGC ARGI ARGV CLENGTH
CSTART CONVFMT CYCLE_COUNT DEGREES DELAY_INPUT_PARSE
ECHO_INPUT ENVIRON FALSE FIELDFILL FIELDWIDTHS
FILEATTR FILEDATE FILEDATE_CREATE FILEDATE_LACCESS FILENAME
FILEPATH FILE_SEARCH FILE_SEARCH_PAT FILESIZE FILE_SORT
FILETIME FILETIME_CREATE FILETIME_LACCESS FNR FS
Gregorian IGNORECASE LOCALE LONGEST_EXP MATCH_INDEX
MAX_CYCLE MLENGTH MSTART NF NG
NR OFMT ORS POSIX
RECLEN
RLENGTH
RSTART
RETAIN_FS
RS
RT
SPAN_RECORDS
SUBSEP
TRACE
TRANS_FROM
TRANS_TO
TRUE
QTAwk_Path
vargc
vargv
PROCINFO



USER_FUNCTIONS
MODULES
Module_Path






_arg_chk TRUE/FALSE. Default value = 0. If assigned a FALSE value, the number of arguments passed to a user defined function is checked only to ensure that the number is not more than defined. Arguments defined, but not passed are initialized and passed for use as local variables as in Awk. If assigned a true value, the number of arguments passed to a user defined function is checked against the number defined for the function, unless the function was defined with a variable number of arguments. If the number passed is not exactly equal to the number defined, an error message is issued and execution halted. For this case, any local variables must be defined with the local keyword.
ARGC Set equal to the number of arguments passed to QTAwk
ARGI Equal to the index value in ARGV of the NEXT command line argument to be processed. This value may be changed and will change the array element of ARGV processed next. When the last element of ARGV is the current input file, ARGI is set to one of two integer values:
  1. the integer value of the index of the last element of ARGV plus one, or
  2. if the last element of ARGV has a string index, ARGI is set to zero.

Setting ARGI to zero, ARGC or a value for which there is no element of ARGV with a corresponding index value, will cause the current input file to be the last command line argument processed.

ARGV One-dimensional array with elements equal to the arguments passed to QTAwk. The index values are integers ranging in value from zero to ARGC. ARGV[0] equals the filename by which QTAwk was invoked, including full path information, if used in the invocation.
CLENGTH Assigned the length of string matched in a case statement using a regular expression for the case label.
CSTART Assigned the start index of the string matched in a case statement using a regular expression for the case label.
CONVFMT Format for converting string values to floating point numbers. Default value of "%.6g". Refer to section Numerics and Strings for a discussion on the use of CONVFMT in converting strings to numerics.
CYCLE_COUNT Value for the current cycle through the outer pattern match loop for the current record. Value incremented by the cycle statement.
DEGREES TRUE/FALSE. Default value = 0. If assigned a false value, trigonometric functions assume radian values are passed and return radian values. If assigned a TRUE value, trigonometric functions assume degree values are passed and return degree values.
DELAY_INPUT_PARSE TRUE/FALSE. Default value = 0. Used to delay parsing of the current input record until the value of NF or one of the field variables, $i, 1 <= i <= NF, is needed. If the value is true, then the input record is not parsed until necessary. For utilities which do not reference NF or the field variables, $i, in any pattern expressions (or seldom executed pattern expressions), delaying the parsing of the input record can speed the execution of the utility significantly. The normal sequence of execution is:
  1. determine next record according to RS and read record,
  2. set value of RT,
  3. set FNR and NR.
  4. parse record according to FS and set NF and $i, 1 <= i <= NF.
  5. start executing pattern expressions

The fourth step in the above sequence can be delayed until a field variable value or NF is needed by setting DELAY_INPUT_PARSE to a true value.

ECHO_INPUT TRUE/FALSE. Default value = 0. If assigned a true value, when reading from the keyboard file, the input is echoed to the standard output file, normally the console display.

Any characters read from the standard input file, stdin, are echoed to the standard output file, stdout, if ECHO_INPUT has a true value. If ECHO_INPUT has a false value, then characters read from stdin are not echoed to stdout. When the input to QTAwk has been redirected or piped by the operating system, or the input file has been specified on the command line as a single hyphen, '-', then any input read will be echoed to stdout according to the value of ECHO_INPUT. Since the default value of ECHO_INPUT is 0, the following simple command line utility:

QTAwk "{print;}" <input_file

will display a single copy of each input line.

Modifying the utility as:

QTAwk "BEGIN{ECHO_INPUT=1;}{print;}" <input_file

will display two copies of each record from the redirected input file. The first record will be displayed because of the echoed input from 'stdin'. The second copy of the input record will be from the explicit print statement.

When the standard input file is the keyboard, any characters read are always echoed to the console display. In addition, if ECHO_INPUT is true, then any characters read are also echoed to the standard output file.

When the standard input file is redirected from a file or piped from the output of another application program, it is convenient to set ECHO_INPUT to a false value to prevent echoing each input character to the standard output file.

For input read from the keyboard file with the fgetc function, ECHO_INPUT should be set to a true value to display key values as they are pressed.

The following table shows the effect of ECHO_INPUT on input from the standard input file and the keyboard file:
ECHO_INPUT->
true
false
echo keyboard to display yes no
echo stdin to display yes yes
echo stdin to stdout yes no
echo redirected stdin to display no no
echo redirected stdin to stdout yes no

ENVIRON One-dimensional array with elements equal to the environment strings passed to QTAwk. The index values are integers ranging in value from zero to the number of environment strings defined less one.

For example, running the following simple utility will display all environment strings defined and passed to QTAwk:

 C:\>qtawk "BEGIN{for(i in ENVIRON)print i,ENVIRON[i];}"

The following is typical of the output obtained:

0 COMSPEC=C:\OS2\MDOS\COMMAND.COM
1 PROMPT=$i$p$g
2 PATH=C:\OS2;C:\OS2\MDOS;C:\OS2\MDOS\WINOS2;C:\;
3 KEDFILE=D:\KEDIT
4 TMP=D:\
5 TEMP=C:\OS2\MDOS\WINOS2\TEMP
6 LIB=D:\C700\LIB;C:\C700\MFC\LIB
7 INCLUDE=D:\C700\INCLUDE;C:\C700\MFC\INCLUDE;C:\MASM\INCLUDE
8 HELPFILES=D:\C700\HELP\*.HLP;C&colon./C700\HELP
9 INIT=D:\C700\INIT
10 QTAWK=E:\QTAwk_Fn;
11 QTGREP=D:\QTAwk_Fn;
12 ETC=g:\tcpip\dos\etc
FALSE Predefined with zero, 0, constant value.
FIELDFILL This variable value is used only when field splitting is based on FIELDWIDTHS rather than FS. If field splitting is based on FIELDWIDTHS, then the string value of this variable is used to fill a field when the replacement value is less than the field width or if the field changed is greater than the number of fields in the original record. If the field changed is greater than the number of fields defined in FIELDWIDTHS the extra fields created are initialized as null strings separated by the string value of OFS. The default value is a single blank character.
FIELDWIDTHS When assigned a string value containing space separated integral numbers of the form:

n1 n2 n3 ... nn

the splitting of input records into fields is governed by the numbers in FIELDWIDTHS rather than FS. Each number in FIELDWIDTHS specifies the width of a field including columns between fields. If you want to ignore the columns between fields, you can specify the width as a separate field that is subsequently ignored. When the value FIELDWIDTHS does not match this form, field splitting is done using FS in the usual manner. If the length of the input record is greater than the sum of the field widths specified in FIELDWIDTHS. QTAwk creates an additional field and assigns the remainder of the input record to the field.

Assigning the following string to FIELDWIDTHS:

FIELDWIDTHS = "8 25 6 15 9 10";

QTAwk will break subsequent records into 1 to 7 fields depending on the record length. For records with a length of exactly 73 (== 8 + 25 + 6 + 15 + 9 + 10), each field has the lengths specified. For records with greater than 73 characters, the additional characters are assigned to field 7. For records with less than 73 characters, QTAwk creates fields until the characters in the record are exhausted.

This variable is especially helpful when used in conjunction with the RECLEN for fixed length input records. For example, a "dir" under PC/MS-DOS produces records of fixed length as follows:

15:31:50.44>dir

The volume label in drive C is OS2.
The Volume Serial Number is A736:0414.
Directory of C:\

AUTOEXEC BAT 798 12-01-96 5:54p
BOOT DAT 16896 11-26-96 5:51p
CID < DIR > 11-26-96 5:57p
CONFIG SYS 12810 2-06-97 6:58p
DESKTOP < DIR > 11-26-96 6:01p
DMISL < DIR > 11-26-96 5:47p
DOS DAT 33280 11-26-96 5:51p
IBMCOM < DIR > 11-26-96 5:57p
29 file(s) 203191 bytes used
15196160 bytes free

After reading the first 5 records, setting:

RECLEN = 40;
FIELDWIDTH = "8 1 3 1 9 2 2 1 2 1 2 1 2 1 2 1 1";

Allows for easily accessing each component of the listing as follows:

$1 ==> filename string
$3 ==> file extension string
$5 ==> file size or "< DIR >" string
$7 ==> month of file date
$9 ==> day of file date
$11 ==> year of file date
$13 ==> hour of file time
$15 ==> minute of file time
$16 ==> 'p' or 'a' of file time
Note that fields $2, $4, $6, $8, $10, $12 and $14 are separator columns in the directory listing and have been ignored. $17 is the newline, '\n', character separating records. If RECLEN had not been set, i.e. left with a zero value, then $17 would be the null string since the the newline character would not be part of the record.

For HPFS under OS/2, the directory listing is no longer a fixed length, since filenames are no longer fixed length. The following is typical of a directory listing for HPFS:

The volume label in drive C is OS2.
The Volume Serial Number is A736:0414.
Directory of C:\

12-01-96 5:54p 798 0 AUTOEXEC.BAT
11-26-96 5:51p 16896 0 boot.dat
8-12-96 2:43a 43369 0 CDFS.IFS
11-26-96 5:57p < DIR > 0 CID
2-06-97 6:58p 12810 0 CONFIG.SYS
11-26-96 6:01p < DIR > 447 Desktop
11-26-96 5:51p 33280 0 DOS.DAT
11-26-96 5:25p < DIR > 0 IBMINST
11-26-96 5:58p 256 0 IBMLVL.INI
11-26-96 5:27p < DIR > 0 IBMVESA
8-30-96 5:58p 47168 0 README
11-26-96 5:35p <.DIR>. 300 SPOOL
30 file(s) 203191 bytes used
15198720 bytes free

Leaving RECLEN as zero and setting FIELDWIDTHS as:

FIELDWIDTHS = "2 1 2 1 2 2 2 1 2 1 1 9 1 10 2";

The components of the directory listing can be accessed via the fields as:

$1 ==> file date month
$3 ==> file date day
$5 ==> file date year
$7 ==> file time hour
$9 ==> file time minute
$10 ==> 'a' or 'p'
$12 ==> file size string or "<DIR>" string
$14 ==> file attributes size
$16 ==> remainder of record == file name string,

Judicious use of the FIELDWIDTHS variable with records with fields with precisely defined sizews, can make accessing particular fields very easy.

FILEATTR Contains the attributes of the current input file as an integer. The integer defines the attributes in the same manner as the variable for the findfile function defines the attributes for the files found by that function. Changing the value of this variable has no effect on the attributes of the current input file.
FILEDATE Contains the date of the current input file as a Julian Day Number. Refer to the jdn function for a definition of the Julian Day Number. The _ftime function may be used to format the date. Changing the value of this variable has no effect on the date of the current input file.
FILEDATE_CREATE Contains the CREATION date of the current input file as a Julian Day Number. Refer to the jdn function for a definition of the Julian Day Number. The _ftime function may be used to format the date. Changing the value of this variable has no effect on the creation date of the current input file. On PC/MS-DOS systems, this value of this variable equals the value of FILEDATE.
FILEDATE_LACCESS Contains the last file ACCESS date of the current input file as a Julian Day Number. Refer to the jdn function for a definition of the Julian Day Number. The _ftime function may be used to format the date. Changing the value of this variable has no effect on the last access date of the current input file. On PC/MS-DOS systems, this value of this variable equals the value of FILEDATE.
FILENAME Equal to the string value of current input file, NOT including any path specified. If assigned a new value, the file with a name equal to the new string value is opened (or an error message displayed if the file cannot be opened). The new file becomes the current input file. The former input file is not closed and input may continue from the current position by re-assigning FILENAME, putting the name in ARGV for future use or read with the fgetline function.

If assigned a new string value by the user's utility, the full drive and path must be specified if necessary to find the file. QTAwk will strip off the drive and path and assign the filename to the FILENAME variable. The following statements will save the current filepath and name and re-assign it for later use:

# Save Current File Name
fpn_hold = FILEPATH >< FILENAME;
.
.
.
# Revert To Processing Original Input File
FILENAME = fpn_hold;
FILEPATH Contains the drive and path of the current input file. The path string ends with the subdirectory separator character. Changing the value of this variable has no effect on the path of the current input file.
FILE_SEARCH TRUE/FALSE values. Default value = 0. Value determines whether next input record read from the current input file is the next physical record or the next record(s) matching a pattern in FILE_SEARCH_PAT. If assigned a false value, then the next physical record is read. If assigned a true value, then the next record(s) matching a pattern in FILE_SEARCH_PAT is read. Multiple records may be read if SPAN_RECORDS is true and the match spans more than one record. See Pattern/Actions for a more complete explanation of searching the input file for the next record.
FILE_SEARCH_PAT Assigned by the user to the patterns to match in the current input file if FILE_SEARCH. contains a true value. If FILE_SEARCH_PAT is an array, then all array elements are scanned for matches and the MATCH_INDEX built-in variable is set accordingly. See Pattern/Actions for a more complete explanation of searching the input file for the next record.
FILESIZE Contains the size in bytes of the current input file. Changing the value of this variable has no effect on the size of the current input file.
FILE_SORT The string value of this variable defines the sort order for the array returned by the findfile function. The default value is the null string, i.e., the array contains files in the order returned by the operating system.

Valid character values for sorting are given in the table below. Note that case is unimportant.
value Sort
n sort by file name
e sort by file extension
wd sort by file write date
cd sort by file creation date
ad sort by file last access date
wt sort by file write time
ct sort by file creation time
at sort by file last access time
s sort by file size

Any other character(s) will be ignored.

If multiple sort options are specified, the files returned are sorted in the order of preference given.

For example:

# Will Sort By Write Date, Write Time,
# File Extension, File Name And Last By Size
FILE_SORT = "wdwtens";
FILETIME Contains the time of the current input file as seconds since midnight. The _ftime function may be used to format the time. Changing the value of this variable has no effect on the time of the current input file.
FILETIME_CREATE Contains the CREATION time of the current input file as seconds since midnight. The _ftime function may be used to format the time. Changing the value of this variable has no effect on the creation time of the current input file. On PC/MS-DOS systems the value of this variable equals the value of FILETIME.
FILETIME_LACCESS Contains the last file ACCESS time of the current input file as seconds since midnight. The _ftime function may be used to format the time. Changing the value of this variable has no effect on the lastr access time of the current input file. On PC/MS-DOS systems the value of this variable equals the value of FILETIME.
FNR Equal to current record number of the current input file. If the current value of $0 contains more than one input record, then FNR contains the number of the last record in $0. See the definition of the built-in variables FILE_SEARCH, FILE_SEARCH_PAT and SPAN_RECORDS and Pattern-Action Pairs for a more complete explanation of searching the input file for the next record and how $0 may contain more than one input record.

See also NR.

FS Value of the current input field separator. If FIELDWIDTHS is not assigned a proper value for record splitting, then the value of FS is used for splitting the current input record into fields.

Update: 11-27-2005 - If the value of FS is changed, the current record is immediately re-parsed. This is useful if a field variable has been changed and the new value contains separator characters within the value. For example, given the record:

This would be record number:xxxxx with the file

and the 5th field is changed to replace the colon, ':', with a single blank:

number:xxxxx -->  number xxxxx

Then the 5th field would be two words which would normally be separated into two fields. To force the re-parsing simply assign FS to itself, thus:

FS = FS;

The record is immediately re-parsed when the assignment is accomplished and the number of fields is increased from 8 to 9.

The default value for FS is /{_z}+/ == /[[:space:]]+/, i.e., any consecutive white space characters. If FS is set on the command line or in the user utility then the following rules apply (see also RS):
  1. setting to a single blank, ' ' or " ", will set FS to the default value of /{_z}+/. With the default value for FS, leading and trailing white space will be stripped from the input record prior to splitting the record into fields.
  2. setting to a value other than a regular expression constant, the regular expression value will be derived. The regular expression will be converted to the regular expression internal form when the assignment is made. Input records are scanned for a string matching the regular expression and matching strings become field separators. The length of matching strings is governed by the LONGEST_EXP. built-in variable.

    NOTE: If FS is explicitly assigned the default value of /{_z}+/, the splitting of the input record into fields will be accomplished exactly the same as if FS had been assigned a single blank character except that the striping of leading and trailing white space is not done. Thus, if a record has leading white space, the first field will be the null string preceding the white space.


  3. setting to the null string, "", causes field splitting to be done at each character of the input record, i.e., each input field will be a single character from the input record and the number of fields in the input record, NF, will be set to the length of the input record.

If FS is any other single character, such as ",", then each occurrence of that character separates two fields. Two consecutive occurrences delimit an empty field. If the character occurs at the beginning or the end of the line, that too delimits an empty field. The space character is the only single character which does not follow these rules.

Suppose you want single spaces to separate fields the way single commas were used above. You can set FS to /[\s]/. This regular expression matches a single space and nothing else.

There is an important difference between the two cases:

  1. FS = " "; and
  2. FS = /{_z}+/;

For both values of FS, fields are separated by runs of spaces and/or tabs. However, in the first case, QTAwk will first strip leading and trailing whitespace from the record before parsing the record into fields.

For example, with the following input record:

" a b c d e f "

if FS is the default, then the first field of the input record is:

"a"

If, however, FS is set as:

FS = /{_z}+/;

then the first field of the input record is a null string since the leading and trailing white space have not been stripped from the record.

Additionally, if any field is changed the record is rebuilt. The rebuilding process can occur in two ways depending upon the value of the built-in variable, RETAIN_FS. If RETAIN_FS is false, the default value, then QTAwk rebuilds the record by concatenating the fields separated by the string value of OFS. Leading and trailing white space are not retained. If, however, the value of RETAIN_FS is true, then if any field is changed, the new value REPLACES the old value in the input record. All other characters of the input record are unchanged.

Thus, the following short utility:

{
print;
for ( i = 1 ; i <= NF ; i++ ) $i = strupr($i);
print;
}

the output for the above input record is:

"   a b c d e f   "
"A B C D E F"

If the following BEGIN action is added to the above utility,

BEGIN {
RETAIN_FS = TRUE;
}

then the output is:

"   a b c d e f   "
" A B C D E F "

There are times when you may want to examine each character of a record separately. In QTAwk, this is easy to do, you simply assign the null string to FS:
FS = "";

In this case, each character in the record will become a separate field.

{
for ( i = 1 ; i <= NF ; i++ )
print "Field " >< i >< ":",$i;

With the input record:

"a b c d e f"

the output is:

Field 1: a
Field 2: b
Field 3: c
Field 4: d
Field 5: e
Field 6: f
Gregorian TRUE/FALSE. Default == 1. If assigned a true value, QTAwk assumes the Gregorian Calendar in computing the Julian Day Number in the jdn function. The value also affects the calendar used in converting a Julian Day Number to calendar date by the _ftime function. If assigned a false value, QTAwk assumes the Julian Calendar.
IGNORECASE TRUE/FALSE. Default == 0. If assigned a true value, QTAwk ignores case in any operation comparing two strings and for single character comparisons. The affected comparisons include:
  1. any match using the match operators, ~~ and !~, either explicit or implied, in pattern expressions,
  2. any match using the match operators, ~~ and !~, either explicit or implied, in action expressions,
  3. any match using the functions:
    1. gensub
    2. gsub
    3. index
    4. match
    5. split
    6. sub
    7. strim
    8. srchrecord
    9. fsrchrecord
  4. any search using the FILE_SEARCH_PAT variable,
  5. any match of one string against another using the equality operators, == and !=
  6. any match of one character against another using the equality operators, == and !=
  7. any match of one string against another string in switch/case statements,
  8. any match of one character against another character in switch/case statements,
  9. any match against a regular expression in switch/case statements,
  10. all searches for record terminator character/strings using RS.
  11. all searches for field separator character/strings using FS.
LOCALE This variable is a single dimensioned vector containing the string values specific to the current locale. The following indices are defined (The string in parenthsis is the value for the 'en' locale): (The indices are listed in sorted order)
  1. ABDAY_1 (Sun) -- the abbreviated name of the 1st day of the week
  2. ABDAY_2 (Mon) -- the abbreviated name of the 2cd day of the week
  3. ABDAY_3 (Tue) -- the abbreviated name of the 3rd day of the week
  4. ABDAY_4 (Wed) -- the abbreviated name of the 4th day of the week
  5. ABDAY_5 (Thu) -- the abbreviated name of the 5th day of the week
  6. ABDAY_6 (Fri) -- the abbreviated name of the 6th day of the week
  7. ABDAY_7 (Sat) -- the abbreviated name of the 7th day of the week
  8. ABMON_1 (Jan) -- the abbreviated name of the 1st month of the year
  9. ABMON_10 (Oct) -- the abbreviated name of the 10th month of the year
  10. ABMON_11 (Nov) -- the abbreviated name of the 11th month of the year
  11. ABMON_12 (Dec) -- the abbreviated name of the 12th month of the year
  12. ABMON_2 (Feb) -- the abbreviated name of the 2cd month of the year
  13. ABMON_3 (Mar) -- the abbreviated name of the 3rd month of the year
  14. ABMON_4 (Apr) -- the abbreviated name of the 4th month of the year
  15. ABMON_5 (May) -- the abbreviated name of the 5th month of the year
  16. ABMON_6 (Jun) -- the abbreviated name of the 6th month of the year
  17. ABMON_7 (Jul) -- the abbreviated name of the 7th month of the year
  18. ABMON_8 (Aug) -- the abbreviated name of the 8th month of the year
  19. ABMON_9 (Sep) -- the abbreviated name of the 9th month of the year
  20. AM_STR (AM) -- the string used to denote time before noon
  21. CURRENCY_SYMBOL ($) -- the currency symbol
  22. DAY_1 (Sunday) -- the full name of the 1st day of the week
  23. DAY_2 (Monday) -- the full name of the 2cd day of the week
  24. DAY_3 (Tuesday) -- the full name of the 3rd day of the week
  25. DAY_4 (Wednesday) -- the full name of the 4th day of the week
  26. DAY_5 (Thursday) -- the full name of the 5th day of the week
  27. DAY_6 (Friday) -- the full name of the 6th day of the week
  28. DAY_7 (Saturday) -- the full name of the 7th day of the week
  29. DECIMAL_POINT (.) -- the decimal point used in formatted numerics
  30. D_FMT (%m/%d/%y) -- format string used for date
  31. D_T_FMT (%a %d %b %Y %r %Z) -- format string used for date and time. Date and time formats are explained in Date/Time Formats.
  32. FRAC_DIGITS () -- the number of digits to display to the right of the decimal point for monetary values.
  33. GROUPING () -- the sizes of the digits groups for non-monetary values. Successive elemnts of the string describe groups going away from the decimal point. An element value of zero, 0, calls for the previous value to be repeated indefinitely. An element value of 256 ends any further grouping.
  34. INT_CURR_SYMBOL (USD ) -- the international currency symbol specified by ISO 4217.
  35. INT_FRAC_DIGITS () -- the number of digits to display to the right of the decimal point for international monetary values.
  36. LOCALE (en) -- locale name
  37. MON_1 (January) -- full name of the 1st month of the year
  38. MON_10 (October) -- full name of the 10th month of the year
  39. MON_11 (November) -- full name of the 11th month of the year
  40. MON_12 (December) -- full name of the 12th month of the year
  41. MON_2 (February) -- full name of the 2cd month of the year
  42. MON_3 (March) -- full name of the 3rd month of the year
  43. MON_4 (April) -- full name of the 4th month of the year
  44. MON_5 (May) --full name of the 5th month of the year
  45. MON_6 (June) --full name of the 6th month of the year
  46. MON_7 (July) --full name of the 7th month of the year
  47. MON_8 (August) --full name of the 8th month of the year
  48. MON_9 (September) --full name of the 9th month of the year
  49. MON_DECIMAL_POINT (.) -- the decimal point for monetary values
  50. MON_GROUPING () -- the sizes of the digits groups for monetary values. Successive elemnts of the string describe groups going away from the decimal point. An element value of zero, 0, calls for the previous value to be repeated indefinitely. An element value of 256 ends any further grouping.
  51. MON_THOUSANDS_SEP (,) -- the separator for digits groups to the left of the decimal point for monetary values
  52. N_CS_PRECEDES () -- whether the currency symbol precedes (1) or follows (0) the value for negative monetary values
  53. NEGATIVE_SIGN (-) -- the negative sign for monetary values
  54. NOEXPR (^[nN].*) -- a regular expression which can be used to recognize a negative response to a yes/no question
  55. N_SEP_BY_SPACE () -- whether the currency symbol is separated by a space (1) or immediately follows (0) the value for negative monetary values
  56. N_SIGN_POSN () -- for negative monetary value, whether:
    1. 0 --> parentheses surround the value and the currency symbol
    2. 1 --> the negative sign precedes the value and the currency symbol
    3. 2 --> the negative sign follows the value and the currency symbol
    4. 3 --> the negative sign immediately precedes the currency symbol
    5. 4 --> tthe negative sign immediately follows the currency symbol
  57. P_CS_PRECEDES () -- whether the currency symbol precedes (1) or follows (0) the value for positive monetary values
  58. PM_STR (PM) -- the string used to denote time after noon
  59. POSITIVE_SIGN () -- the positive sign for monetary values
  60. P_SEP_BY_SPACE () -- whether the currency symbol is separated by a space (1) or immediately follows (0) the value for positive monetary values
  61. P_SIGN_POSN () -- for positive monetary value, whether:
    1. 0 --> parentheses surround the value and the currency symbol
    2. 1 --> the positive sign precedes the value and the currency symbol
    3. 2 --> the positive sign follows the value and the currency symbol
    4. 3 --> the positive sign immediately precedes the currency symbol
    5. 4 --> tthe positive sign immediately follows the currency symbol
  62. T_FMT (%r) -- format string used for time. Date and time formats are explained in Date/Time Formats.
  63. T_FMT_AMPM (%I:%M:%S %p) -- format string used for time with before/after noon designation
  64. THOUSANDS_SEP (,) -- the separator for digits groups to the left of the decimal point for non-monetary values
  65. YESEXPR (^[yYsS].*) -- a regular expression which can be used to recognize a positve response to a yes/no question
LONGEST_EXP TRUE/FALSE. Default == 1. If assigned a true value, the longest string matching a regular expression is found in:
  1. patterns
  2. expressions containing the match operators, ~~ and !~
  3. the match function
  4. the gensub function
  5. the gsub function
  6. the sub function
  7. the strim function
  8. input record separator strings matching RS pattern(s)
  9. input record field separator strings matching FS. pattern(s)
  10. field separator matching in the split function

If assigned a false value, then the first string matching the regular expression is found.

MATCH_INDEX Set to the string value of the index of the matching element when an array is used for matching. QTAwk uses the string value of SUBSEP to separate indices for multidimensional arrays.
MAX_CYCLE The maximum value for CYCLE_COUNT when cycling through outer pattern match loop with the current input record. Default value == 100. Refer to the discussion of the cycle statement.
MLENGTH Assigned the length of the string matched by the match operators, ~~ and !~, used in expressions.
MODULES
This is a singly dimensioned array. The index for each array element is the name of a currently loaded module and the element value is the module count when the module was loaded. When a module is unloaded, the array element corresponding to that module is deleted from the array.

The element index by zero,0, equals the count of currently loaded modules.
Module_Path
This variable is set in the configuration file, '.qtawkrc'.  The variable specifies paths to be searched for module files. Multiple paths may be specified, separated by semi-colons. The paths specified are searched for module files in the order specified. If a drive and/or path is specified with an module filename, then that drive and path only are searched for the desired file. If no drive or path is specified with an module filename, then the current directory is searched and then the paths specified in Module_Path. The search sequence for files follows the the order:
  1. If a directory and/or path name name is specified for an module file, then that path only is searched.
  2. If no directory or path name is specified, then the current directory is searched. If the file is not found, then all paths specified in Module_Path are searched for the file in the order specified. Multiple paths may be specified, separated by a semi-colon. This follows the same convention for specifying multiple paths in the system environment path setting, "PATH".

The value of Module_Path may be reset at any time by the user's utility to change the paths to be searched for module files. Setting the value of Module_Path to a false value, will null the directory search, only the current directory will be searched.

MSTART Assigned the start index of the string matched by the match operators, ~~ and !~ used in expressions.
NF Equal to the number of fields in the current input record. The action of QTAwk when NF is changed reflects the intuitive effect of changing NF. If the new value is less than the current value, the current input line is shortened by truncating at the end of the field corresponding to the new NF value.

If the new value of NF is greater than the current value, the current input line is lengthened. The method by which QTAwk split the current record into fields determines how the record is lengthened. If QTAwk is using the value of FS to split records into fields, then the current record is lengthened by concatenating empty fields separated by the output field separator string, OFS, onto the end of the record.

If field splitting is currently done using the FIELDWIDTHS variable, then, QTAwk follows the following rules for adding new fields:

  1. new fields are added using the fields widths specified in FIELDWIDTHS. The new fields are filled using the current string value of FIELDFILL. The string value of FIELDFILL is repeated as necessary to fill each field.
  2. When the field to be added exceeds the number of fields specified in FIELDWIDTHS, then new fields are added as if field splitting was accomplished using FS.
NG Set to the number of the GROUP expression matching the current input record for GROUP patterns.
NR Total number of records read so far across all input files. See also FNR.
OFMT Conversion format for outputting floating point numbers. Default value of "%.6g". Whenever a floating point number, either a constant or a variable value, is specified for output with the print function, the value is formatted for output using the string value of OFMT.
OFS Output field separator. Default value of a single blank, '\s'. Whenever more than one argument is listed for output with the print function, each argument is output separated by the string value of OFS.
ORS Output record separator. Default value of a single newline character, '\n'. The string value of ORS is concatenated to the output of the print function.
POSIX
This array contains the strings used in the replacement of the regular expression character classes: [:alpha:], [:alnum:], ... , [:xdigit:]. Since these strings are dependent on the execution locale, this change makes these strings readily available.The array elements are:
POSIX["alnum"]
all alphebetic and numeric characters
POSIX["alpha"]
all alphebetic characters
POSIX["blank"]
the blank and tab characters
POSIX["cntrl"]
all control characters
POSIX["digit"]
all numeric digits
POSIX["graph"]
all visible and printable characters. A tab character is "printable", but not visible. 'a' is both printable and visible
POSIX["lower"]
all lower-case alphabetic characters
POSIX["print"]
all printable characters
POSIX["punct"]
all punctuation characters
POSIX["space"]
all white space characters
POSIX["upper"]
all upper-case alphabetic characters
POSIX["xdigit"]
all hexadecimal numeric digits
PROCINFO
This builtin variable is an array containing information on the QTAwk process running. Ths array has the following array elements and indices indicated:
FS
element has one of two values. "FS" if field splitting is based on the FS variable and "FIELDWIDTHS" if field splitting is based on the field widths specified in the FIELDWIDTHS variable.
RS
element has one of two values. "RS" if record splitting is based on the RS variable and "RECLEN" if field splitting is based on the fixed record length specified in the RECLEN variable.
cmdline
command line string invoking QTAwk.
egid
The numeric value of the effective group ID for the QTAwk process
euid
The numeric value of the effective user ID for the QTAwk process
gid
The numeric value of the group ID for the user running the QTAwk process
module
The number of modules loaded with the QTAwk 'load_module' builtin function.
pgrpid
The numeric value of the process group ID for the QTAwk process
pid
The numeric value of the process ID for the QTAwk process
ppid
The numeric value of the process ID for the parent process of the QTAwk process
uid
The numeric value of the user ID for the user running the QTAwk process

RECLEN If assigned a non-zero numeric value, then the current input file is assumed to consist of fixed length records with the record length equal to the integral value of RECLEN. When RECLEN determines input records, RT is assigned the null string whenever a record is read from the current input file.

Note: Under OS/2, whenever RECLEN is assigned a non-zero value, the current input file is read as a "binary" file. Normally, the current input file is opened in "text" mode under OS/2, i.e., Carriage Return/Line Feed pairs are translated to single Line Feed characters. However, when fixed length records are being read, then the translation is no longer performed. The translation may also be turned off with the command line option, "-Wi". Refer to Command Line Options

RLENGTH Assigned the length of the string matched in the match function.
RSTART Assigned the start index of the string matched in the match function.
RETAIN_FS TRUE/FALSE. Default value = 0. The value of this variable is used only if input record fields are determined by FS and not by the FIELDWIDTHS variable. If assigned a false value, and FS is used for field splitting, then OFS is used between fields to reconstruct $0 whenever a field value is altered. If assigned a true value, and FS is used for field splitting, the original field separator characters are retained in reconstructing $0 whenever a field value is altered.
RS Input record separator. The default value for RS is a single newline character, '\n'. If RS is set on the command line or in the user utility then the following rules apply (see also FS):
  1. setting to the null string, "", will set RS to the regular expression /\n\n+/. Thus, blank lines, i.e., two or more consecutive newline characters, bound input records.
  2. setting to a value other than a regular expression constant, the regular expression value will be derived. The regular expression internal form will be derived when the assignment is made. The input file character stream is scanned for a string matching the regular expression and matching strings become record separators. The length of matching strings is governed by the LONGEST_EXP built-in variable.

The string matching RS is assigned to RT.

RT Assigned the string value of the record terminator whenever a new record is read from the current input file. If fixed length records are used by setting RECLEN, then RT is assigned the null string.
SPAN_RECORDS TRUE/FALSE value. Default value = 0. Value determines whether or not matches to FILE_SEARCH_PAT or the search pattern in srchrecord or fsrchrecord are allowed to span records. If assigned a false value, matches must be contained in a single record. See Pattern/Actions. for a more complete explanation of searching the input file for the next record.
SUBSEP A default value of a comma character, ','. The value of SUBSEP is used to separate the index values in MATCH_INDEX when a multidimensional array is used for matching.
TRACE Control statement tracing. Default value == 0. Determines whether statements are traced during execution. Refer to section Trace Statements for more detailed information on tracing the execution of QTAwk utilities.
TRANS_FROM String used by stran function for translating characters. Default value is the value of the POSIX variable array member POSIX["upper"].
TRANS_TO String used by stran function for translating characters. Default value is  the value of the POSIX variable array member POSIX["lower"].
TRUE Predefined with one, 1, constant value.
USER_FUNCTIONS
This is a singly dimensioned array. The index value of each element is equal to the name of a user defined function and the value of the array element is equal to the file in which the user defined function was defined. This applies for user defined functions which are defined in dynamically loaded modules also.

For example, if two user defined functions have been defined, one in the file "source_file_1.awk" and the second in the file "library_functions.awk", we would have the following array:
  1. USER_FUNCTIONS["some_function"] == "source_file_1.awk"
  2. USER_FUNCTIONS["library_function_1"] == "library_functions.awk"

As user defined functions are loaded and unloaded via dynamically loaded modules, the appropriate array elements are added and deleted.

The element index by zero,0, equals the count of currently defined user defined functions.
QTAwk_Path The means for defining this variable has changed starting with version 1.60. Environment variables are no longer used. This variable now set in the configuration file, '.qtawkrc'.  The variable specifies paths to be searched for input files. Multiple paths may be specified, separated by semi-colons. The paths specified are searched for input files in the order specified. If a drive and/or path is specified with an input filename, then that drive and path only are searched for the desired file. If no drive or path is specified with an input filename, then the current directory is searched and then the paths specified in QTAwk_Path. The search sequence for files follows the the order:
  1. If a directory and/or path name name is specified for an input file, then that path only is searched.
  2. If no directory or path name is specified, then the current directory is searched. If the file is not found, then all paths specified in QTAwk_Path are searched for the file in the order specified. Multiple paths may be specified, separated by a semi-colon. This follows the same convention for specifying multiple paths in the system environment path setting, "PATH".

The value of QTAwk_Path may be reset at any time by the user's utility to change the paths to be searched for input files. Setting the value of QTAwk_Path to a false value, e.g., the null string (""), will null the directory search, only the current directory will be searched.

vargc Assigned by QTAwk the integer value of the count of variable arguments passed to the current invocation of a user defined function defined with a variable number of arguments. Refer to the section Variable Length Argument Lists for a complete discussion of user defined functions with a variable number of arguments.
vargv A singly-dimensioned array of assigned the arguments passed to the current invocation of a user defined function with a variable number of arguments. Indexing numeric starts at one, 1. Refer to the section Variable Length Argument Lists for a complete discussion of user defined functions with a variable number of arguments.

TOP
User Guide
Chapters
Table of Contents
Variables
Expressions