VoiceGuide IVR Software Main Page
Jump to content

Vbscript Includes

Recommended Posts

Support Team,

 

Does the VBS module support VBScript includes?

I wrote a vbs class and saved it in an external file.

How can I include this file into a VBS module?

 

Thanks in advance.

Share this post


Link to post

In WSH, the "easiest" is to just write a function called "Include()" which has the following code:

 

Sub Include(cNameScript)

 Dim oFS, oFile, sCwd

 sCwd = Left(Wscript.ScriptFullName, InStrRev(Wscript.ScriptFullName , "\"))
 Set oFS = CreateObject("Scripting.Filesystemobject")
 Set oFile = oFS.OpenTextFile(sCwd & cNameScript)
 ExecuteGlobal oFile.ReadAll()
 oFile.Close

 Set oFile = Nothing
 Set oFS = Nothing

End Sub

 

Call Include with the path/name to your script and it will execute it

in the currently-running script's namespace, loading any classes etc.

 

There are several other ways. See:

 

http://groups.google.com/groups?selm=3E479EC6.6EFB4ADE%40hydro.com

Share this post


Link to post

Thanks for your reply.

 

I tried the 2nd method from the page that you provided, but VoiceGuide seems to be rejecting the script tag.

 

Could you provide an example of how I can include scripts within a VBS module using script tags?

 

I believe that this would be the most effective method because, if successful, it will require the fewest lines of code.

 

Thanks.

Share this post


Link to post

I think that the example that you are referring to was intended for ASP based implementations.

 

For Run VB Script modules - which basically run the VB Script function in the same way as using the Wscript interpreter - the recommended way is using the "Include()" function as described before.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×