IVR Program Listing (1/96)
The following program listing pertains to the DBMS January 1996 article "DBMS-Oriented Interactive Voice Response, Part 2" by P. L. Olympia, Ph. D. (The language used is Microsoft FoxPro.)
* From:
* DBMS-Oriented Interactive Voice Response, Part 2
* P. L. Olympia, Ph. D., DBMS, January 1996, page 55
* Copyright (C) 1996 Miller Freeman, Inc.
* Listing 1. Code Fragment from Time & Attendance Interactive Voice Response Application
*-- Code Fragment from T&A IVR using VoysAccess Toolkit
*-- by p.o.
SET LIBR TO voysaccf ADDI && Load the API library
*-- Define where the app prompts go
* gcDefDir is the default directory
nRet = VSet("AppPrompts", gcDefDir+"\prompts")
*-- Put code here to ensure all required prompts can be found
*-- Required .VOX (prompt) files are Bye, Hello, GiveMeID,TryAgain,LvMsg,GoForIt
DO WHILE .t.
*-- Wait for ring, pick up after 1 ring
* timeout (nRet=-1) after 10 secs
nRet = -1
DO WHILE nRet < 0 && if 0, picked up phone
nRet = VWaitRing(1,10)
ENDDO
*-- Process the call
DO ProcCall
*-- If caller still on, say Bye, hangup, and recycle
IF VChkHangup() = 0
nRet = VSpeak("Bye")
ENDIF
nRet = VHangup()
ENDDO && while .t.
RELE LIBR voysaccf && Release library
RETURN
PROCEDURE ProcCall
gcEmpID = ""
lcLvMsg = "2"
nRet = VSpeak("Hello") && Tell caller who you are
FOR lnTry = 1 TO gnMaxTry && gnMaxTry is max # tries
IF VChkHangup() = 1 && he hung up
RETURN
ENDI
nRet = VSpeak("GiveMeID")
nRet = VGetTones(@gcEmpID,5," ",10) && get 5-digit ID
IF nRet < 0 && caller is brain-dead
RETURN
ENDIF
IF SEEK(gcEmpID, "Emps") && Valid caller
EXIT
ENDIF
IF lnTry < gnMaxTry
nRet = VSpeak("TryAgain")
ELSE
RETURN
ENDIF
NEXT lnTry
*-- Here, go to a big loop. Prompt caller for Job Number
* and hours expended. Continue until caller inputs JobNo
* of 0. If Hours > 9, last digit is fractional hour.
* Update the Hours table based on user input
*-------------------------------
* Code omitted
*-------------------------------
*-- Finally ask if caller wants to leave a msg
nRet = VSpeak("LvMsg") && Say wanna leave msg?
IF VGetTones(@lcLvMsg,1) = "1"
nRet = VSpeak("GoForIt") && Say start msg now
CREA CURS temp (mvoice M)
APPE blan
IF nRet = VRecord("mvoice") = 0
REPL Emps.VoxMsg WITH temp.mvoice
ENDIF
USE IN temp
ENDIF
RETURN