LEFT Function

Returns the specified number of characters from the beginning of a string.

This function is provided for compatibility with other MultiValue systems.

Syntax

LEFT(string, charCount)

Syntax Elements

string A DataBasic expression that evaluates to a string.

charCount A DataBasic expression that evaluates to the number of characters to extract. Only the integer part is used.

If negative, one less than the specified number of characters are removed from the end of the string and LEFT returns what remains.

Return Value

A string containing the specified number of characters from the beginning of the string.

Operation

The LEFT function is equivalent to the following substring extraction operation:

string[1, charCount]

See Also

RIGHT function, Substring Extraction.

Examples

S = "123456789"
C = 7
R = LEFT(S, C)

Sets R to "1234567".

S = "123456789"
C = -7
R = LEFT(S, C)

Sets R to "123".

S = "123456789"
C = 12
R = LEFT(S, C)

Sets R to "123456789" (C is greater than the length of the string, so the complete string is returned).