LEFT()

LEFT()

Top  Previous  Next

 

The LEFT() function returns the leading part of a string.

 

 

Format

 

LEFT(string, len)

 

where

 

stringis the string from which the leading substring is to be extracted.

 

lenis the length of the substring to be extracted. A value less than 1 is replaced by 1.

 

 

The LEFT() function returns the leftmost length characters from the given string. If length is greater than the number of characters in the string, the entire string is returned.

 

This function is identical in effect to use of the substring assignment operator. Thus the following two statements are equivalent:

SUBSTR = LEFT(VAR, length)

SUBSTR = VAR[1, length]

 

 

Example

 

A = "ABCDEFGHIJK"

S = LEFT(A, 3)

 

This program fragment assigns the string "ABC" to variable S.

 

 

See also:

RIGHT()