Once loaded, the text input file can be treated identically to a normal
database file. Each field in the input record is given a numeric name so as
they can be distinguished. These names have the form Unnn
where nnn
is a three digit number. For example, to reference the first three fields in
the input you would do as in the example below.
%%EQUATE test "ABC"%U001=?%U002:%U003; %%RECORD %U001 %U002 %U003
The example shows fields being referenced in an equate and a text body in the
same way as fields are normally referenced. Records can also be sorted on the
fields or filtered as normal. The system variables _eq_totrec
and _eq_currec
also get set for a text input file as
normal. Also direct field indexing works as normal so that the contents of
any partiulcar record (input line) can be accessed.
Real column names can be setup by using the NAMCOL environment variable
by simply defining it. Then instead of the form Unnn
the values of the
fields in the first record in the input file will be taken as the column names
and that record will be ignored. These will always be used in uppercase and
truncated to ten characters. Do not use non-supported field characters.
The example below sets NAMCOL and prints fields from dogs.txt
also
shown below.
Contents of dogs.txt: Name Type Id Bounce Scottie 119 Jack Terrier 102
%%DATABASE "dogs.txt" %%DEFINE NAMCOL %%RECORD %NAME %TYPE %ID
Note that the NAMCOL directive is globally applied to all databases in the GRG file and cannot be set individually for each input file.
To establish which field is which when not using NAMCOL and what the column names are a simple GRG file can be created that uses the default header and record text bodies.
Go to the first, previous, next, last section, table of contents.