473,372 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Conditional Includes

Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas
Jul 19 '05 #1
10 6313
your IF is weird but the premise is correct
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #2
Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in a
subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #3
Yes, it will work, assuming you start and end your ASP blocks
correctly -- though probably not in the way you expect. Both files will
be included, but only the one that matches the condition will be used.

"Thomas" <th****@corpuslogic.com> wrote in message
news:#o*************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #4
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in a
subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas


Jul 19 '05 #5
No. The processor would convert it to
If True Then
response.write "Hello 1"
Else
response.write "Hello 2"
end if

which would result in
Hello 1

So, it basically does what you want (presumably) but you can run into
conflicts.
If test1.asp contains
Dim x
x=1
and test2.asp contains
Dim x
x=2
then you've "redimmed" and will get an error. However, if they are in
subroutines, the scope of x is within the subroutine so you won't have a
conflict.
"Thomas" <th****@corpuslogic.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in

a subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas



Jul 19 '05 #6
No the reult will alwasy be

Hello 1

doing

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

If True Then
response.write "Hello 1"
Else
response.write "Hello 2"
End If

is exactly the same as doing

"Thomas" <th****@corpuslogic.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in

a subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas



Jul 19 '05 #7
http://www.aspfaq.com/show.asp?id=2042
"TomB" <sh*****@hotmailXXX.com> wrote in message
news:uM**************@TK2MSFTNGP11.phx.gbl...
No. The processor would convert it to
If True Then
response.write "Hello 1"
Else
response.write "Hello 2"
end if

which would result in
Hello 1

So, it basically does what you want (presumably) but you can run into
conflicts.
If test1.asp contains
Dim x
x=1
and test2.asp contains
Dim x
x=2
then you've "redimmed" and will get an error. However, if they are in
subroutines, the scope of x is within the subroutine so you won't have a
conflict.
"Thomas" <th****@corpuslogic.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
> If True Then
> <!-- #include file="test1.asp" -->
> Else
> <!-- #include file="test2.asp" -->
> End If
>
will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Yes and no.
The include files are processed first, so the contents of test1.asp and test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp
in a subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> Will this work in asp 3.0:
>
> If True Then
> <!-- #include file="test1.asp" -->
> Else
> <!-- #include file="test2.asp" -->
> End If
>
> - Thomas
>
>



Jul 19 '05 #8
in my routines this runs well like:
<%
if Session("logado") <> "sim" then
'Rotina de verificação de sessão do usuário só funciona dentro das
tags<body></body>
%>
<!--#include file="controle_sessao.asp" -->
<%End If%>
bye

--

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
"Thomas" <th****@corpuslogic.com> escreveu na mensagem
news:#o*************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #9
On Fri, 16 Jan 2004 13:44:16 -0200, "Vilmar Brazão de Oliveira" <te***@teste.teste.teste> wrote:
in my routines this runs well like:
<%
if Session("logado") <> "sim" then
'Rotina de verificação de sessão do usuário só funciona dentro das
tags<body></body>
%>
<!--#include file="controle_sessao.asp" -->
<%End If%>
bye


What most of the responses want to emphasise is that, even though the logic will work and only the 'correct' page will
be displayed, all of the includes will be read and processed before anything else happens...If those pages are large
and/or contain lots of processor intensive or memory heavy stuff, you can run into real resource depletion problems.

The faq citation from Tom B :
http://www.aspfaq.com/show.asp?id=2042

has, at the end, a discussion of using Server.Execute - It will help, if it can be employed in your situation.

hth

Jul 19 '05 #10

If the content in test1.asp and test2.asp are not dependent on the
rest of the page ... I would consider Server.Execute in your if/then
... that way the entire pages code from the files won't be pulled in
... only what is executed.


On Fri, 16 Jan 2004 09:43:10 -0500, "Thomas" <th****@corpuslogic.com>
wrote:
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas


I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

Brynn
www.coolpier.com
Jul 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: David Winter | last post by:
(Sorry - couldn't find a generic DocBook NG - I hope this is close enough.) I'm considering moving my documentation and translation business - which is currently done in proprietary formats such...
11
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
2
by: Wesley | last post by:
HELP, Could anyone help me with this one. I am building query that includes postall addresses, I would like to be able to include calculated control "REGION" which would disply either "CITY"...
5
by: jodyblau | last post by:
I am trying to do some conditional formatting with a textbox and I am not able to quite get it. Here is the setup: My record includes a textbox called and two checkboxes the first called ...
4
by: kj | last post by:
I have a dynamically generated HTML document that includes a table of numbers. In this table, I want every number greater than some numerical parameter MAX_VAL (also dynamically generated) to be...
10
by: Dave | last post by:
I'm a C++ programmer of many years, trying to get my feet wet in C#. I have a question about conditional compilation. In C++, I would sometimes define a constant in an include file, and then...
36
by: anon.asdf | last post by:
Hello! Can the proprocessor make conditional decisions. Here's an example of the functionality (not standard C!) #define PUT_BYTE(const_index, val) \ #preprocessor_if (const_index ==...
1
by: barcaroller | last post by:
I was looking at some code that uses fstream: #include <fstream> // // which includes: // istream& getline( char* buffer, streamsize num ); // ifstream fin;
4
by: rocketeer | last post by:
I've a set of Javascript classes that maintain state. For example, gm.js might be: var GroupManager { groups: {} }; Over time I add new groups to the list: GroupManager.groups = myGroup; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.