Description
Use the HasNext
method to find out whether the current object is the last item in the collection or whether there is at least one more object. To obtain the next object, use the Next
method.
Declaration
aqObjIteratorObj.HasNext()
aqObjIteratorObj | An expression, variable or parameter that specifies a reference to an aqObjIterator object | |||
Result | Boolean |
Applies To
The method is applied to the following object:
Result Value
True if one more objects follow the current one. False if the current object is the last one in the collection.
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.")
}
}