VoiceGuide IVR Software Main Page
Jump to content

Calling Scripts From Vbs Using Gosub

Recommended Posts

Hi. When I call a script VGS from VBS using the GOSUB function/command, it looks like I can't return back to the calling script at the point the call was made...eg:

' testing out gosub calls
set VG = CreateObject("VoiceGuide.CommandLink")
msgbox "gosub to first sub"
VG.Script_GoSub iLineID, "firstsub.vgs", "", "", "", ""
msgbox "gosub to second sub"
VG.Script_Gosub iLineID, "secondsub.vgs", "", "", "", ""
sRet = vg.Run_ResultReturn( $RV_LINEID, "success" )
Set VG = Nothing
msgbox "done"

When this script is executed, after the first message box, the GOSUB is called, and when it returns the script restarts at the beginning of the current VG Script (as documented). From reading the documentation, you can specify the VGS and Module that should be run after returning, but it won't pick up from where it left off, unless I split this into 2 VBS module blocks, like this:

VBS1

' testing out gosub calls
set VG = CreateObject("VoiceGuide.CommandLink")
msgbox "gosub to first sub"
VG.Script_GoSub iLineID, "firstsub.vgs", "", "", "", "VBS2"
sRet = vg.Run_ResultReturn( $RV_LINEID, "success" )
Set VG = Nothing
msgbox "done1"

VBS2

' testing out gosub calls
set VG = CreateObject("VoiceGuide.CommandLink")
msgbox "gosub to second sub"
VG.Script_Gosub iLineID, "secondsub.vgs", "", "", "", ""
sRet = vg.Run_ResultReturn( $RV_LINEID, "success" )
Set VG = Nothing
msgbox "done2"

This looks pretty inefficient, and if you have to make several calls, very complicated. Have I got this right? Is GOSUB not really a gosub, but a one module calling another at the MODULE level?

 

Or is there another way to do this?

Thx.

Share this post


Link to post
From reading the documentation, you can specify the VGS and Module that should be run after returning, but it won't pick up from where it left off, unless I split this into 2 VBS module blocks,

Correct.

Execution has to start at a module - not someway through a VBScript within the module.

Is GOSUB not really a gosub, but a one module calling another at the MODULE level?

Correct.

It's an immediate branch to the module.

Don't allow multiple Gosubs/Gotos to be in the same execution path in a VBScript Module - VG will not guarantee which module you'll wind up in...

 

If you want to call multiple subscripts one after another the you will need to do this from separate modules.

 

Another solution is to have an external control program which monitors events and module transitions on each line and issues the GOTOs and GOSUBs to VG...

Share this post


Link to post

Thanks for confirmation. I suppose by external program, you mean, call and control VG via the com component completely.

Share this post


Link to post
by external program, you mean, call and control VG via the com component completely.

Yes. Basically have another program monitor what is happening on each line and the issue COM commands to jump to different scripts as needed.

 

It's possible to do things like that but we've never had to resort to doing anything along those lines. Usually there is a way just putting the solution together within VG Scripts themselves.

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
×