Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Phone Dialer Example

Keywords: phone dialer 

Here's some example code to dial a phone number. This WBT file implements a phone dialer with WIL language statements. The phone numbers are kept in the FONEBOOK.TXT file. It is simply a text file with name followed by number. This code assumes everything after the last space or tab is part of the phone number. The code also assumes that the COM port has been correctly set up in the PORTS section of the control panel. Mostly be sure the Control Panel ports section has the right baud rate for your modem in it. User initialization section. Set these to correspond to your modem commands. Most users will only have to check the ComPort setting.
;Contents of batch file "phonebk.wbt":

ComPort="COM1"
DialPrefix="ATDT"
HangCommand="ATH0"

; And here we go.  First make a CR/LF and TAB
CR=strcat(num2char(13),num2char(10))
TAB=num2char(9)

; Make sure there is a fonebook.txt file.  If not, create one:
If !FileExist("fonebook.txt") then fp=FileOpen("fonebook.txt","WRITE")
			      then FileWrite(fp,"Wilson WindowWare Order Line 1-800-762-8383")
			      then FileClose(fp)

; Put up the TextBox so the user can choose a number
:NewNum

CancelCmd="Exit"		  ; What to do if user hits "Cancel"
num=StrTrim(TextBox("DIALER - Just hit OK to add a new number","fonebook.txt"))
if num==""  then num=strtrim(AskLine("DIALER","Enter name and number",""))
	    then Terminate(num=="","","")
	    then fp=FileOpen("temp876.num","WRITE")
	    then FileWrite(fp,num)
	    then FileClose(fp)
	    then FileAppend("temp876.num","fonebook.txt")
	    then FileDelete("temp876.num")
	    then goto newnum

a=StrIndex(num," ",0,@BACKSCAN)
b=StrIndex(num,TAB,0,@BACKSCAN)
a=max(a,b)
num=strsub(num,a+1,strlen(num)-a)
DialCommand="%DialPrefix%%NUM%;"

:redial
fp=FileOpen(ComPort,"WRITE")
FileWrite(fp,DialCommand)
FileClose(fp)
CancelCmd="Goto Hang1"

a=AskYesNo("Dialer","Yes=HANGUP%CR%No=REDIAL%CR%Cancel=New Number")
fp=FileOpen(ComPort,"WRITE")
FileWrite(fp,HangCommand)
FileClose(fp)

if a==@YES then exit
Display(30,"Dialer","Redial Wait")
goto redial

:CANCEL
%CancelCmd%

:Hang1
fp=FileOpen(ComPort,"WRITE")
FileWrite(fp,HangCommand)
FileClose(fp)

goto NewNum

Article ID:   W13755
Filename:   Phone Dialer Example.txt