Scripting > UNICOM Intelligence Function Library > Text, categorical, and array functions > Len
 
Len
Returns a Long containing the number of characters in a string, the number of categories in a category list, or the number of elements in an array.
Syntax
Len(Val)
Parameters
Val
Type: Type: None
Text value, categorical value, or array to operate on.
(return)
Type: Type: Long
Numbers of characters, categories, or elements in Val.
Remarks
For type Text, the return value is the number of characters in Val. For type Categorical, the return value is the number of categories in Val. For an array (which can contain values of any type), the return value is the number of elements in Val. For any other type, an error occurs.
When Val is NULL, the return value is zero.
Examples
Function call
Val
Result
Notes
Len(Val)
24 St John's Road, Barnes
25
The return value is the number of characters in the supplied string.
Len(Val)
{4,2,9}
3
The return value is the number of categories in the supplied category list.
Len(Val)
Split("The quick brown fox")
4
The return value is the number of elements in the supplied array of text strings. See Split for more information.
The following example returns the number of characters stored in the address text variable:
address.Len()
The following example returns the number of categories selected by the respondent in response to the remember multiple response question:
remember.Len()
For a mrScriptBasic example that uses Len, see CreateObject. For ideas for using Len in SQL queries, see I want to use the Data Model to access data, but I am used to SPSS-style data. Can you give me an overview?.
See also
Find
Text, categorical, and array functions