Click to See Complete Forum and Search --> : Looping through an array


Motabobo
07-17-2003, 12:37 PM
Hi !

I have this code (that works for once lol) that gets the folders in a directory and puts their name into an array

Set objFS = Server.CreateObject("Scripting.FileSystemObject")
Set objFd = objFS.GetFolder(Server.MapPath(".\"))
Set objFL = objFd.subFolders

For each folder in objFL

i = i + 1

Redim Preserve Nav(i)

Nav(i) = folder.name

Next

Response.Write Nav(1)
Response.Write Nav(2)
Response.Write Nav(3)

i = 0

Set objFL = Nothing
Set objFd = Nothing
Set objFS = Nothing


But now what i want is to get the first 4 characters of the folder's name to the left and depending of the results, write a table that will group the folders starting with the same 4 characters togethers. Those 4 characters are the date written in the folder's name. Name structure is like this for all folders : 2002-05-05-[content here]. Another thing to figure out would be to set the order of the array descending upon the complete date written on the folder's name.

What i want can be viewed here (note that the data is already sorted ! but i don't know how to do that yet !):
http://pages.infinit.net/rouxjean/sort.htm

Many thanks !!