Difference between revisions of "STR PAD()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 1: Line 1:
{{YLM to do}}
 
 
==Class==
 
==Class==
 
String Data
 
String Data
Line 9: Line 8:
  
 
==Syntax==
 
==Syntax==
RPAD(<expC1>,<expN>,[<expC2>])  
+
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()]], [[STR()]], [[STRTRAN()]], [[STRZERO()]], [[STUFF()]]
  
  
 
==Description==
 
==Description==
The RPAD() 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. The RPAD() 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, it is truncated.  The RPAD() function is synonymous with the PADR() function.
+
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">
? rpad("abc",6,"d")
+
? str_pad("abc",6,"d")
 
abcddd
 
abcddd
 
</code>
 
</code>

Revision as of 15:58, 13 October 2009

Class

String Data


Purpose

Function to pad out a character string to a defined length from the right


Syntax

STR_PAD(<expC1>,<expN>,[<expC2> [,<pad_type>]])


See Also

CENTER(), LPAD(), PADC(), PADL(), PADR(), RPAD(), 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