[thelist] For the ASP Gurus...
lon.kraemer
lwkraemer at earthlink.net
Sun Dec 9 10:56:19 CST 2001
Hi Ken,
If indeed your files are sequentially numbered, all you need to do is create a
random number. You don't need to use FSO.
01.gif - 10.gif
randomize
upperbound=int(rnd*10)+1
upperbound=right("0" & upperbound,2) 'makes 1="01", while 10="10"
session("topGraphic") ="path/" & upperbound & ".gif"
HTH
lonk
> This all executes within global.asa:
>
> I've got 10 graphics in a folder, all named 01.gif - 10.gif.
> I use the FSO to grab one at random and strip off the extension, leaving
> just a number.
> I assign the random number to a session variable.
>
> I use this code to implement a random header graphic on my site. I'm
> doing it this way since I don't want a random header for every page
> load/refresh from every user. I just want every user to get a random one
> for each session they start.
>
> Problem is, every user is getting the same graphic every time.
>
> Here's my global.asa:
>
> -----------------------------------------------------------
> Sub Session_OnStart
>
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
> Set objFolder = objFSO.GetFolder(server.mappath("/images/headers/"))
>
> For Each objFile in objFolder.Files
> upperbound = objFile.name
> Next
>
> upperbound = split(upperbound,".")
>
> session("topGraphic") = Int(Rnd() * cInt(upperBound(0))) + 1
>
> set objFSO = nothing
> set objFolder = nothing
>
> End Sub
> -----------------------------------------------------------
>
> ~Ken K.
More information about the thelist
mailing list