Avatar of Bob3975
Bob3975
Flag 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?  
Web Languages and StandardsASP

Avatar of undefined
Last Comment
Bob3975

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
clockwatcher

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck