|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
preventing multiple includes
Is there a way in ASP to prevent including the same file more than once?
Example: dbutil.asp needs constants.asp, so I include constants.asp inside dbutil.asp. transact.asp also needs constants.asp, so I include constants.asp inside transact.asp. transact.asp doesn't need stuff in dbutil.asp, and dbutil.asp doesn't need stuff in transact.asp. Then later I might have a main.asp that needs both dbutil.asp and transact.asp. So I include them both. However, the constants.asp will be found to be included twice! What can I do to creatively prevent multiple inclusion of the same file in ASP? I know how to do it in C and C++, but I can't apply that to ASP, it seems. twice |
|
#2
|
|||
|
|||
|
You could try passing parameters via the querystring, then use if's
so you might have something like the following in your transact.asp and dbutils.asp Code:
<% If Request.QueryString("incfile") = "Yes" Then %>
<!--#include file="constants.asp"-->
<% end if %>
%>
Then in main.asp, you include the three files. so calling transact.asp, would look something like Code:
transact.asp?incfile=Yes I haven't tested this, but I think it should work, hope this helps.
__________________
How can I soar like an eagle when I'm flying with turkey's? |
|
#3
|
|||
|
|||
|
No, that's not what I meant. I am trying to imitate the way C++ and C use the #ifndef/#define/#endif directives to prevent multiple inclusion of a particular file (normally a .h header file) EVEN IF it was included several times by the programmer. In C/C++, you do:
#ifndef __stringutil.h #define __stringutil.h .... .... a bunch of code for string utils here.... .... #endif Note that if a file happens to include the stringutil.h and this is the first time this file is encountered, then because __stringutil.h has not yet been defined, it will (1) define the __stringutil.h and (2) include the code within the file. Then when another file includes stringutil.h, since __stringutil.h has already been defined, the code within the file will not be included. From what I have been reading, I believe ASP does not have any means to do this. Correct me if I am wrong. |
|
#4
|
|||
|
|||
|
Ahhhh, yes, good old C.
It's been a few years since I wrote C stuff. But now I know what you are talking about. I haven't seen anything yet indicating that this sort of thing can be done in ASP. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > preventing multiple includes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|