STR_PAD

Script Function: Extends a string to a certain length.

Syntax

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

Syntax

Description/Format

String

The string that should be extended.
Format: script literal or script variable

Character

Any character that will be used to extend the string.
Format: AE name, script literal or script variable

Default value: " "

Total length The length to which the string should be extended.
Format: a number without inverted commas, script literal or script variable
Alignment

The string's position.
Format: script literal or script variable

Allowed values:
"LEFT" - The string is positioned on the left.
"RIGHT" - The string is positioned on the right.
"CENTER" - The string is positioned in the center.


Return codes

The extended string.

Comments

This script function extends a string to a certain length. You specify the character that should be used for the extension in the parameter Character. By default, blanks are used.

You can also define the order in which the string should be shown in the result (parameter Alignment). The possible values are LEFT, RIGHT and CENTER.
CENTER means that the required characters are equally positioned to the left and to the right of the string. If the number of characters that are required to extend the string is not even, the position to the right of the string includes one character more than the position to the string's left.

Examples

The following example increases one and the same string in three different ways and writes the result to the activation protocol.

: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 following result is written to the activation protocol:

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

See also:

Script element Description
STR_SPLIT Splits a string to several parts using a separator.