atEnd 方法
傳回的布林值將說明列舉值是否是集合物件的最後一個項目。
function atEnd() : Boolean
備註
如果目前的項目是集合物件中的最後一個、集合物件是空的,或者目前的項目尚未定義,atEnd 方法就會傳回 true。 否則,它會傳回 false。
範例
在下列程式碼中,使用 atEnd 方法來確定是否已到達磁碟機清單的結尾:
function ShowDrives()
{
var s = "";
var bytesPerGB = 1024 * 1024 * 1024;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var e = new Enumerator(fso.Drives);
e.moveFirst();
while (e.atEnd() == false)
{
var drv = e.item();
s += drv.Path + " - ";
if (drv.IsReady)
{
var freeGB = drv.FreeSpace / bytesPerGB;
var totalGB = drv.TotalSize / bytesPerGB;
s += freeGB.toFixed(3) + " GB free of ";
s += totalGB.toFixed(3) + " GB";
}
else
{
s += "Not Ready";
}
s += "\n";
e.moveNext();
}
return(s);
}