Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 ASP Coding Help
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 06 February 2008 :  07:42:51  Show Profile
Hi,

I have this photogallery script that reads the content of a folder and shows it as a gallery.

I would like to change only one thing in the script - as it is now it will show the images in 01 to 09 for example, I would like the reverse order 09 to 01 for example

Edited by - wii on 06 February 2008 10:46:12

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 06 February 2008 :  07:54:00  Show Profile
Do you just want to reverse the order of the numbers of the order of the images as well?


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 06 February 2008 :  07:57:44  Show Profile
No, just the order the images are shown

Thanks a lot
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 06 February 2008 :  07:58:52  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Its not trivial. The first example uses an array to sort the files by name, the other uses a recordset.

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=118
http://www.roubaixinteractive.com/PlayGround/FSO/Sort_Folder_Contents.asp

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 06 February 2008 :  08:23:49  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Actually, you just need to find a way to sort this array;
	'Store picture file names in an array
	x = 0
	For Each objFileItem in objFolderContents
		If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
			strPicArray(0,x) = objFileItem.Name
			strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
			x = x + 1
		End if
	Next

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 06 February 2008 :  08:26:37  Show Profile
Yeah, but how, it may as well be in russian for me.
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 06 February 2008 :  08:32:01  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
I have a function to sort a multidimensional array somewhere, if I could only find it!

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 06 February 2008 :  09:18:43  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Try this. Let me know if it doesn't work correctly.

<%

' PhotoAlbum

Dim CurFile, PopFileShowSub, ShowPic, PictureNo
Dim strPathInfo, strPhysicalPath


Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
intPicsPerRow = 3
intPicsPerPage = 12

intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
intPage = 1
End If


CurFile = "PhotoAlbum.asp"
PopFile = "ShowPicture.asp"
%>
<body stylesrc="../../template.asp" background="../../Hovedside/arrow.jpg" bgproperties="fixed">
<script language="JavaScript">
<!--
function jumppage(sel)
{
var i = sel.selectedIndex
self.location.href = sel.options[i].value
}
// -->
</script>
<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openGalleryWindow(url) {
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
var xOffset = 100, yOffset = 100;

popupWin = window.open(url,'new_page','width=700,height=535,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=auto,toolbars=no,menubar=no,resizable=yes')
}
// done hiding -->
</script>

<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
<tr>

<td align="center" width="25%">
<form action="<%=PopFile%>" method="POST">
<font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>" color="<% =strBaseFontColor %>"><b>vælg photo album: </b>
<select name="go" onChange="jumppage(this);" size="1">
<%
ShowSub = request("ShowSub")
ShowPic = request("ShowPic")
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
For each Folder in objFolder.SubFolders
If Left(Folder.Name,1)<>"_" Then
Response.write "<option "
If ShowSub=Folder.Name Then
Response.Write "selected "
End if
Response.Write"value='" & CurFile & "?ShowSub="
Response.Write(Replace(Folder.Name, " ", "%20"))
response.write "'>"
Response.Write(Folder.Name & "</option>")
If ShowSub <= " " Then
ShowSub = Folder.Name
End if
End if
Next
Set objFSO = Nothing
%>
</select></h3>
</form>
</td>
</tr>
</table>


