Guest cangracom Report post Posted 02/09/2004 03:47 PM 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
SupportTeam Report post Posted 02/09/2004 08:08 PM 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
Guest cangracom Report post Posted 02/09/2004 09:01 PM 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
SupportTeam Report post Posted 02/09/2004 09:10 PM 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