VoiceGuide IVR Software Main Page
Jump to content

If Statement In Vb Script

Recommended Posts

Can you/how do you do the following using a VBscript in VoiceGuide to do the following,

 

A user keys in a 4 digit number

If number entered is between 1000 and 1999 goto module x,

If number entered is between 2000 and 2999 goto module y,

 

On going to the module will vb script terminate?

 

What syntax do you use for the goto line?

How do you define the success path? if 1003 entered then success path module x followed, if 2003 entered then success path module y followed, can you define multiple success paths in the paths tab of the module definition?

 

Thanks in advance

Share this post


Link to post

Say the Get Numbers module in which the caller enters the 4 digit number is called GetSomeCode

 

The VBScript can be done something like this:

 

set vg = CreateObject("vgServices.CommandLink")

 

if $RV[GetSomeCode] >= 1000 and $RV[GetSomeCode] <= 1999 then

vg.Script_Goto $RV_LINEID, "", "Module1000", ""

end if

 

if $RV[GetSomeCode] >= 2000 and $RV[GetSomeCode] <= 2999 then

vg.Script_Goto $RV_LINEID, "", "Module2000", ""

end if

 

set vg = Nothing

 

On going to the module will vb script terminate?

The VBScript will complete normally, but VoiceGuide will start executing next module immediately.

 

if 1003 entered then success path module x followed, if 2003 entered then success path module y followed

For specific entries use paths like these in the GetSomeCode module:

 

on {1003} goto [x]

on {2003} goto [y]

 

Please post if you have any further questions.

Share this post


Link to post

Thank you for the reply.

 

The VBS module has three tabs

Run VBScript Tab

Play Tab

Paths Tab

 

The goto statements in the vbscript will cause the script to go to the appropriate module, but what paths do I need to define in the Paths Tab or do I need to define any as the goto statements will take care of this?

 

 

Share this post


Link to post

The Script_Goto statement sends an instruction direct to VoiceGuide to goto another module. Nothing extra needs to be defined in Paths tab or anywhere else to make the Script_Goto command to work.

Share this post


Link to post

I am having some trouble getting my if statement to work, it works OK outside of Voiceguide,

 

I have attached a log file for you to look at.

 

Thanks

ifstatement.txt

Share this post


Link to post

Please attach the VoiceGuide script itself.

 

You can use the Admin_TraceLogAdd COM command to trace the VBScript execution. This will let you debug how any VBScript progresses as Admin_TraceLogAdd adds log entries to vgEngine file.

Share this post


Link to post

The VBScript in your VBScript modules is quite long. It's best to start of with a small subset of code and add to it and see at which stage the problem occurs. Using Admin_TraceLogAdd would also help to pinpoint the line on which the error occurs.

Share this post


Link to post

I have done as you have suggested reduced the size of my VBScript but I am still having problems, I have added trace logs to the script, when I run the script

I don't even get to see these in the log file. :wub:

 

I have attached a log file and a script with the VBScript included, any pointer in the right direction will be much appreciated. :rolleyes:

280708ifprob.txt

ifscript.vgs

Share this post


Link to post

Try changing the VBScript in the module [Test Parent Code] to something basic like:

 

Set vg = CreateObject("vgServices.CommandLink")

vg.Admin_TraceLogAdd 0, 0, "**** vgServices.CommandLink completed"

Set vg=Nothing

 

And then slowly add to that.

 

Also, you are trying to use a Excel spreadsheet as a database - scanning though spreadsheet cells to find a match.

 

Suggest you just switch to using a database, Excel is not the right tool for database lookup type operations.

Share this post


Link to post

I have done as you have suggested, I have written another script which tests the input from a user.

 

I add the admin trace logs as suggested, when I view the log files I can see the admin trace logs until I insert the if statement, then I can't see any comlg lines in the log file.

 

I have changed the vg.Script goto to statement from

 

vg.Script_Goto $RV_LINEID,"","module name", ""

 

to

 

vg.Script_Goto $RV_LINEID,"module name"

 

but this does not make any difference.

 

I have attached the log files for a few runs, first log file you can see the comlg lines, and also the vgs script that I am trying to test.

 

Thanks

290708ifprob.txt

ifproblem.vgs

Share this post


Link to post

If the problem occurs when you add the "IF" statement then maybe you could try this:

 

If (($RV[GetSomeCode] >= 1000) And ($RV[GetSomeCode] <= 1999)) Then

vg.Script_Goto $RV_LINEID, "", "Module1000", ""

end if

 

If (($RV[GetSomeCode] >= 2000) And ($RV[GetSomeCode] <= 2999)) Then

vg.Script_Goto $RV_LINEID, "", "Module2000", ""

end if

 

or this:

 

If ($RV[GetSomeCode] >= 1000) Then

If ($RV[GetSomeCode] <= 1999) Then

vg.Script_Goto $RV_LINEID, "", "Module1000", ""

end if

end if

 

If ($RV[GetSomeCode] >= 2000) Then

If ($RV[GetSomeCode] <= 2999) Then

vg.Script_Goto $RV_LINEID, "", "Module2000", ""

end if

end if

Share this post


Link to post

To debug the VBScripts you should look at the VBScript file that VoiceGuide creates from the "Run VBScript" module. The trace file will show you the file to look at, eg:

 

215519.187 9 1 state [Test Parent Code] type: VB Script, iRunWait=1

215519.187 9 1 rv replace start (strlen>500)

...

215519.203 9 1 script will be ran from file: C:\Program Files\VoiceGuide\temp\vbs_1_1.vbs

 

Try double clicking on that file (C:\Program Files\VoiceGuide\temp\vbs_1_1.vbs) from above trace and if there is a problems with it then you should see the error message box appear telling you on which line the problem is occurring. You can then debug the VBScript and see what changes are necessary to make it work.

 

The vbs_1_1.vbs file is just the script from the "Run VBScript" module with all of the $RVs replaced by their actual values.

Share this post


Link to post

Found the problem, no space in "endif", when space inserted "end if" worked fine

 

Thanks for the help

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
×