<% '################################################################################# '## Copyright (C) 2001-02 Kevin Hillabolt '## '## This program is free software; you can redistribute it and/or '## modify it under the terms of the GNU General Public License '## as published by the Free Software Foundation; either version 2 '## of the License, or any later version. '## '## This program is distributed in the hope that it will be useful, '## but WITHOUT ANY WARRANTY; without even the implied warranty of '## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '## GNU General Public License for more details. '## '## You should have received a copy of the GNU General Public License '## along with this program; if not, write to the Free Software '## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. '## '## Correspondence can be sent to: '## khill@bigfoot.com '################################################################################# Option Explicit On Error Resume Next '--------------------------------------------------------------------------- ' Class DynamicArray: Class to create dynamically sized arrays ' ' http://www.4guysfromrolla.com/webtech/032800-1.shtml ' ' Usage: ' Dim objDynArray ' set objDynArray = New DynamicArray ' ' objDynArray.Data(4) = "Hello!" ' ' To Loop: ' Dim i ' For i = LBound(objDynArray.DataArray) to UBound(objDynArray.DataArray) ' ///Or, the above line could be replaced by: ' ///For i = objDynArray.StartIndex() to objDynArray.StopIndex() ' Response.Write i & ".) " & objDynArray.Data(i) & "" ' Next '--------------------------------------------------------------------------- Class DynamicArray '************** Properties ************** Private aData '**************************************** '*********** Event Handlers ************* Private Sub Class_Initialize() Redim aData(0) End Sub '**************************************** '************ Property Get ************** Public Property Get Data(iPos) 'Make sure the end developer is not requesting an '"out of bounds" array element If iPos < LBound(aData) or iPos > UBound(aData) then Exit Property 'Invalid range End If Data = aData(iPos) End Property Public Property Get DataArray() DataArray = aData End Property '**************************************** '************ Property Let ************** Public Property Let Data(iPos, varValue) 'Make sure iPos >= LBound(aData) If iPos < LBound(aData) Then Exit Property If iPos > UBound(aData) then 'We need to resize the array Redim Preserve aData(iPos) aData(iPos) = varValue Else 'We don't need to resize the array aData(iPos) = varValue End If End Property '**************************************** '************** Methods ***************** Public Function StartIndex() StartIndex = LBound(aData) End Function Public Function StopIndex() StopIndex = UBound(aData) End Function Public Sub Delete(iPos) 'Make sure iPos is within acceptable ranges If iPos < LBound(aData) or iPos > UBound(aData) then Exit Sub 'Invalid range End If Dim iLoop For iLoop = iPos to UBound(aData) - 1 aData(iLoop) = aData(iLoop + 1) Next Redim Preserve aData(UBound(aData) - 1) End Sub '**************************************** End Class '--------------------------------------------------------------------------- ' ReturnImageSize(strFileName) ' This function utilizes the free ImageSize COM object from ServerObjects ' to return the height and width of an image ' ' Note: strFileName must be an absolute path. Use Server.MapPath if you ' don't not know. ' ' http://www.serverobjects.com/products.htm#free ' http://www.serverobjects.com/comp/imgsize.zip '--------------------------------------------------------------------------- Function ReturnImageSize(strFileName) Dim objImgSize 'ImgSize object Dim astrImageSize(2) 'Height, Width Set objImgSize = Server.CreateObject ("ImgSize.Check") objImgSize.FileName = strFileName If objImgSize.Error = "" Then astrImageSize(0) = objImgSize.Height astrImageSize(1) = objImgSize.Width End If Set objImgSize = Nothing ReturnImageSize = astrImageSize End Function '--------------------------------------------------------------------------- ' Begin Code '--------------------------------------------------------------------------- '==Set constants Const MAX_ROWS = 4 Const MAX_COLS = 4 '--Set this to zero if you don't have the serverobjects imagesize component Const HAVE_IMAGE_SIZE_COMPONENT = 1 '==Image Directory ' This can change if thumbnails are active Dim strImgDir: strImgDir = Request.QueryString("ImageDir"): strImgDir = Server.MapPath(strImgDir) Dim strRelImgDir: strRelImgDir = Request.QueryString("ImageDirRelative") Dim strThumbDir If Request.QueryString("ThumbDir") <> "" Then strThumbDir = strImgDir & "\" & Request.QueryString("ThumbDir") End If '==Image Array Dim strArrImages() '--FileSystemObject variables Dim objFSO, objFolder, objFile Set objFSO = Server.CreateObject("Scripting.FileSystemObject") '--Check for the use of thumbnails If strThumbDir <> "" Then strImgDir = strThumbDir End If Set objFolder = objFSO.GetFolder(strImgDir) Dim intFileCount: intFileCount = objFolder.Files.Count Dim intIterator: intIterator = 0 '==Initialize the dynamic array Dim objDynArray Set objDynArray = New DynamicArray For Each objFile in objFolder.Files objDynArray.Data(intIterator) = objFile.Name intIterator = intIterator + 1 Next 'objFile '==Usage variables Dim intMaxImgPerPage: intMaxImgPerPage = MAX_ROWS * MAX_COLS Dim intPages: intPages = intFileCount / intMaxImgPerPage: intPages = Int(intPages) Dim strPage: strPage = Request.QueryString("Page") %> Photo Gallery Browser

Photo Gallery

<% '--Row/Col Iteration variables Dim intRowIterator, intColIterator '--Image Iterator Dim intImgIterator If strPage = "0" Then intImgIterator = 0 Else intImgIterator = strPage * intMaxImgPerPage End If For intColIterator = 1 To MAX_COLS '--Begin table row Response.Write "" For intRowIterator = 1 To MAX_ROWS Response.Write "" If intRowIterator < MAX_ROWS Then intImgIterator = intImgIterator + 1 End If Next '--End table row Response.Write "" If intColIterator =< MAX_COLS Then intImgIterator = intImgIterator + 1 End If Next %>
" If intImgIterator > UBound(objDynArray.DataArray) Then Response.Write " " Else Dim aintImageParams If HAVE_IMAGE_SIZE_COMPONENT = 1 Then '==Run ReturnImageSize Function to get height and width aintImageParams = ReturnImageSize(strImgDir & "\" & _ objDynArray.Data(intImgIterator)) End If If strThumbDir <> "" Then Response.Write "" Else Response.Write "" End If End If End If Response.Write "

<% '==Paging For intIterator = 0 To intPages Response.Write "[" & intIterator & "]" If intIterator <> intPages Then Response.Write " " End If Next %>
<% '==Free objects Set objDynArray = Nothing Set objFolder = Nothing Set objFSO = Nothing %>