473,405 Members | 2,373 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,405 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 6315
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; ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.