aqString.ListSeparator Property

Applies to TestComplete 14.72, last modified on April 22, 2021

Description

The aqString.ListSeparator specifies a single character or a string that is used to delimit items in a string list. This delimiter is used by string list enumeration methods, such as aqString.GetListItem and aqString.GetListLength.

Declaration

aqString.ListSeparator

Read-Write Property String

Applies To

The property is applied to the following object:

Property Value

A string used as the item separator. The default value is the pipe character ( | ).

Remarks

The separators are case-sensitive: for example, "a" and "A" are different separators. Keep this in mind when using alphabetic characters in the separator.

aqString.ListSeparator cannot be an empty string.

Changes made to the aqString.ListSeparator property are preserved between the test runs in the same TestComplete session. The property is reset to the default value upon restarting TestComplete.

The name of this property coincides with the name of the ListSeparator property of the Utilities object that is obsolete. If you access the ListSeparator property without specifying the object name, TestComplete will use the obsolete Utilities.ListSeparator property rather than aqString.ListSeparator. This is done for backward compatibility. To work with the property of the aqString object, always place the object name before the property name, that is, use the aqString.ListSeparator syntax.

Example

The code below demonstrates how you can get or set the list separator directly from your script.

JavaScript, JScript

function SplitDemo()
{

    var s = "Better late than never but better never late.";
    // Assign the list separator to the space character
    var prevSep = aqString.ListSeparator;
    aqString.ListSeparator = " ";
    Log.Message("The string is: " + s);
    // Split by spaces
    Log.Message("There are " + aqString.GetListLength(s) + " words in the string");
    Log.Message("The first word is: " + aqString.GetListItem(s, 0));
    // Restore the previous separator
    aqString.ListSeparator = prevSep;
}

Python

def SplitDemo():
  s = "Better late than never but better never late."
  # Assign the list separator to the space character
  prevSep = aqString.ListSeparator
  aqString.ListSeparator = " "
  Log.Message("The string is: " + s)
  # Split by spaces
  Log.Message("There are " + str(aqString.GetListLength(s)) + " words in the string")
  Log.Message("The first word is: " + aqString.GetListItem(s, 0))
  # Restore the previous separator
  aqString.ListSeparator = prevSep

VBScript

Sub SplitDemo
    Dim s, prevSep

    s = "Better late than never but better never late."
    ' Assign the list separator to the space character
    prevSep = aqString.ListSeparator
    aqString.ListSeparator = " "
    Log.Message("The string is: " & s)
    ' Split by spaces
    Log.Message("There are " & aqString.GetListLength(s) & " words in the string")
    Log.Message("The first word is: " & aqString.GetListItem(s, 0))
    ' Restore the previous separator
    aqString.ListSeparator = prevSep
End Sub

DelphiScript

function SplitDemo;
var s, prevSep;
begin

    s := 'Better late than never but better never late.';
    // Assign the list separator to the space character
    prevSep := aqString.ListSeparator;
    aqString.ListSeparator := ' ';
    Log.Message('The string is: ' + s);
    // Split by spaces
    Log.Message('There are ' + IntToStr(aqString.GetListLength(s)) + ' words in the string');
    Log.Message('The first word is: ' + aqString.GetListItem(s, 0));
    // Restore the previous separator
    aqString.ListSeparator := prevSep;
end;

C++Script, C#Script

function SplitDemo()
{

    var s = "Better late than never but better never late.";
    // Assign the list separator to the space character
    var prevSep = aqString["ListSeparator"];
    aqString["ListSeparator"] = " ";
    Log["Message"]("The string is: " + s);
    // Split by spaces
    Log["Message"]("There are " + aqString["GetListLength"](s) + " words in the string");
    Log["Message"]("The first word is: " + aqString["GetListItem"](s, 0));
    // Restore the previous separator
    aqString["ListSeparator"] = prevSep;
}

See Also

Working With Strings
AddListItem Method
ChangeListItem Method
DeleteListItem Method
GetListLength Method

Highlight search results