更新 : 2007 年 11 月
Enumerator オブジェクト内の現在の項目を最初の項目に設定し直します。
function moveFirst()
解説
コレクション内に項目がない場合、現在の項目は undefined に設定されます。
使用例
moveFirst メソッドを使って Drives コレクションのメンバを先頭から評価する例を次に示します。
function ShowFirstAvailableDrive(){
var fso, s, e, x; //Declare variables.
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives); //Create Enumerator object.
e.moveFirst(); //Move to first drive.
s = ""; //Initialize s.
do
{
x = e.item(); //Test for existence of drive.
if (x.IsReady) //See if it's ready.
{
s = x.DriveLetter + ":"; //Assign 1<SUP>st</SUP> drive letter to s.
break;
}
else
if (e.atEnd()) //See if at the end of the collection.
{
s = "No drives are available";
break;
}
e.moveNext(); //Move to the next drive.
}
while (!e.atEnd()); //Do while not at collection end.
return(s); //Return list of available drives.
}