VoiceGuide IVR Software Main Page
Jump to content

Vbscript Module Question

Recommended Posts

I have a Result Variable $RV[subTotal] that has it's value determined in Voiceguide through caller input. I am trying to use a VBScript Module to take that variable and use it to determine the shipping charges which will be added to the customers order.

 

I have tried using both If..then..else statements, and Select Case statements to try and accomplish this, but am having no luck. I've read through the VG help and lots of online tutorials for VBScript but I think I must be messing up the syntax construction of my statements. I've included my script below, could you take a look?

 

--------------------------------------------------------------------

 

Dim ShippingCharge, GrandTotal

 

Select Case $RV[subTotal]

Case <= "14.97"

ShippingCharge = 4.30

Case <= "29.94"

ShippingCharge = 5.35

Case <= "54.89"

ShippingCharge = 7.30

Case <= "84.83"

ShippingCharge = 8.50

Case <= "99.80"

ShippingCharge = 9.75

Case <= "124.75"

ShippingCharge = 10.35

Case <= "149.70"

ShippingCharge = 11.10

Case <= "499.00"

ShippingCharge = 22.30

Case Else

ShippingCharge = 32.70

End Select

 

GrandTotal = ShippingCharge + SubTotal

 

StrResultVariables="[shippingCharge]{" & ShippingCharge & "}" & "[GrandTotal]{" & GrandTotal & "}"

 

IRet = WriteResultFile(strResultVariables)

 

Function WriteResultFile(strResult)

Const ForReading=1, ForWriting=2, ForAppending=8

Dim filename, fso, ts, outdata, outdata2, outdata3

 

Filename = "VGRUNRESULT_8.TXT"

Set fso = CreateObject("Scripting.FileSystemObject")

Set ts = fso.OpenTextFile(filename, ForWriting, True)

Ts.WriteLine(strResult)

Ts.Close

WriteResultFile=0

End function

Share this post


Link to post

A VB Script editor would be usefull

 

I'd suggest getting a book on VB Script...

 

This should work better:

 

iSubTotal = $RV[SubTotal]

if iSubTotal <= 14.97 then
 ShippingCharge = 4.30
else 
 if iSubTotal <= 29.94 then
   ShippingCharge = 5.35
 else 
   if iSubTotal <= 54.89 then
     ShippingCharge = 7.30
   else 
     if iSubTotal <= 84.83 then
       ShippingCharge = 8.50
     else 
       if iSubTotal <= 99.80 then
         ShippingCharge = 9.75
       else 
         if iSubTotal <= 124.75 then
           ShippingCharge = 10.35
         else 
           if iSubTotal <= 149.70 then
             ShippingCharge = 11.10
           else 
             if iSubTotal <= 499.00 then
               ShippingCharge = 22.30
             else
               ShippingCharge = 32.70
             end if
           end if
         end if
       end if
     end if
   end if
 end if
end if

GrandTotal = ShippingCharge + iSubTotal

strResultVariables="[ShippingCharge]{" & ShippingCharge & "}" & "[GrandTotal]{" & GrandTotal & "}"
iRet = WriteResultFile(strResultVariables)
'msgbox strResultVariables



'*****************************************************
' WriteResultFile
'
' Writes results to the file which is then read in
' by VoiceGudie.
' In V5.0 onwards return of information can be done
' though a COM interface.
'
'*****************************************************

Function WriteResultFile(strResult)
 Const ForReading=1, ForWriting=2, ForAppending=8
 Dim filename, fso, ts

 filename = "VGRUNRESULT_$RV_DEVICEID.TXT"
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set ts = fso.OpenTextFile(filename, ForWriting, True)
 ts.WriteLine(strResult)
 ts.Close
 WriteResultFile=0
end function

Share this post


Link to post

Do you guys have any favorite reference books that you use for VBScript and SQL? I'm going to take your advice and buy some books on these subjects so I don't have to waste your time. I thought you'ld probably be the best to ask, before purchasing.

 

Your support is nothing short of fantastic! You post accurate and thorough replies in just a few hours even on a Sunday evening. Your 5.0 beta version, had a few bugs when it was first made available for download (which is to be expected), but the problems were identified and fixed super fast, with what appeared to be daily version updates on your website. Your product and your company are first rate.

 

I have completed an automated phone system for our warehouse in around 8 days. It consists of nearly 80 modules and works flawlessly on a D/4PCI card. I will be buying further Voiceguide licenses and packaging complete phone systems similar to my own to be made available to my nearly 300 distributors and resellers.

 

Thank you.

Share this post


Link to post

A pretty good book on VBScript is:

 

"VBScript in a Nutshell" by Matt Childs, Paul Lomax & Ron Petrusha

ISBN: 1-56592-720-6

 

It's a bit skewed towards using VBScript in web pages, but it covers the syntax and other info pretty well..

 

As for SQL somebody else recommended:

"SQL Queries for Mere Mortals"

by Michael J. Hernandez, John Viescas

ISBN 0201433362

 

 

Thanks for the good comments :)

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
×