VoiceGuide IVR Software Main Page
Jump to content

If Then Else

Recommended Posts

I wish to write a statement via built in module or VbScript that uses a result variable from a previous module, Say $RV[sampleModule] as a play file module and I want to use the result of the if, then statement in a query. I was trying to do a VbScript module named GetDescription like....

Dim ItemKey

Dim Choice

Choice=$RV[sampleModule]

If Choice=1 then

ItemKey=1359

else

if Choice=2 then

ItemKey=1360

else

if Choice=3 then

ItemKey=1500

else ItemKey=0

end if

end if

end if

set vg = CreateObject("VoiceGuide.CommandLink")

vg.RvSet $RV_LINEID, "ItemKey", ItemKey

set vg = Nothing '

Then reference the result in a query module like so....

SELECT Description FROM ItemDesc WHERE Key=$RV[itemKey]

I may be far off base with the way I am approaching this, I there is a better way feel free to suggest it or point me to a location in which I can find my answer.

Thank you

Share this post


Link to post

From looking at it, it all seems spot on. The script should work just the way you wrote it.

 

Have you tried it in VG yet?

Share this post


Link to post

When I run this in VG when it hits thre VBScript it takes the fail path.

At level 0 this is the only error I receive.

091324.32 1 ERROR 6.0.2028 TW__LineEvCallState_Error:Subscript out of range

091346.74 1 ERROR 6.0.2028 TW__LineEvCallState_Error:Subscript out of range

Share this post


Link to post

Is the VBScript returning an explicit 'Success' result or RV list to VG?

 

If you are still haveing problems please increase level to 8 or higher and post trace and the VG script itself.

Share this post


Link to post

This is the log at level 8 around the VbScript

 

100534.04 1 event TDX_PLAY, code=129, state=6001

100534.04 1 timer clear

100534.04 1 state [GetItemKey] Running VB Script...

100534.04 1 rv replace start: [Dim ItemKey

Dim Choice

Choice=$RV[ProductChoice]

If Choice=1 then

ItemKey=1359

else

if Choice=2 then

ItemKey=1360

else

if Choice=3 then

ItemKey=1500

else ItemKey=0

end if

end if

end if

]

100534.05 1 vbs ran [vbs_1_1.vbs], cmd [wscript "C:\Program Files\VoiceGuide\data\vbs_1_1.vbs" //I //T:60]

100534.07 1 Run Script waiting. iRunWait=1 (shellid=2396, process=6212)

100534.07 1 timer set 1 EV_TIMEOUT_CHECKONSTATE

100535.07 1 event EV_TIMEOUT_CHECKONSTATE, code=9007, state=1501

100535.07 1 LsRunWaitTillFinished EV_TIMEOUT_CHECKONSTATE

100535.07 1 task completed (shellid=2396, process=6212) vgm=29, iRunWait=1, iRunWait_ExeResult_NextVgm=0

100535.07 1 no result file returned from program (VGRUNRESULT_1.TXT or SHLRESLT.TXT)

100535.07 1 task completed LsRunWaitChooseNext iNextVgm=12

100535.08 1 fn RunModule start

100535.08 1 timer clear

Share this post


Link to post

The VBScript is not returning an explicit 'Success' result or RV list to VG...

 

From: http://www.voiceguide.com/vghelp/html/modVbs.htm

A "Success" or Result Variable list must be returned to VoiceGuide (either though a Run_ResultReturn COM function or a Result File) in order for it to go down the Success path.

If no result is returned then the "Fail" path is taken after the VBScript completes.

Calls to Script_Gosub(), Script_Goto() and Script_Return() functions result in immediate running of the next module.

Share this post


Link to post

I used:

Dim Key

Dim Choice

Choice=$RV[ProductChoice]

If Choice=1 then

Key="1300"

else

if Choice=2 then

Key="1500"

else

if Choice=3 then

Key="1600"

else Key=0

end if

end if

end if

set vg = CreateObject("VoiceGuide.CommandLink")

vg.Run_ResultReturn $RV_LINEID, "[itemKey]{Key}"

set vg = Nothing

 

 

And it returned Key as the result variable not the 'value of Key. Is there anyway to fix that?

Share this post


Link to post

Change:

vg.Run_ResultReturn $RV_LINEID, "[itemKey]{Key}"

to:

vg.Run_ResultReturn $RV_LINEID, "[itemKey]{" & Key & "}"

 

You have to "build" the string by patching in the variable value.

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
×