allhandlesareused
Technical User
First of all I want to thank many people who contributed to this forum - I've gained quite a bit of insight to perform many different functions. From the code attached you can see I checked a few past postings, but I couldn't find good examples how to branch the code based on different results. I first started in a very linear fashion - but based on examples in the forums, I used the "Target" method to accomplish what I needed.
The script reads a text file of extensions and makes the same change to each one. My problem is that I need to handle different results, like entries that don't exist ("Cannot find this form", and multiple lined entries (It will list "Extension [" multiple times.) Could someone show me how to handle this in a more logical manner? Possibly even two different ways to handle it? I can't seem to get my head around the code.
I have two examples...
Here is my original Linear method with comments where I have the problems:
-----------------start example 1---------------------
-----------------end example 1-----------------------
Here is the working result using the Target method:
-----------------start example 2----------------------
-----------------end example 2-----------------------------
The script reads a text file of extensions and makes the same change to each one. My problem is that I need to handle different results, like entries that don't exist ("Cannot find this form", and multiple lined entries (It will list "Extension [" multiple times.) Could someone show me how to handle this in a more logical manner? Possibly even two different ways to handle it? I can't seem to get my head around the code.
I have two examples...
Here is my original Linear method with comments where I have the problems:
-----------------start example 1---------------------
Code:
waitfor "Subscriber Name or Extension: "
; type exten number from file ---------
transmit s1
transmit "^M"
; At this point I have to check if the mailbox exists...
; look for "Cannot find this form"
; start again if it shows - continue if it doesn't.
waitfor "Name (last first) :"
transmit "^M"
waitfor "Class Number :"
transmit "^M"
waitfor "Extension [1]"
transmit "^M"
waitfor "Extension [2]"
transmit "^M"
; At this pont I need to make sure no other extensions exist for the system.
; look for "Extension [3]"
; keep hitting enter until I get the line: ""PhoneMail Password :"
waitfor "PhoneMail Password : (Previous = ##########): "
transmit "^M"
waitfor "Group Name :"
transmit "^M"
waitfor "Referral Extension :"
transmit "^M"
waitfor "Volume Level :"
transmit "^M"
waitfor "Speed level :"
transmit "^M"
waitfor " Enter T or F for each field): "
transmit "T T T^M"
waitfor "Abbreviated Prompts?: "
transmit ";^M" ; Done with this record
Here is the working result using the Target method:
-----------------start example 2----------------------
Code:
integer flag=0
string sEnter = "^M"
string Fname = "file.txt" ; File name to be opened.
integer nJumps
string sLine
string sTok1
proc main
when Target 0 "Extension [" call Press_Enter
when Target 1 "Name (last first) :" call Press_Enter
when Target 2 "Class Number :" call Press_Enter
When Target 3 " Enter T or F for each field): " call Announce
When Target 4 "Group Name :" call Press_Enter
When Target 5 "Referral Extension : " call Press_Enter
When Target 6 "Volume Level : " call Press_Enter
When Target 7 "Speed level : " call Press_Enter
When Target 8 "Abbreviated Prompts?: " call Exit_MailBox
When Target 9 "Cannot find this form." call Press_Next
When Target 10 "PhoneMail Password :" call Press_Enter
; set txpace=100
if fopen 0 fname READ TEXT ; Open file for read only.
; dial the number
; log into the system -------
while not feof 0 ; Loop while not end of file.
setjmp 0 nJumps ; This is a Jump Mark Point
fgets 0 sLine ; Get line from file.
strtok sTok1 sLine " " 1 ; Assigns Text in First Field (From Text
File) to Variable sTok1.
strreplace sLine " " ""
; Debug message possibly here... check variable after string replace.
waitfor "Subscriber Name or Extension: " 10
transmit sTok1 ; Sends the Text Value (Assigned to
Variable sTok1) to the PhoneMail System.
transmit "^M"
if waitfor "Function: "
transmit "PROFILE^M"
waitfor "Action: "
transmit "MODIFY^M"
waitfor "Subscriber Name or Extension: "
transmit sTok1 ; Sends the Text Value (Assigned to
Variable sTok1) to the PhoneMail System.
transmit "^M"
else
; do nothing? let Target handle it?
endif
endwhile
setjmp 1 nJumps
fclose 0 ; Close file opened for read.
; Logout Procedure ----------
waitfor "Subscriber Name or Extension: "
transmit ";^M"
waitfor "Function: "
transmit "logo^M"
waitfor "Action: "
transmit "logo^M"
else
errormsg "Couldn't open file `"%s`"." Fname
endif
endproc
proc Announce
;pause 1
transmit "T T T^M"
endproc
proc Exit_MailBox
;pause 1
transmit ";^M"
endproc
proc Press_Enter
;pause 1
transmit "^M"
endproc
proc Press_Next
; this is not very elegant(to say the least)
; It's suppossed to handle when a mailbox doesn't exist.
;pause 1
nJumps = 0
longjmp 0 nJumps ; jump to start of loop
endproc