VoiceGuide IVR Software Main Page
Jump to content

Include External Vgs Into Current Vgs->Vbs Module

Recommended Posts

How can I call an external VGS script containing "insert" logic into the current VGS and VBS module?

Share this post


Link to post

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

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

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

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

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
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

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
×