vgnewb1 Report post Posted 05/17/2012 09:32 PM How can I call an external VGS script containing "insert" logic into the current VGS and VBS module? Share this post Link to post
SupportTeam Report post Posted 05/17/2012 10:19 PM External VGS scripts can be called by using a "goto" or a "gosub" path. Any Result Variables created by the called subscript are visible to the calling script when the subscript returns. Is this what you require? Can you describe in more detail what you are trying to achieve? We can then better advise an appropriate approach/solution. Share this post Link to post
vgnewb1 Report post Posted 05/18/2012 09:35 PM Yes. I am attempting to "insert" whenever a user reaches a specific module. The subscript reference within the calling script will execute the insert, then continue on its way. A similar post explains including a VBS class, http://voiceguide.com/forums/index.php?showtopic=1106, which is not exactly applicable to call an external VGS VBS module. Share this post Link to post
SupportTeam Report post Posted 05/18/2012 10:57 PM Can you describe in mode detail what you mean by "insert"? Can you may be post your current script and a detailed description of what you are trying to achieve? Share this post Link to post
SupportTeam Report post Posted 05/19/2012 12:49 AM If you have some VBScript functions which you would like to include in every Run VBScript module then you can read the code into your current VBSCript using this approach: strPath = "$RV[scriptsPath]" & "inc\myVbsCode.vbs" ExecuteGlobal CreateObject("Scripting.FileSystemObject").OpenTextFile(strPath).ReadAll Share this post Link to post
SupportTeam Report post Posted 05/19/2012 01:02 AM from http://stackoverflow.com/questions/316166/how-do-i-include-a-common-file-in-vbscript-similar-to-c-include : You can create a (relatively) small function in each file that you want to include other files into, as follows: sub includeFile (fSpec) dim fileSys, file, fileData set fileSys = createObject ("Scripting.FileSystemObject") set file = fileSys.openTextFile (fSpec) fileData = file.readAll () file.close executeGlobal fileData set file = nothing set fileSys = nothing end sub and then use it to include specific files - these are executed as if they were inline. includeFile "commonapi.vbi" includeFile "dbcalls.vbi" It basically opens the file, reads the entire contents into a string, then executes that string. There's no error handling on the I/O calls since this sort of stuff is usually done once on program start, and you want to fail if there's a problem including it. Share this post Link to post
vgnewb1 Report post Posted 05/21/2012 01:47 PM Thanks for the Stack Overflow reference. I attempted to work the code example without success. Is the implementation correct? sub includeFile (file path) dim fileSys, file, fileData set fileSys = createObject ("Scripting.FileSystemObject") set file = fileSys.openTextFile (file path) fileData = file.readAll () file.close executeGlobal fileData set file = nothing set fileSys = nothing end sub includeFile "file path" To better explain the objective, I've attached screen shots of the VGS script and the referenced script. Let me know if the information is sufficient. Share this post Link to post
SupportTeam Report post Posted 05/24/2012 06:14 AM To better explain the objective, I've attached screen shots of the VGS script and the referenced script. Let me know if the information is sufficient. No screenshot was attached. Can you try attaching the screenshot and the file again? Share this post Link to post