Developer Documentation Library > UNICOM Intelligence Function Library > Text, categorical, and array functions > Left
 
Left
Returns a string containing the first characters from a string, a category list containing the first categories from a category list, or an array containing the first elements from an array.
Syntax
Left(<value>, <length>)
Parameter
<value>
Type: None
Text value, categorical value, or array to operate on.
<length>
Type: Long
Number of characters, categories, or elements to return. If Length is greater than the number of items available, all of the items are returned.
(return)
Type: None
The required characters, categories, or elements from <value>.
Notes
For type Text, the return value is of type Text, and contains Length characters from the start of <value>. For type Categorical, the return value is of type Categorical, and contains Length categories from the start of <value>. For an array (which can contain values of any type), the return value is an array, and contains Length elements from the start of <value>. For any other type, an error occurs.
When <value> is NULL, the return value is NULL.
Examples
Function call
Val
Length
Result
Notes
Left(Val, Length)
24 St John's Road, Barnes
10
24 St John
The return value is the first 10 characters in the supplied string.
Left(Val, Length)
{4,2,9}
1
{4}
The return value is the first category in the supplied category list.
Left(Val, Length)
Split("The quick brown fox")
2
{The,quick}
The return value is the first two elements in the supplied array. For more information, see Split.
The following example returns the first six characters of the name text variable:
name.Left(6)
The following example returns the first three categories stored in the remember multiple response variable:
remember.Left(3)
For a mrScriptBasic example that shows using Left in combination with another function, see Call statements. For a data cleaning example, see Example 4: Cleaning other question types.
See also
Find
Text, categorical, and array functions