Click to See Complete Forum and Search --> : Need help with arrays !


Motabobo
09-07-2003, 06:48 PM
Hi !

I have this directory that contains all of those folder :
=====================================
2001-[Big John]
2001-[Minette]
2002-01-2003-[Mont Ham]
2002-04-27-[Luray Caverns]
2002-04-27-[Shenandoah National Park]
2002-06-24-[Hautes-Gorges Riviere Malbaie]
2002-08-21-[White Mountains]
2002-12-08-[Mont Orford]
2003-02-2003-[Mont Sutton]
2003-05-21-[Franconia]
2003-06-06-[Baxter State Park]
2003-06-10-[Forillon Park]
=====================================

Now i want to group those folders in descendant order by looking at the first 4 characters of the folder's name (the year ie.: 2001, 2002, etc.)

That can be done using this bit of code :
==========================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
</HEAD>

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

Dim theFolders( )
ReDim theFolders( 50 )
currentSlot = -1 ' commencer avant la première position

For Each folder in objFL
fname = folder.Name
ftype = folder.Type
fsize = folder.Size
fcreate = folder.DateCreated
fmod = folder.DateLastModified
faccess = folder.DateLastAccessed
currentSlot = currentSlot + 1
If currentSlot > UBound( theFolders ) Then
ReDim Preserve theFolders( currentSlot + 99 )
End If
' Infos disponibles pour les dossiers
theFolders(currentSlot) = Array(fname,ftype,fsize,fcreate,fmod,faccess)
Next

folderCount = currentSlot
'ReDim Preserve theFolders( currentSlot )

For i = folderCount TO 0 Step -1
minmax = theFolders( 0 )( sortBy )
minmaxSlot = 0
For j = 1 To i
mark = (strComp( theFolders(j)(sortBy), minmax, vbTextCompare ) < 0)
If mark Then
minmax = theFolders( j )( sortBy )
minmaxSlot = j
End If
Next
If minmaxSlot <> i Then
temp = theFolders( minmaxSlot )
theFolders( minmaxSlot ) = theFolders( i )
theFolders( i ) = temp
End If
Next
%>
<TABLE Border=1 CellPadding=3>
<TR>
<TH>File name</TH>
<!--
<TH>Type</TH>
<TH>Size</TH>
<TH>Created</TH>
<TH>Last modified</TH>
<TH>Last accessed</TH>
-->
</TR>
<%
Dim First4Char, LastFirst4Char

For i = 0 To folderCount
Response.Write "<TR>" & vbNewLine
First4Char = Left(theFolders(i)(0), 4)
if (First4Char <> LastFirst4Char) then
Response.Write "<TR>" & vbNewLine
Response.Write "<TD align=center><b>" & First4Char & "<b></TD>" & vbNewLine
Response.Write "</TR>" & vbNewLine
LastFirst4Char = First4Char
end if
Response.Write "<TD>" & theFolders(i)(0) & "</TD>" & vbNewLine
Response.Write "</TR>" & vbNewLine
Next
%>
</TABLE>

<%
Set objFL = Nothing
Set objFd = Nothing
Set objFS = Nothing
%>
</BODY>
</HTML>
==========================================================

Now my question is with that kind of loops how do i put in one array only the group's name ie.: 2003, 2002, 2001 (in that order) and in another array each group's content ?

ex:
Group array : 2003, 2002, 2001

Content array for group 2001 : 2001-[Minette], 2001-[Big John]

Content array for group 2002 : 2002-12-08-[Mont Orford], 2002-08-21-[White Mountains], 2002-06-24-[Hautes-Gorges Riviere Malbaie], 2002-04-27-[Shenandoah National Park], 2002-04-27-[Luray Caverns], 2002-01-2003-[Mont Ham]

Content array for group 2003 : 2003-06-10-[Forillon Park], 2003-06-06-[Baxter State Park], 2003-05-21-[Franconia], 2003-02-2003-[Mont Sutton]

I need that for writing an outlook bar menu (maybe a multi-dimensionnal array would be better ?).

I need to do this :


For each element in group array (ie.: 2003, 2002, 2001)
write the group array name
For each content arrays
Find the content array related to the group we are currently in
Write all the elements of that good content array
Next
Next


I would need complete code please !

Many thanks :-)