Avaya Logo

Previous Topic

Next Topic

Book Contents

Book Index

Sample script using flow control instructions

The following is an example of a script using the flow control instructions.

#define DECIDE 0
#define COUNTER 2
INTRO:
talk("Welcome to our company")
load(r.1,0) /*initialize loop counter to 0*/

start:
talk("To speak to an operator, enter 1")
talk("To hear your account balance, enter 2")
getinput(ch.DECIDE,1)
case(ch.DECIDE,'1',OPERATOR,continue)
case(ch.DECIDE,'2',ACCT_BAL,continue)
--
--
--

OPERATOR:
talk("Please hold, an operator will be with you shortly")
--
--
(code to dial operator, transfer call)
--
--
(call returns)
rts()

ACCT_BAL:
nwitime(20) /*maximum seconds to wait for host confirmation*/
--
--
(query host)
--
--
talk("Your account balance is")
tnum(int.FIVE,'f')
rts()

continue:
ibrl(COUNTER,r.1,start)
talk("Thank you for calling")
quit()

In this example, the instructions first define DECIDE as 0 and COUNTER as 2. The script then welcomes the caller to the system and initializes r.1 as containing 0. The script asks the caller to enter 1 to talk to an operator or 2 to hear the account balance. The getinput instruction tells the script to wait for one touch tone and store it in ch.DECIDE. The case instructions tell the script that if the caller enters 1, to go to the OPERATOR subroutine, then to the continue code and if the caller enters 2, to go to the ACCT_AL subroutine, then to the continue code. Regardless of what the caller enters, script execution continues with the next instruction.

The OPERATOR subroutine would contain code telling the script to dial out to an operator and transfer the call. (This code is omitted from this example to make it simple, as shown by the use of --). When the caller has finished talking to the operator, the script continues with the next instruction.

The ACCT_BAL subroutine tells the script to wait a maximum of 20 seconds for the host information requested (nwitime instruction). The call to the host is not included here to keep the example simple. After the host has returned the information, the script tells the caller what the account balance is based on the value in the tnum instruction. The script then continues with the next instruction.

The ibrl instruction tells the script to compare COUNTER (which was set at 2 at the beginning of the script) with the value in r.1. If r.1 is less than COUNTER, the script returns to the start code. If r.1 is equal to COUNTER, the script executes the next instruction. The script then thanks the caller for calling and quits, voluntarily ending the transaction.

© 2006 Avaya Inc. All Rights Reserved.