JavaScript tutorial:
atEnd method

 

Applies to: Enumerator Object

The atEnd method is use to get a Boolean value indicating if the enumerator is at the end of the collection.

Syntax

myEnum.atEnd( )

The myEnum argument is any Enumerator object.

Return

Returns a Boolean value indicating if the enumerator is at the end of the collection.

Return Value

The atEnd method returns true if the current item is the last one in the collection, the collection is empty, or the current item is undefined. Otherwise, it returns false.

Example

In following code, the atEnd method is used to determine if the end of a list of drives has been reached:

<HTML>
<HEAD>
<SCRIPT LANGUAGE= JavaScript>
function ShowDriveList()
{
var fso, s, n, e, x;
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives);
s = "";
for (; !e.atEnd(); e.moveNext())
{
x = e.item();
s = s + x.DriveLetter;
s += " - ";
if (x.DriveType == 3)
n = x.ShareName;
else if (x.IsReady)
n = x.VolumeName;
else
n = "[Drive not ready]";
s += n + "<br>";
}
return(s);
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE= JavaScript>
document.write(ShowDriveList());
</SCRIPT>
</BODY>
</HTML>

To run the code above, paste it into JavaScript Editor, and go to View, Internal Page Viewer or press F5.

See also: item Method, moveFirst Method, moveNext Method