Previous Topic: LOOP Function--Call a Virtual Attribute in a Loop

Next Topic: LTRIM Function--Remove Leading Spaces in a String

LPAD Function--Pad a Source String on the Left

The LPAD function pads a source string on the left with the first character of the specified padding until the resulting string is the specified length.

Syntax

The LPAD function has the following format:

LPAD(source_string, length[, padding])

Parameters

The LPAD function accepts the following parameters:

source_string (string)

This parameter can also be a number; it is automatically converted to a string.

length (number)

The number of characters of the final string.

padding (string)

(Optional) If the padding is more than one character long, only the first character is used. If the padding is zero length, no padding is done. If the source is a string and padding omitted, a space is used for padding. If the source is a number and padding is omitted, a zero is used for padding.

Return Value

The LPAD function returns a string.

Examples

Result_value=LPAD('Juan', 5)
Result_value=' Juan'

Result_value=LPAD('Juan', 5, 'X')
Result_value= 'XJuan'

Result_value=LPAD('Juan', 6, 'XY')
Result_value= 'XXJuan'

Result_value=LPAD(5, 2)
Result_value= '05'

Result_value=LPAD(5, 2, ' ')
Result_value=' 5'

More information:

CENTER Function--Pad a Source String

RPAD Function--Pad a String on the Right


Copyright © 2010 CA. All rights reserved. Email CA about this topic