aqString.GetListLength Method

Applies to TestComplete 15.64, last modified on June 12, 2024


The aqString.GetListLength method returns the number of items in the List string that are delimited by the aqString.ListSeparator character or string (default is |). Use this method when you need to enumerate items in the List. To get an individual item, use the aqString.GetListItem method.



List [in]    Required    String    
Result Integer

Applies To

The method is applied to the following object:


The method has the following parameter:


A string containing items delimited by the character or string specified by the aqString.ListSeparator property.

Result Value

The number of items in the List that are delimited by the aqString.ListSeparator character or string. If List does not contain any instance of aqString.ListSeparator, the method returns 1. If List is an empty string, the method also returns 1 (see Remarks).


If the List contains two adjacent delimiters or if the delimiter occurs at the beginning or end of the List, the corresponding list item is considered empty. Empty items are also counted.

An empty string is considered as consisting of one empty item.


The following table lists some sample input strings for the aqString.GetListLength method, the corresponding item separators and the resulting item count:

List aqString.ListSeparator Item Count
"Hello, world!" "," 2
"Hello, world!" "." 1
"Hello, world!" "o" 3
"4;;8;;16" ";" 5
";4;8;16;" ";" 5
"-" "-" 2
"" (empty string) any 1 (see Remarks)

The script below demonstrates how you can use the aqString.GetListLength method to count the number of items in a string list:

JavaScript, JScript

function GetListLengthSample()
  var str = "This is a test.";
  aqString.ListSeparator = " ";



def GetListLengthSample():
  str = "This is a test."
  aqString.ListSeparator = " "


Sub GetListLengthSample
  Dim str

  str = "This is a test."
  aqString.ListSeparator = " "

  Log.Message aqString.GetListLength(str)
End Sub


procedure GetListLengthSample;
var str;
  str := 'This is a test.';
  aqString.ListSeparator := ' ';


C++Script, C#Script

function GetListLengthSample()
  var str = "This is a test.";
  aqString["ListSeparator"] = " ";


See Also

Working With Strings
AddListItem Method
ChangeListItem Method
DeleteListItem Method
GetListItem Method
ListSeparator Property

Highlight search results