Next Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the Next method to obtain the next item in the objects collection. To check whether the next object is available, call the HasNext method.

Declaration

aqObjIteratorObj.Next()

aqObjIteratorObj An expression, variable or parameter that specifies a reference to an aqObjIterator object
Result An aqFileInfo, aqFolderInfo, aqDriveInfo, aqObjEvent, aqObjField, aqObjMethod, or aqObjProperty object.

Applies To

The method is applied to the following object:

Result Value

The type of the returned object depends on the method or property that caused the creation of the aqObjIterator object:

Method/Property Generator Resulting object Item Meaning
aqDriveInfo.Files aqFileInfo Information about a single file from the drive’s root.
aqDriveInfo.Folders aqFolderInfo Information about a single folder from the drive’s root.
aqFileSystem.FindFiles aqFileInfo Information about a single file matching the specified search pattern.
aqFileSystem.FindFolders aqFolderInfo Information about a single folder matching the specified search pattern.
aqFileSystem.Drives aqDriveInfo Information on one of system drives.
aqFolderInfo.Files aqFileInfo Information about a single file of the folder.
aqFolderInfo.SubFolders aqFolderInfo Information about a single subfolder of the folder.
aqObject.GetEvents aqObjEvent A description of the object’s event.
aqObject.GetFields aqObjField A description of the object’s field.
aqObject.GetMethods aqObjMethod A description of the object’s method.
aqObject.GetProperties aqObjProperty A description of the object’s property.

Example

The code below obtains the collection of all the drives existing on your computer and posts their size to the test log.

JavaScript, JScript

function ObtainDriveSize()
{

  // Obtains the drives collection
  var DrvCol = aqFileSystem.Drives;
  var Fixed = 3;
  
  while ( DrvCol.HasNext() )
  {
    // Obtains the current drive
    var DrvItem = DrvCol.Next();
    // Obtains the drive letter
    var DrvLet = DrvItem.DriveLetter;
    if (DrvItem.DriveType == Fixed)
    {
      // Obtains the drive size
      var DrvSize = DrvItem.TotalSize;
      // Posts the drive letter and its size to the test log
      Log.Message("Drive " + DrvLet + ": size " + DrvSize);
    }
    else
      Log.Message("Disk " + DrvLet + ": unable to get information about the total space on the specified disk.")
    
  }
    
}

Python

def ObtainDriveSize():
  # Obtains the drives collection
  DrvCol = aqFileSystem.Drives
  Fixed = 3
  while DrvCol.HasNext():
    # Obtains the current drive
    DrvItem = DrvCol.Next()
    # Obtains the drive letter
    DrvLet = DrvItem.DriveLetter
    if DrvItem.DriveType == Fixed:
      # Obtains the drive size
      DrvSize = DrvItem.TotalSize
      # Posts the drive letter and its size to the test log
      Log.Message("Drive " + DrvLet + ": size " + str(DrvSize))
    else:
      Log.Message("Disk " + DrvLet + ": unable to get information about the total space on the specified disk.")

VBScript

Sub ObtainDriveSize
Dim Fixed
  ' Obtains the drives collection
  Set DrvCol = aqFileSystem.Drives
  Fixed = 3
  
  While DrvCol.HasNext
  
    ' Obtains the current drive
    Set DrvItem = DrvCol.Next
    ' Obtains the drive letter
    DrvLet = DrvItem.DriveLetter
    If (DrvItem.DriveType = Fixed) Then
      ' Obtains the drive size
      DrvSize = DrvItem.TotalSize
      ' Posts the drive letter and its size to the test log
      Log.Message "Drive " & DrvLet & ": size " & IntToStr(DrvSize)
    Else
      Log.Message "Disk " & DrvLet & ": unable to get information about the total space on the specified disk."
    End If
    
  WEnd
    
End Sub

DelphiScript

function ObtainDriveSize;
var DrvCol, Fixed, DrvItem, DrvLet, DrvSize;
begin

  // Obtains the drives collection
  DrvCol := aqFileSystem.Drives;
  Fixed := 3;
  
  while ( DrvCol.HasNext() ) do
  begin
    // Obtains the current drive
    DrvItem := DrvCol.Next();
    // Obtains the drive letter
    DrvLet := DrvItem.DriveLetter;
    if (DrvItem.DriveType = Fixed) then
    begin
      // Obtains the drive size
      DrvSize := DrvItem.TotalSize;
      // Posts the drive letter and its size to the test log
      Log.Message('Drive ' + DrvLet + ': size ' + IntToStr(DrvSize) );
    end
    else
      Log.Message('Disk ' + DrvLet + ': unable to get information about the total space on the specified disk.')
    
  end;
    
end;

C++Script, C#Script

function ObtainDriveSize()
{

  // Obtains the drives collection
  var DrvCol = aqFileSystem["Drives"];
  var Fixed = 3;
  
  while ( DrvCol["HasNext"]() )
  {
    // Obtains the current drive
    var DrvItem = DrvCol["Next"]();
    // Obtains the drive letter
    var DrvLet = DrvItem["DriveLetter"];
    if (DrvItem["DriveType"] == Fixed)
    {
      // Obtains the drive size
      var DrvSize = DrvItem["TotalSize"];
      // Posts the drive letter and its size to the test log
      Log["Message"]("Drive " + DrvLet + ": size " + DrvSize);
    }
    else
      Log["Message"]("Disk " + DrvLet + ": unable to get information about the total space on the specified disk.")
    
  }
    
}

See Also

HasNext Method
Reset Method
Skip Method
Item Method

Highlight search results