Enumerator 对象

集合访问对象。

因集合无法用数字下标取值,只能以关键字取值,在关键字未知的情况下可用此对象。

方法/属性 意义
Enumerator( 集合 ) 构造函数
moveNext() 移到下一个
moveFirst() 移到第一个
atEnd() 是否到结束位置
item() 返回集合中的一个对象

示例:

// 显示目录 c:\ 中的所有文件

sc = new ActiveXObject("Scripting.FileSystemObject");

en = new Enumerator(sc.GetFolder("c:\\").Files);


for ( ; !en.atEnd(); en.moveNext() )
    document.write (en.item().Path + "<br>\n");