[Table of Contents]

Field Definitions and Field Definition Files

Using Field Definitions

ALL works with program as well as user defined fields. For a list of the program defined fields, which are available by default, see the corresponding table of field names further down.

In addition to the program defined fields you can define fields yourself by including field definitions in a definition file. This allows you to use any string of data or text found in an input file and to include it in the output command or file by inserting its name.

Fields can be looked at as pieces of text or other data in the input that are defined via their starting position in the record and their length.

Fields are made known to ALL with the help of field definitions. Field definitions inform ALL where a field begins and how long it is so that the program can extract the right amount of data.

Field definitions allow you to access portions of input records by specifying the corresponding field name in the template.

A field definition in the definition file syntactically looks like this:

fieldname [start-position] length

The specification of a start position is optional as indicated by the square brackets. It lets you skip data in the input record that you are not interested in as shown in the example below. If not specified the first start position is position 1 (i.e. the first character in a line) and all subsequent start positions are calculated by means of the length fields.

Field definitions with or without specification of a start position can be mixed as in the following example that describes a record such as might be found in the ASCII output of an address database:

    LAST_NAME      20     ! starts at position 1 and is 20 characters long
FIRST_NAME 20 ! starts at position 21 and is 20 characters long
! --- There is a field representing a title that is skipped
STREET 42 30 ! The next field street starts at position 42

Field definitions are read from a file that is specified using the /D option.

Field name types

There are two types of fields:

Program defined fields

Program defined fields are available whenever ALL is started.

Note

All the field names used to identify file specification portions are not identical for OpenVMS and DOS. First, there are more fields for OpenVMS, and also the field names are slightly longer and more descriptive than their DOS counterparts.

The field names for DOS were kept as short as possible so as not to exceed the small DOS command buffer too easily.

The following table lists all program defined fields.

Program Defined Fields
MS-DOS* OpenVMS Field Description
fsfspecFull file specification
-fnodeNode name
-fdevDevice name
-frootRoot name
fdr-Drive name
-fdevDevice name
fdifdirDirectory name
fnfnameFile name
feftypeFile extension/type
-fverFile version
rrThe whole input record
p0p0All tokens delimited by whitespace or any other delimiter concatenated
p1p1First token delimited by whitespace or any other delimiter
......
p8/p100p100Last token delimited by whitespace or any other delimiter
yyyyyyyyAll four digits of the current year (e.g. 1999 for 1999)
yyyyThe last two digits of the current year (e.g. 98 for 1998)
mmmmThe current month (e.g. 01 for January or 12 for December)
ddddThe current day (from 01 to 31)
hhhhThe current hour (from 00 to 23)
mnmnThe current minute (from 00 to 59)
ssssThe current second (from 00 to 59)
nnOrdinal number of the current record
* MS-DOS here refers to DOS under Windows 9x and NT as well. Some resources are larger under Windows NT than under plain DOS as for example the number of parameters which is 8 under DOS and 100 under NT.

To find out the names of program defined fields when no documentation is available call ALL with the /H option (note: the H must be entered in uppercase). ALL then displays usage information with a list of program defined fields included.

User defined fields

User defined fields are made known to ALL via a field definition file that is specified on the command line using the /D option.

Syntax and function of field name qualifiers

There are a number of ways to influence the appearance and length of field values specified in the template string.

The following example is used to explain the syntax and function of the various qualifiers available. These qualifiers allow you to use substrings of field values, to pad them with blanks up to a specific length, or to change their case.

    all /Flist.dat "echo !p1[1,4](10)!"
            |             |  | |  |
            |             |  | |  +-- pad limit
            |             |  | |
            |             |  | +-- length of field substring
            |             |  |
            |             |  +-- offset of field substring
            |             |
            |             +-- field name
            |
            +-- input file name

The various portions of the above field specification have the following meaning:

P1

P1 is the field name. User defined field names may be composed of up to 15 arbitrary characters. Generally, however, it should be advisable to choose meaningful names.

Field names must be enclosed in exclamation marks (!). If you want an exclamation mark to appear in the output precede it with an escape character (a tilde '~' by default). This is also required to print the escape character itself.

[1,4]

This is a range or substring specification. It tells ALL to fill in the field value in its entirety but only 4 characters of it starting with the first.

(10)

This is a padding specification. It tells ALL to fill the output string with blanks up to the 10th character. Padding is used to produce output in tabular form that is easier to interpret and manipulate by other programs.

The following sections explain field ranges and padding in more detail.

Field ranges

Field names may optionally be followed by a range specification which must also be placed within the pair of exclamation marks enclosing the field specification.

"Field 1: !P1[1,15]!"

In this example, only the first 15 characters of field P1 are used in the output.

If you do not know how long a field exactly is specify a sufficiently large number for the length. ALL will extract all characters up to the end of the field in this case. If the number you specify is larger than the length of the actual data ALL just extracts what is there and does not complain.

Field padding

Field names may optionally be followed by a padding specification which must also be placed within the pair of exclamation marks enclosing the field specification. A padding specification must follow the field name. It may be placed before or after a range specification. A substring (range) is always extracted before it is padded.

Padding can be used to achieve a columnar formatting of the output. The field for which padding is specified is padded with blanks up to the length specified. In the example below this is a length of 20.

"Field 1: !P1(20)!"

or in combination with a range specification:

"Field 1: !P1[1,15](20)!"

The following example shows a very simple template in the context of an ALL command line:

all /Finput.dat "Field 1: !P1!" /t

In this example, a program defined field name is used which is called P1. P1 - Pn are those tokens in the input record that are delimited by the start of line, whitespace (blanks or tabs) or any delimiters denoted by the /d option, or the end of line.

All field names must be delimited by exclamation marks (!) as shown in the example. Field names are treated case insensitive, i.e. a field name may be entered in uppercase, lowercase or mixed case.

Field names may be preceded by a number of metacharacters. These characters instruct ALL to change the field value retrieved in a special way as described in the following table:

Field meta characters and their functions
Character Function
-Instructs ALL to trim the retrieved field value i.e. to remove all leading or trailing tabs and spaces
:Instructs ALL to uppercase the retrieved field value
;Instructs ALL to lowercase the retrieved field value
^Instructs ALL to capitalize the retrieved field value
llowercase "L"; removes leading zeros from the current record number and only applies to the N field
breplaces leading zeros in the N field with blanks and only applies to the N field

Note

If both a "_" and one of the other characters are used together the "_" must precede the other character.

[Table of Contents]