Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Random Include files Request.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Random Include files Request.

 Post Reply Post Reply
Author
rahimi View Drop Down
Groupie
Groupie
Avatar

Joined: 12 January 2004
Location: Iran
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote rahimi Quote  Post ReplyReply Direct Link To This Post Topic: Random Include files Request.
    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.

Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post 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..
Back to Top
rahimi View Drop Down
Groupie
Groupie
Avatar

Joined: 12 January 2004
Location: Iran
Status: Offline
Points: 53
Post Options Post Options   Thanks (0) Thanks(0)   Quote rahimi Quote  Post ReplyReply Direct Link To This Post 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 %>

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
validweb View Drop Down
Newbie
Newbie


Joined: 09 April 2004
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote validweb Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 08 May 2004 at 5:04am
if there are much data int he include files, your host wont be happy if using it
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.