Difference between revisions of "STR PAD()"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
− | Function to pad out a character string to a defined length | + | Function to pad out a character string to a defined length |
==Syntax== | ==Syntax== | ||
− | + | STR_PAD(<expC1>,<expN>,[<expC2> [,<pad_type>]]) | |
==See Also== | ==See Also== | ||
− | [[CENTER()]], [[LPAD()]], [[PADC()]], [[PADR()]], [[RPAD()]], [[STR()]], [[STRTRAN()]], [[STRZERO()]], [[STUFF()]] | + | [[CENTER()]], [[LPAD()]], [[PADC()]], [[PADL()]], [[PADR()]], [[RPAD()]], [[SET STRESCAPE]], [[STR()]], [[STRTRAN()]], [[STRZERO()]], [[STUFF()]] |
==Description== | ==Description== | ||
− | The | + | The STR_PAD() function left-justifies a character string <expC1> and pads out the right of the string, to a total length of <expN> characters, with blank spaces. The optional <expC2> may be used to pad <expC1> with a character string instead of blank spaces. If the optional <pad_type> is included, the string is processed as follows: |
+ | |||
+ | |||
+ | {| class="wikitable" | ||
+ | !<pad_type>||Description | ||
+ | |- | ||
+ | |STR_PAD_RIGHT||Default behavior as above | ||
+ | |- | ||
+ | |STR_PAD_LEFT||<expC1> is right justified and padded to the left to a total of <expN> characters | ||
+ | |- | ||
+ | |STR_PAD_BOTH||<expC1> is centered and padded to the left and right to a total of <expN> characters | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | |||
+ | The STR_PAD() function is useful for creating fixed length character strings by padding them out with blanks. If the string being processed is longer than the specified total length, no padding takes place. | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | ? | + | ? str_pad("abc",6,"d") |
abcddd | abcddd | ||
</code> | </code> |
Latest revision as of 15:15, 22 July 2010
Purpose
Function to pad out a character string to a defined length
Syntax
STR_PAD(<expC1>,<expN>,[<expC2> [,<pad_type>]])
See Also
CENTER(), LPAD(), PADC(), PADL(), PADR(), RPAD(), SET STRESCAPE, STR(), STRTRAN(), STRZERO(), STUFF()
Description
The STR_PAD() function left-justifies a character string <expC1> and pads out the right of the string, to a total length of <expN> characters, with blank spaces. The optional <expC2> may be used to pad <expC1> with a character string instead of blank spaces. If the optional <pad_type> is included, the string is processed as follows:
<pad_type> | Description |
---|---|
STR_PAD_RIGHT | Default behavior as above |
STR_PAD_LEFT | <expC1> is right justified and padded to the left to a total of <expN> characters |
STR_PAD_BOTH | <expC1> is centered and padded to the left and right to a total of <expN> characters |
The STR_PAD() function is useful for creating fixed length character strings by padding them out with blanks. If the string being processed is longer than the specified total length, no padding takes place.
Example
? str_pad("abc",6,"d") abcddd
Products
Recital Server, Recital