TSearchRec Object

Applies to TestComplete 15.10, last modified on December 01, 2021
This object is obsolete. See the Remarks section below.

Description

The TSearchRec object is a wrapper for Borland’s VCL TSearchRec structure. This structure is used by the FindFirst and FindNext functions. These functions search for files. TSearchRec holds information about files that are to be found or about files that were found.

Note: TSearchRec is passed to the FindFirst routine as an [out] parameter. FindFirst stores information about the found file to the object properties. Before calling this function, you should first create a TSearchRec instance by calling Utilities.TSearchRec.

Properties

The TSearchRec object contains the following properties (they are analogues to the fields of the TSearchRec structure):

Property Description
Time An integer value that specifies the date and time of a file. You can obtain the desired integer value by converting a Variant of the Date subtype using the DateTimeToFileDate function.
Size The size of a file in bytes.
Attr Specifies file attributes. This property can hold one or a combination of the following values. To combine the values, use the or operator:
Attribute Value Description
faAnyFile 63 Any file.
faReadOnly 1 Read-only file.
faHidden 2 Hidden file.
faSysFile 4 System file.
faVolumeID 8 Volume identifier file.
faDirectory 16 Folder or directory.
faArchive 32 The file that has been changed since the last backup.

To see if the found file has the desired attributes, you can combine the desired attribute combination with the Attr property by the and operator as it is shown in the following sample:

JavaScript, JScript

// t holds a reference to the TSearchRec object
if ( t.Attr & (faReadOnly | faHidden) == (faReadOnly | faHidden) )
  Log.Message("The file is read-only and hidden.");

Python

# t holds a reference to the TSearchRec object
if ( t.Attr and (faReadOnly or faHidden) == (faReadOnly or faHidden) ):
   Log.Message("The file is read-only and hidden.")

VBScript

' t holds a reference to the TSearchRec object
If ( (t.Attr And (faReadOnly Or faHidden)) = (faReadOnly Or faHidden) ) Then
  Log.Message "The file is read-only and hidden."
End If

DelphiScript

// t holds a reference to the TSearchRec object
if ( (t.Attr and (faReadOnly or faHidden)) = (faReadOnly or faHidden) ) then
  Log.Message('The file is read-only and hidden.');

C++Script, C#Script

// t holds a reference to the TSearchRec object
if ( t["Attr"] & (faReadOnly | faHidden) == (faReadOnly | faHidden) )
  Log["Message"]("The file is read-only and hidden.");

Name String that holds the file name in the 8.3 format. It does not include the file path.
ExcludeAttr Used internally by the routines. Do not modify this property.
FindHandle Used internally by the routines. Do not modify this property.

Remarks

The TSearchRec object is obsolete. It is supported for backward compatibility only. To search for files, use the aqFileSystem.FindFiles method.

See Also

TSearchRec Method
FindFiles Method

Highlight search results