Padding items – P / PL / PR


A result-string is padded by adding 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 padding item is encountered in the mapping string, it is applied to the result string as it exists at that point in time.  Thus, to pad the ‘final’ result string in a certain way, you would place the padding item last (right-most) in the mapping string.


Because the action of a padding 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 padding item, since the data characters in the source string remain undisturbed in their original locations.


A padding item consists of the codes P, PL or PR followed by a optional padding specification.


By default, the pad character used for padding is a blank.  You can optionally specify a different padding character as a literal value.


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


Syntax of an alignment item:


{ P| PL | PR }  [ pad-character ]  [ pad-amount ]


P| PL | PR:


Refers to the type of padding that takes place:



Pad-character:


Defines the pad character to be used.  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.


Pad-amount:


A decimal number that defines the number of padding characters that are to be added to either side of the result string; if used with the P code, the same number of pad characters are added to both sides.  If omitted, the pad-amount length is treated as 1.  It is illegal to specify a pad-amount length of 0, since that would request the Pad command to do nothing.




Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator