Forum Moderators: open
I already created a little routine that changes the block by the day of the week - I store seven blocks in an array and choose the one for the appropriate day. Instead, though, I'd like to use the semi-random approach outlined above.
My first thought is to choose some unchanging file property and base the choice on that.
Any ideas on the most efficient way to do this?
This ensures, no matter how many things you pick randomly, you'll always get the same ones for the same url.
SN
Function CheckSum(strText)
Dim iabyte
Dim lngHash
lngHash = 4444 'random seed
For iabyte = 1 To Len(strText)
lngHash = CLng(lngHash And &H3FFFFF) * 33 + Asc(Mid(strText, iabyte, 1))
Next
CheckSum = lngHash
End Function
Then I'd just take the result from that, mod the number of pages you have to pick from, say you have 14 pages to pick from:
lngPage = CheckSum(Request.ServerVariables("PATH_INFO")) mod 14
lngPage will then have a value between 0 and 13, that is entirely fixed, but essentially random, as long as you don't change the local path of the page. You can use that as part of the filename or a lookup into an array to get the filename of the file you want to insert.