Avaya Logo

Previous Topic

Next Topic

Book Contents

Book Index

Sample scripts using data manipulation instructions

The following are two sample scripts using the data manipulation instructions as they might be used in an application.

In the following example, the script asks the caller to enter the number of widgets they want to order, and then waits for three touch tones and stores them in ch.QUANTITY. The script then converts the characters in ch.QUANTITY to an integer and stores it in r.1. The script tells the caller how many widgets they ordered based on the integer in r.1. Using the mul instruction and r.1, the script multiplies the integer in r.1 by five (5) to get the total cost of the order. The script then tells the caller the total cost of the order.

MAIN:

talk("Enter the number of widgets you wish to order")
getinput(ch.QUANTITY,3)
atoi(r.1,ch.QUANTITY)
talk("You have ordered")
tnum(r.1) /*spoken as a number, not a string of digits*/
talk("widgets")
talk("at a cost of $5 each for a total cost of")
mul(r.1,5)
tnum(r.1,'f')
talk("dollars.")

In the following example, the script sets the value of r.1 to 0, then asks the caller to enter their password. The script waits for four touch tones, stores them in ch.PASSWORD, then compares ch.PASSWORD with ch.GOOD. If they match, the script continues. If they do not match, as this example illustrates, the script jumps to the retry instructions where it tells the caller that the password is invalid. The script increments r.1 by 1. If r.1 equals 3, the script jumps to the good-bye subroutine. If r.1 is not equal to 3, the script asks the caller to re-enter the password. The script then goes back to the validate subroutine. In this example, the caller can enter an invalid password up to three times before the script terminates in good-bye.

start:
load(r.1,0)
talk("Enter your password.")

validate:
getinput(ch.PASSWORD,4)
strcmp(ch.PASSWORD,ch.GOOD)
jmp(r.0 !=0,retry)
--
--
retry:
talk("I'm sorry, that was an invalid password")
incr(r.1,1)
jmp(r.1 == 3,good-bye)
talk("Please re-enter your password.")
goto(validate)
good-bye:
talk("Goodbye")
quit()

© 2006 Avaya Inc. All Rights Reserved.