views:

186

answers:

4

I am currently in a situation where I have to make some additions to an application written in classic ASP using server-side JScript on IIS.

The additions that I need to make involve adding a series of includes to the server-side code to extend the application's capabilities. However, the inc files may not exist on the server in all cases, so I need the application to fall back to the existing behavior (ignore the includes) if the files do not exist, rather than generating an error.

I know that this can't be accomplished using if statements in the JScript code because of the way that SSI works, and have not come across any ways of dynamically including the code on the server side, where the files may not exist.

Does anyone know of a way to accomplish this in classic ASP? Any help would be much appreciated.

A: 

Put simply, no. Why would the files not exist? Can you not at least have empty files present?

AnthonyWJones
+1  A: 

If you are really brave, you can read the contents of the file and then Eval() it. But you will have not real indication of line numbers if anything goes wrong in the included code.

As a potentially better alternative: Can you not create some sanity check code in global.asa to create the include files as blanks if they do not exist?

My Other Me
A: 

What you could do is something like this:

  • Use Scripting.FileSystemObject to detect the presence of the files
  • Use Server.Exeecute to "include" the files, or at least execute the code.

The only problem is that the files cannot share normal program scope variables.

thomask
A: 

The solution to this turned out to be to use thomask's suggestion to include the files and to set a session variable with a reference to "me" as per http://www.aspmessageboard.com/showthread.php?t=229532 to allow me to have access to the regular program scope variables.

(I've registered because of this, but can't seem to associate my registered account with my unregistered account)

Brent
You should flag this as the accepted answer =)
ajdams