Item number in a collection?

N

news.microsoft.com

Hi

I want to reverse a folder listing, can I referre to a collection with a
item number like in arrays?

ex:
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fo=fs.GetFolder(smp)
for each subfld in fo.subfolders
..
..
next

can I do the FOR statement reverse without putting all folder names into an
array.
 
R

Ray at

I think what he wants to do is something like:
Set subFolders = fo.Subfolders
For i = 0 to subFolders.Count
response.write subFolders(i).Name
Next

which you cannot do with the subfolders collection.

instead of

for each x in fo.subfolders
response.write x.name
next

Ray at home
 
N

news.microsoft.com

U right Ray, that is what I wanted.
Ok, no big problem, just takes longer to execute my code if I have to put
folder names into an array.
 
J

Jon Mundsack

He doesn't. klæj wants to iterate through the subfolders in reverse order,
i.e., not the order they come out in the For Each loop. In order to do
this, klæj has to first iterate through the subfolders in their initial
order, while storing them into an array. Once the subfolders are in an
array, they can be iterated through in reverse order using step -1. klæj
was lamenting over the fact that doing this makes the code slower.

HTH-Jon
 
P

Paul Baker

Oh, okay :) I too am lamenting.

Paul

Jon Mundsack said:
He doesn't. klæj wants to iterate through the subfolders in reverse order,
i.e., not the order they come out in the For Each loop. In order to do
this, klæj has to first iterate through the subfolders in their initial
order, while storing them into an array. Once the subfolders are in an
array, they can be iterated through in reverse order using step -1. klæj
was lamenting over the fact that doing this makes the code slower.

HTH-Jon



http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,079
Messages
2,570,574
Members
47,206
Latest member
Zenden

Latest Threads

Top