PADR Function


Formatted_String as C = PADR(C,N length,C pad_string)



A character string.


A positive integer representing the length of the Formatted_String. If Length is less than len(Unformatted_String), then Unformatted_String will be truncated to Length. Numeric


The character string to append to the end of Unformatted_String to position it within Formatted_String.


Pads the right side of a string with another string.


PADR() pads a C string on the right with a Pad_String, and returns a resulting string of the specified Length. If the length of Pad_String + C_string is less than the Length, the Pad_String is repeated to fill the remainder of the string.


PADR can easily create a series of trailing characters like you find in a Table of Contents. Assume that your report summarizes the totals of multiple invoices for each customer. The following expression defines a calculated field that you can place in the Detail section to create a easily readable printout:

padr(ltrim("Polucci"), 20, ".") + ltrim(str(200) ) -> Polucci.............200

The difference between using this method and including trailing characters as a Text object directly on a layout is that this method eliminates the gap that would appear between the end of a shorter value and the start of the Text object. The following expression extracts the decimal places from a dollar value and pads the string with the cents symbol.

padr(ltrim(str( (RETAIL - floor(RETAIL) ) * 100) + " "), 8, ".") -> "15 ....." for values such as 10.15 and 0.15.

Note : ANSI character 162 is the cents symbol; press ALT + 0162 on a numeric keypad to enter this character. Assume that the above expression defines the calculated field CENTS. The following expression creates a string to format dollar values:

case(RETAIL CENTS, RETAIL > = 1, ltrim(str(floor(RETAIL) ) ) + " dollars and " + CALC->CENTS) ? "10 dollars and 15 .....", if RETAIL contains 10.15 and "15 ....." if RETAIL contains 0.15.

See Also