jim wrote on 18 jun 2004 in comp.lang.javascript
:
I have an example that iterates through the fso folders collection etc
for the fso files collection. The problem is this:
the example uses an enumerator to cycle through the collection items
and i would like to use a for loop but I can't get the syntax correct.
for (var i=1;i<=length;i++) {
eFile=oFldr.files;
alert(eFile.item(1).type);
}
perhaps the .item(1). should be .item(i). ?
and the i<=length be i<=oFldr.length ?
==============================================
M$ enumerates:
function ShowFolderFileList(folderspec) {
var fso, f, fc, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.files);
for (; !fc.atEnd(); fc.moveNext()) {
alert(fc.item().name + "\n" + fc.item().type);
}
}
not tested.
see:
<http://msdn.microsoft.com/library/en-us/script56/html/jsprofiles.asp>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)