Trimming items – T / TL / TR

A result-string is trimmed by removing leading or trailing pad characters (or both).  Recall from the discussion above that the result string is built up, a piece at a time, in a left-to-right manner.  When a trimming item is encountered in the mapping string, it is applied to the result string as it exists at that point in time.  Thus, to trim the ‘final’ result a certain way, you would place the trimming item last (right-most) in the mapping string.

Because the action of a trimming item is applied to the result string and not to the source string, the mapping string can contain additional column-reference operands to the right of a trimming item, since the data characters in the source string remain undisturbed in their original locations.

A trimming item consists of the codes T, TL or TR followed by a optional trimming specification.

When trimming causes the result string to be truncated, the default pad character that is searched for is a blank.  You can optionally specify a different padding character as a literal value. Be mindful that for the Trim commands, “padding” defines, not the padding to be added, but the existing padding that is going to be removed.

If trimming results in all characters being removed, the result is an empty (zero-length) string.  Thus, if you request all blanks to be removed, and the value contains only blanks, the result will be a zero-length string.  If that is not the result you want, you could ‘correct’ that by following the trim request with an alignment item that specifies the desired field length, such as a Pad command, or you could use a text-insertion command to add back some value if desired.

No spaces or characters not part of the syntax can appear within a single trimming item, unless appearing inside of quotes as a literal pad-character value.

Syntax of an alignment item:

{ T| TL | TR }  [ pad-character ]  [ maximum-trim ]

T| TL | TR:

Refers to the type of trimming that takes place:


Defines the character to be searched for and removed.  May be any single character in quotes.  If omitted, a pad-character of blank is used.  See Alignment Item above for more information on the syntax of this part.


A decimal number that defines the maximum number of padding characters that can be removed from either side of the result string; if used with the T command code, the same maximum is applied individually to both sides.  If omitted, all possible padding characters that are present are removed.  It is illegal to specify a maximum trim length of 0, since that would request the trimming operation to do nothing.

Created with the Personal Edition of HelpNDoc: Full-featured multi-format Help generator