T Code - Text Extraction
The T code extracts a character substring from an attribute value.
Input Conversion
Input conversion does not invert. It simply applies the text extraction to the input data.
Syntax
T{start,}count
Syntax Elements
start Is the starting column number. When start is specified, the code counts and extracts characters from left to right only: the contents of attribute 9 of the data definition item has no effect.
count Is the number of characters to be extracted.
If start is specified, the code extracts count characters, left to right, starting at character start.
If start is not specified, the code extracts count characters either from the left or the right end of the element, depending on the contents of attribute 9 of the data definition item. If attribute 9 contains R (right-align), the code extracts the last count characters from the element. If attribute 9 does not contain R, the code extracts the first n characters from the element.
Comments
The T code is particularly useful for retrieving information from a file with fixed length attribute values. To save space, many applications concatenate various elements, such as address fields, into one string. The T code can then be used to extract elements such as city, ZIP code, and so on.
Examples
Code |
Alignment |
Stored Value |
Result |
---|---|---|---|
T3,2 |
Left |
ABCDEFG |
CD |
T3,2 |
Right |
ABCDEFG |
CD |
T5 |
Right |
CA90071 |
90071 |
T2 |
Left |
CA90071 |
CA |
T3,5 |
Left |
CA90071 |
90071 |