2

In C#, I can say

#if DEBUG
    Console.WriteLine("we are in debug mode");
#else
    Console.WriteLine("we are in release mode");
#endif

This is handy for managing things that need to be different between debug and release builds, e.g. connection strings. Is there anything like this available in classic ASP?

user692942
  • 16,398
  • 7
  • 76
  • 175
ekolis
  • 6,270
  • 12
  • 50
  • 101
  • No *(Just set your own `debug` flag)*. Next!... – user692942 Aug 15 '19 at 18:26
  • 1
    there are a number of ways to "inspect" the server name -- that lets you change depending on environment. (eg if localhost output deug info) – Hogan Aug 15 '19 at 18:29
  • @Hogan not really the same thing though is it? – user692942 Aug 15 '19 at 18:34
  • @Lankymart kinda is I think -- debug in C# is defined in the environemnt just like the name – Hogan Aug 15 '19 at 18:35
  • @Hogan kind of, it's just a flag though that is set by the Configuration. – user692942 Aug 15 '19 at 18:36
  • @Lankymart in C# you could use `#if HOGAN_DEBUG` and it would work the same way. the `DEBUG` is just one that by default is set up in the build files – Hogan Aug 15 '19 at 18:37
  • 2
    @Hogan yep, that is true. But like I said Classic ASP doesn't have anything like that. These types of preprocessor directives change the behaviour of the compiler, Classic ASP isn't compiled code. So the closest you can get to it is build a persisted Application variable as a flag. – user692942 Aug 15 '19 at 18:42

1 Answers1

2

The short answer is: No.

But that doesn't mean you can't build your own debug flag then use that. There are various ways to do this using Application or Session variables.

You could then use them something like;

'Application variable should have been set in the global.asa file.
Dim debug: debug = (Application("debug") = True)
If debug Then
  'Output some debug information.
Else
  'Release mode.
End If

Useful Links

user692942
  • 16,398
  • 7
  • 76
  • 175
  • @Hogan not really it's not a preprocessor directive or anything like that. Also, Classic ASP uses VBScript by default which is a scripting language not a compiled one like .Net languages. – user692942 Aug 15 '19 at 18:39
  • Not sure what you are getting at, we are talking about Classic ASP not .Net *(VB.Net, C#, ASP.Net, MVC etc.)*. – user692942 Aug 15 '19 at 18:44
  • @Hogan Not sure what we are arguing about to be honest, think i'll leave it there. Apologies for the confusion. – user692942 Aug 15 '19 at 19:46
  • 1
    Agreed -- you answer is excellent and exactly what is needed IMO – Hogan Aug 15 '19 at 20:00
  • Oh, cool, thanks! Just curious though - what's the colon for in the `Dim` statement? I've never seen that syntax in VB before... – ekolis Aug 16 '19 at 13:38
  • 1
    @ekolis [VBScript, purpose of colon?](//stackoverflow.com/q/1144914) – user692942 Aug 16 '19 at 13:58
  • Oh yeah, thanks, I totally forgot about that silly feature of VB! – ekolis Aug 16 '19 at 14:06