Working in ASP classic (not .NET) is frustrating. I really need a define statement akin to the define statements in C, C++. Is this possible?
-
You can always just declare variables. If you're trying to use it for conditional compilation, you can sort of do it like this:
<% If SomeFlagDeclaredEarlier = True Then %> <!-- #include FILE="SomeConditionallyUsedFile.asp" --> <% End If %>And you can use that construct to also define expressions.
AnthonyWJones : ALthough of course the conditional file is still included so you can't use this approach to include mutually exclusive files (for example files which declare the same variable names). -
In an ASP web site its really useful to ensure that all ASP files declare a common include at the top:-
<!-- #include virtual="/globalInclude.asp" -->This is a good place to put variables that you can then use to conditionaly skip stuff, for example you could include this code in the global include:-
class CGlobalDefinitions public Debug end class dim DEFINE : set DEFINE = new CGlobalDefinitions DEFINE.Debug = trueNow everywhere in your ASP code you can use the code:-
if DEFINE.Debug then '' # Do stuff only when debugging is required end ifNote using a class to hold your "DEFINE"s limits the impact creating various such flags on the each pages namespace, you wouldn't want your define to collide with another variable in an ASP page .
0 comments:
Post a Comment