FileNamesList Method

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

Description

The FileNamesList method lets you get as one string all the file names referred to by items in the Files, Objects or Regions collection, in index order, separated by line breaks (0Dh, 0Ah) by default.

Declaration

ProgObj.FileNamesList(Separator)

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
Separator [in]    Optional    String Default value: new line character   
Result String

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameter:

Separator

The string that will be used to separate individual file names in the returned list. By default, this string is “\r\n”, which means line breaks (0Dh, 0Ah).

Result Value

The string that contains all the file names referred to by items of the collection.

Example

The following example demonstrates how you can get the names of items of the Files collection and the names of the corresponding stored files.

JavaScript, JScript

function Test1()
{
  var i;

  // Posts the names of the items stored in the Files collection
  Log.Message(Files.NamesList());

  // Posts the names of the files stored in the Files collection
  Log.Message(Files.FileNamesList());

  // Posts the total number of items stored in the Files collection
  Log.Message("The total number of files: " + Files.Count);

  // Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
  for (i = 0; i < Files.Count; i++)
    Log.Message(Files.NameByIndex(i) + " stores " + Files.FileNameByIndex(i));
}

Python

def Test1():
  # Posts the names of the items stored in the Files collection
  Log.Message(Files.NamesList())
  # Posts the names of the files stored in the Files collection
  Log.Message(Files.FileNamesList())
  # Posts the total number of items stored in the Files collection
  Log.Message("The total number of files: " + str(Files.Count))
  # Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
  for i in range(i, Count): 
    Log.Message(Files.NameByIndex[i] + " stores " + Files.FileNameByIndex[i])

VBScript

Sub Test1
  ' Posts the names of the items stored in the Files collection
  Log.Message(Files.NamesList())

  ' Posts the names of the files stored in the Files collection
  Log.Message(Files.FileNamesList())

  ' Posts the total number of items stored in the Files collection
  Log.Message("The total number of files: " & Files.Count)

  ' Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
  For i = 0 To Files.Count-1
    Log.Message(Files.NameByIndex(i) & " stores " & Files.FileNameByIndex(i))
  Next
End Sub

DelphiScript

procedure Test1;
var
  i : OleVariant;
begin
  // Posts the names of the items stored in the Files collection
  Log.Message(Files.NamesList());

  // Posts the names of the files stored in the Files collection
  Log.Message(Files.FileNamesList());

  // Posts the total number of items stored in the Files collection
  Log.Message('The total number of files: ' + Files.Count);

  // Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
  for i := 0 to Files.Count-1 do
    Log.Message(Files.NameByIndex(i) + ' stores ' + Files.FileNameByIndex(i));
end;

C++Script, C#Script

function Test1()
{
  var i;

  // Posts the names of the items stored in the Files collection
  Log["Message"](Files["NamesList"]());

  // Posts the names of the files stored in the Files collection
  Log["Message"](Files["FileNamesList"]());

  // Posts the total number of items stored in the Files collection
  Log["Message"]("The total number of files: " + Files["Count"]);

  // Iterates through the items of the collection and posts their names and the names of the corresponding files to the log
  for (i = 0; i < Files["Count"]; i++)
    Log["Message"](Files["NameByIndex"](i) + " stores " + Files["FileNameByIndex"](i));
}

See Also

NamesList Method
FileNameByIndex Method
FileNameByName Method

Highlight search results