Forum Moderators: open
<%
Dim Quote(6)
Quote(0) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#FF4500'> </td></tr></table>"
Quote(1) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#336699'> </td></tr></table>"
Quote(2) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#111111'> </td></tr></table>"
Quote(3) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#556699'> </td></tr></table>"
Quote(4) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#999999'> </td></tr></table>"
Quote(5) = "<table width='90' border='1' cellspacing='0' cellpadding='0'><tr><td bgcolor='#444444'> </td></tr></table>"
QuoteList = ""
NumList = "¦"
Randomize
For x = 0 to 5
'get random number
RndQuote = Int(Rnd * 6)
Do Until Instr(Cstr(NumList),Cstr("¦" & RndQuote & "¦")) = 0
RndQuote = Int(Rnd * 6)
Loop
NumList = NumList & RndQuote & "¦"
QuoteList = QuoteList & Quote(RndQuote) & "¦"
Next
QuoteList = Left(QuoteList,Len(QuoteList)-1)
QuoteArr = Split(QuoteList,"¦")
For x = 0 to UBound(QuoteArr)
Response.Write QuoteArr(x)
Next
%>
<%
Randomize
RandNum = Int(Rnd * 6) + 1
if RandNum = 1 Then %>
<!--#include virtual="/Include/1.asp" -->
<% ElseIf RandNum = 2 Then %>
<!--#include virtual="/Include/2.asp" -->
<% ElseIf RandNum = 3 Then %>
<!--#include virtual="/Include/3.asp" -->
<% ElseIf RandNum = 4 Then %>
<!--#include virtual="/Include/4.asp" -->
<% ElseIf RandNum = 5 Then %>
<!--#include virtual="/Include/5.asp" -->
<% ElseIf RandNum = 6 Then %>
<!--#include virtual="/Include/6.asp" -->
<% End if %>
...
Quote(0) = "<img src=""myimage1.jpg"" ... >"
Quote(1) = "<img src=""myimage2.jpg"" ... >"
...
I don't think you need to use SSI's to achieve this, but you can do if required. Just remember, in ASP all the include files are included before processing starts. HTH
<%
RANDOMIZE
LowestNumber = 1
HighestNumber = 5
RandomNumber = INT((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
SELECT CASE RandomNumber
CASE "1"
%>
<!--#include virtual="/Include/1.asp" -->
<%CASE "2"%>
<!--#include virtual="/Include/2.asp" -->
<%CASE "3"%>
<!--#include virtual="/Include/3.asp" -->
<%CASE "4"%>
<!--#include virtual="/Include/4.asp" -->
<%CASE "5"%>
<!--#include virtual="/Include/5.asp" -->
<%END SELECT %>
<!--#include virtual="/Include/3.asp" -->
<!--#include virtual="/Include/2.asp" -->
<!--#include virtual="/Include/1.asp" -->
<!--#include virtual="/Include/6.asp" -->
<!--#include virtual="/Include/4.asp" -->
<!--#include virtual="/Include/5.asp" -->
and next time
<!--#include virtual="/Include/5.asp" -->
<!--#include virtual="/Include/2.asp" -->
<!--#include virtual="/Include/6.asp" -->
<!--#include virtual="/Include/3.asp" -->
<!--#include virtual="/Include/4.asp" -->
<!--#include virtual="/Include/1.asp" -->
etc
Mattur can you go a little further on what you mean by uinsg filsystemobject?
<%
RANDOMIZE
LowestNumber = 1
HighestNumber = 2
RandomNumber = INT((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
SELECT CASE RandomNumber
CASE "1"
%>
<!-- #include virtual="ads/1.asp" -->
<!-- #include virtual="ads/2.asp" -->
<!-- #include virtual="ads/3.asp" -->
<!-- #include virtual="ads/4.asp" -->
<!-- #include virtual="ads/5.asp" -->
<%CASE "2"%>
<!-- #include virtual="ads/5.asp" -->
<!-- #include virtual="ads/4.asp" -->
<!-- #include virtual="ads/5.asp" -->
<!-- #include virtual="ads/1.asp" -->
<!-- #include virtual="ads/2.asp" -->
etc...
<%END SELECT %>
'---------------------------------------------------
Function GetTextFileContent(strPath)
Const ForReading = 1
Dim fso, fil, txs, varFileContent
'setup filesystemobject and file objects
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fil = fso.GetFile(strPath)
'open textstream
Set txs = fil.OpenAsTextStream(ForReading)
'read file, return null if blank
If Not txs.AtEndOfStream Then
varFileContent = txs.ReadAll
Else
varFileContent = Null
End If
txs.Close
Set txs = Nothing
Set fil = Nothing
Set fso = Nothing
GetTextFileContent = varFileContent
End Function
'---------------------------------------------------
You could use it to read each include file, something like:
Quote(0) = GetTextFileContent(Server.MapPath("/") & "/ads/1.asp")
... etc
You could speed up the script by re-writing the function to loop thru and read each include file and return an array of ads, so you only have instantiate the filesystemobject once.