Link to home
Start Free TrialLog in
Avatar of Bob3975
Bob3975Flag for United States of America

asked on

Sharing include files

The asp application in question is written in javascript.  Recently a large block of code was imported into a subdirectory and it's an asp app written in vbscript.  From the javascript app the user clicks a link that targets a seperate page in the imported vbscript code so everything works fine at that stage.

Now I wish to include a function from the vbscript code on a page in the main javascript code.  The timeline goes like this 1) there's a serverside javascript file for the main javascript app which already contains vbscript code at the end under a <SCRIPT LANGUAGE="VBScript" RUNAT="SERVER"> tag, 2) I copied the function needed into that section, 3) of course it calls a function that calls a function that calls ... you get the picture, 4) I start copying these other functions, 5) it becomes obvious that's not going to be very managable.

I'd like to include the vbscript files into my serverside javascript under the <SCRIPT LANGUAGE="VBScript" RUNAT="SERVER"> tag.  There are asp files written in vbscript already used as include files.  The inclusion is written something like...

<%
blah blah blah %>
<!--#include file="functions/functions_code.asp"-->
<%
more blah blah blah

functions/functions_code.asp is written like...
<%
blah blah blah

In the javascript file, the <SCRIPT LANGUAGE="VBScript" RUNAT="SERVER"> looks something like...

...
 js code}
%>
<SCRIPT LANGUAGE="VBScript" RUNAT="SERVER">
Function x(y)
...

Therefore the question becomes, how do I share multiple vbscript include files between the two apps?  When included with vbscript, the enclosing <% and %> tags are needed.  When in the javascript file under the <SCRIPT LANGUAGE="VBScript" RUNAT="SERVER"> tag, these are not wanted.

I started to use the following, thinking I'd write code to strip the <% and %> tags...
------
Include "somecode.vbs"
Sub Include(sCodeFile)
  Dim sCode
  with createobject("scripting.filesystemobject")
    sCode = .OpenTextFile(sCodeFile).ReadAll
  End With
  ExecuteGlobal sCode
End Sub
-----
but stopped short wondering if this was applicable since I had multiple include files.

This has to be easy, right?  How do I share these include files?  
ASKER CERTIFIED SOLUTION
Avatar of clockwatcher
clockwatcher

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bob3975

ASKER

Unfortunately there is some bare code so replacing <% wih <script language="vbscript" runat="server"> causes problems.

I think the question is unanswerable.  At least thanks for trying.