<%
If ShowPic > " " then
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<a href='JavaScript:history.go(-1)'><img src='" & ShowPic & "'><BR><BR><font face=""verdana"" size=""1""><b>Go Back</b></a>"
Else
%>
<table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
<tr>
<%
strPhysicalPath = Server.MapPath(".\" & ShowSub)
If ShowSub > " " then
ShowSub = Replace(ShowSub, " ", "%20")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objFolderContents = objFolder.Files



'Get the number of pictures in the subdirectory
intTotPics = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
intTotPics = intTotPics + 1
End if
Next

'Get the total number of pages in the subdirectory
If (intTotPics/intPicsPerPage) = (int(intTotPics/intPicsPerPage)) Then
intTotPages = int(intTotPics/intPicsPerPage)
Else
intTotPages = int(intTotPics/intPicsPerPage)+1
End If
Redim strPicArray(2,intTotPics)

'Store picture file names in an array
x = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
strPicArray(0,x) = objFileItem.Name
strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
x = x + 1
End if
Next

'Sort picture array
call SortAlpha(strPicArray, "DESC", 0)

'Determine if there are multiple pages and if so, display page numbers.
If intTotPages > 1 Then
Response.Write "<td colspan='" & intPicsPerRow & "' align='center'><font face='Verdana,Arial' size='1'>SIDE:   "
For x = 1 to intTotPages
If x = intPage Then
Response.Write "</font><font face='Arial' size='2'>" & x & "</font><font face='Arial' size='1'>    "
Else
Response.Write "<a href='PhotoAlbum.asp?Page=" & x & "&ShowSub=" & ShowSub & "'>" & x & "</a>    "
End If
Next
Response.Write "</font></td>"
Response.Write "</tr><tr><td> </td></tr><tr>"
End If


For x = 0 to UBound(strPicArray,2)-1
If CInt(strPicArray(1,x)) = intPage Then
ShowPic = Replace(strPicArray(0,x), " ", "%20")
Response.write "<td align='center' width='25%'><a href=""Javascript:openGalleryWindow('" & PopFile & "?ShowPic=" & ShowSub & "/" & ShowPic & "')"""
Response.write "<br>"
Response.Write("<img src='" & ShowSub & "/" & strPicArray(0,x) & "' width=150> ")
Response.Write("<br><font color=""" & strBaseFontColor & """><b>" & Mid(strPicArray(0,x),1,Len(strPicArray(0,x))-4) & "</b></font>")
Response.write "</a></td>" & vbcrlf

PictureNo = PictureNo + 1
If PictureNo=intPicsPerRow Then
Response.write "</tr><tr>"
PictureNo = 0
End if
End If
Next



Set objFSO = Nothing
End if
%>
</tr>
</table>
<%
End if

function SortAlpha(ary, direction, indexnum)
Dim StopWork
Dim i
Dim i2
Dim firstval()
Dim secondval()

redim firstval(ubound(ary,1))
redim secondval(ubound(ary,1))

StopWork=False
Do Until StopWork=True
StopWork=True
For i = 0 To UBound(ary,2)
if i=UBound(ary,2) Then Exit For
if UCase(Direction) = "DESC" Then
compare = ary(indexnum,i) < ary(indexnum,i+1)
if compare Then
For i2 = 0 To ubound(firstval)
firstval(i2) = ary(i2,i)
secondval(i2) = ary(i2,i+1)
ary(i2,i) = secondval(i2)
ary(i2,i+1) = firstval(i2)
Next
StopWork=False
End if
Else
compare = ary(indexnum,i) > ary(indexnum,i+1)
if compare then
For i2 = 0 To ubound(firstval)
firstval(i2) = ary(i2,i)
secondval(i2) = ary(i2,i+1)
ary(i2,i) = secondval(i2)
ary(i2, i+1) = firstval(i2)
Next
StopWork=False
End if
End if
Next
Loop
SortAlpha=ary
End function
%>
</center>
</html>

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.

Edited by - Podge on 06 February 2008 09:19:09
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 06 February 2008 :  10:46:33  Show Profile
It does !

Thanks a lot, I owe you a beer !!!
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 06 February 2008 :  11:46:05  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Its an alphanumeric sort, rather than a numeric one. What do you mean by a beer ? I always thought beer was plural ?

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.

Edited by - Podge on 06 February 2008 11:46:26
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 07 February 2008 :  05:11:24  Show Profile
Ha, ha, you are right - a beer is just wrong

Here you go:



Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 07 February 2008 :  07:37:16  Show Profile  Visit HuwR's Homepage
wii, be careful, you are talking to Podge, that ain't a beer, this is a beer



Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 07 February 2008 :  12:34:48  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
This is more like it*


or this old one from my local*



Must do another of those competitions soon.



*Actually, I don't drink Guinness

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 08 February 2008 :  07:15:07  Show Profile
Hmm, I´m not into dark beer, I prefer lager:

http://en.wikipedia.org/wiki/Lager

Any case, one is definately not enough.
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 08 February 2008 :  07:57:04  Show Profile
quote:
Originally posted by Podge
*Actually, I don't drink Guinness
You mean not all Irish people drink Guinness Next you'll be telling me we've no pet leprechauns in our gardens!


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 08 February 2008 :  10:44:16  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Mine are just coming out of hibernation now after the Winter. Pretty soon they will be skipping along the fields hiding their pots of gold and making rainbows to beat the band. I love this time of year.

You're looking well in that new TV ad for woo.ie, Shaggy !

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.38 seconds. Powered By: Snitz Forums 2000 Version 3.4.07