STR_PAD

Use the STR_PAD script function to extend a string to a specified length by adding padding characters on the left, on the right, or on both sides.

Syntax

STR_PAD (String, [Character], Total length, Alignment)

Parameters

Parameter Description Format Allowed Values Default Value
String The string to extend Script literal or script variable n.a. n.a.
Character

(Optional)

The character used to pad the string AE name, script literal, or script variable n.a. " " (blank)
Total length The target length of the extended string Number without quotation marks, script literal, or script variable n.a. n.a.
Alignment Defines where the original string is positioned within the padded result n.a.
  • LEFT — The string is positioned on the left; padding characters are added on the right
  • RIGHT — The string is positioned on the right; padding characters are added on the left
  • CENTER — The string is centered; padding characters are distributed equally on both sides. If the number of characters to add is odd, the right side receives one extra character.
n.a.

Return Codes

Return Value Condition
String The extended string padded to the specified length

Examples

The following example extends a 20-character string to a total length of 31 characters using three different alignments and prints each result to the activation report.

:SET &STRING# = "String for Scripting"

:SET &STRLEN# = 31

:SET &STRNEW# = STR_PAD(&STRING#, ".", &STRLEN#, "LEFT")

:PRINT &STRNEW#

:SET &STRNEW# = STR_PAD(&STRING#, "+", &STRLEN#, "CENTER")

:PRINT &STRNEW#

:SET &STRNEW# = STR_PAD(&STRING#, "_", &STRLEN#, "RIGHT")

:PRINT &STRNEW#

The activation report output looks like this:

String for Scripting...........
+++++String for Scripting++++++
___________String for Scripting

See also: