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. |
Character |
Any character that will be used to extend the string. 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. Allowed values: |
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. |
Script Elements - Activation Data
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Ordered by Functions