pad()

Examples


The pad() function adds a specified string to the beginning, end or both the beginning and end of another specified string. It also allows you to set the length of its returned value.

Syntax

pad(string, direction, addstring, length)

Parameters

string – A string field or string value to which the string specified in the addstring parameter will be added.

direction – A Dexterity constant that defines where the specified addstring should be added to the specified string. The possible values for the parameter are:

[spacer]

Constant

Description

LEADING

Add addstring to the start of string.

TRAILING

Add addstring to the end of string.

LEADING+TRAILING

Add addstring to the beginning and end of string.


addstring – A string field or string value to be added to the specified string parameter.

length – An integer specifying the length of the string this function returns.

Return value

String

Comments

The length parameter specifies the exact size of the returned string. If the resulting concatenation of string and addstring is shorter than the specified length, the addstring parameter will be added repeatedly until the length is reached. The last addition of addstring will be truncated at the point where the specified length is reached.

If the resulting concatenation of string and addstring is longer than the specified length, addstring will be truncated to the necessary length.

If addstring is added to both the beginning and end of the existing string, and an odd number of characters is needed to attain the specified length, then the extra character will be added to the end of the string.


Documentation Feedback