The G code extracts groups of characters that are separated by delimiters. Since words are separated by spaces, the G code extracts words from a sentence.
Format
G [skip] delimiter #fields |
Parameter(s)
skip |
Number of fields to skip. |
delimiter |
Character used to separate fields. Any single nonnumeric character except a system delimiter (segment mark, attribute mark, value mark, subvalue mark, or start buffer mark). |
#fields |
Number of contiguous fields to extract. |
Description
When an Attribute Definition item is created with a G code that is to extract data from an attribute that already exists, the attribute number (line 2) of the new Attribute Definition item should be the same as that of the existing attribute.
Continuing the example in the preceding section, using a G code instead of a T code derives the short title from the BOOK-CATALOG file. This G code extracts the first word from the attribute TITLE:
G 1 |
The space between G and 1 specifies the space character as the delimiter. 1 specifies that only the first field is to be extracted. G 1 produces the data:
DATABASE OPERATING WORD WRITING |
Another example: Attribute 2 in a personnel database contains a department ID and a job ID delimited by a slash (/). The data is stored in the format:
30/110 |
The G correlative in this Attribute Definition item extracts only the department ID:
DEPT.ID 001 S 002 2 003 Dept ID 004 005 006 007 008 G/1 009 L 010 3 |
G/1 extracts only one field, the first one; the delimiter is defined as a slash (/). Since the number of fields to skip before extraction is not specified before the delimiter, a default of zero is assumed. G1/1 would specify that the first field should be skipped and only one field, the second one, should be extracted.
In an attribute with several fields separated by asterisks, G1*3 would specify that the first field should be skipped and the next three fields (2, 3, and 4) should be extracted.
See Also