Print Page | Close Window

Random Include files Request.

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10094
Printed Date: 31 March 2026 at 4:33pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Random Include files Request.
Posted By: rahimi
Subject: Random Include files Request.
Date Posted: 22 April 2004 at 3:41am

Hello

I Need Random Asp Script to Chanche Randomize Include Files to My index.asp Site.  i need change include.asp include1.asp include3.asp and ....

Please Help Me.




Replies:
Posted By: Phat
Date Posted: 22 April 2004 at 6:59am
You  will need to use Server.Execute as includes are all included.

Do something like

Select Case IncNumber
   
    Case 1
        server.execute "thefile1.asp"
    Case 2
        server.execute "thefile2.asp"
    Case 3
        server.execute "thefile3.asp"

End Select



Posted By: Semikolon
Date Posted: 22 April 2004 at 9:55am
random includes is not possible, as the including is preprocessing (it is done before the ASP code is processed)

but one alternative method is the server.execute method, but that doesn't include the code in the file it executes, it just processes the code and insert the output into the page. so all variables and constants, database connections, include files etc, will not be transferred from the executing page to the executed page and vice versa. you can look at it in a way like an Inline Frame, just without the scrollers..


Posted By: rahimi
Date Posted: 23 April 2004 at 10:47pm

Hello

Thanks for Reply My Qustion.

i Search to Web for THis Qustion and Find this code :

<%
Randomize Timer

rnum = int(rnd*100)

if rnum > 94 and rnum <= 97 then
%>
 

<% elseif rnum > 97 then %>

<!--#include file="File_Inc" -->

<% elseif rnum =< 47 then %>
<!--#include file="File_Inc-1" -->
<% elseif rnum > 47 then %>
<!--#include file="File_inc-2.asp" -->

<% end if %>



Posted By: dpyers
Date Posted: 24 April 2004 at 12:01am

You're doing it the hard way. Try...


Dim iRndNumber
Randomize
iRndNumber = Int(Rnd*3)+1 ' (where 3 is the total number of files to pick from)

Select Case iRndNumber
    Case 1
        server.execute "thefile1.asp"
    Case 2
        server.execute "thefile2.asp"
    Case 3
        server.execute "thefile3.asp"
   Case ELSE
        server.execute "SomeDefault.asp"
End Select

If you use Includes instead of server.execute, you would code it like this...

<%
Dim iRndNumber
Randomize
iRndNumber = Int(Rnd*3)+1 ' Number of files (where 3 is the total number of files)

Select Case iRndNumber
    Case 1 %>
     <!--#include file="testfile1.inc"-->
    <% Case 2 %>
     <!--#include file="testfile2.inc"-->
    <% Case 3 %>
        <!--#include file="testfile3.inc"-->
 <% Case ELSE %>
        <!--#include file="SomeDefault.inc"-->
<% End Select
%>

Select Case is many times faster than If statements.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: validweb
Date Posted: 07 May 2004 at 7:37pm
I would advise using the include, not server.execute as the includes keeped the variables from the file you want to include, as server.execute only does the script, no variables a carried over.


Posted By: Semikolon
Date Posted: 08 May 2004 at 5:04am
if there are much data int he include files, your host wont be happy if using it



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net