Get string length

Syntax

int len(s)

 

Parameters

s - string.

 

Remarks

Returns number of characters in string. To calculate it, searches for terminating null character. Returns 0 if s is null. Returns 0 if s is VARIANT of type other than VT_BSTR.

 

For str and lpstr, this function always returns number of bytes. In Unicode mode, some characters consist of 2-4 bytes. For other types, always returns number of 2-byte characters.

 

Tips

For str and BSTR variables, use len property instead of this function. Example: length = s.len.

 

See also: empty.

 

Examples

lpstr s = "String"
int i = len(s)
 now i is 6

str s = "one two"; s[3]=0
out s.len
out len(s)
 Output:
 7
 3