Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for Data in a scrolling Screen

Status
Not open for further replies.

iamwhatiam

Technical User
Jul 18, 2002
5
US
Is there a way to put data into a string variable from a screen that is scrolling out data. Voice example.
DN 7100
CPND
NAME New User
XPLN 10
DISPLAY_FMT FIRST,LAST
VMB
VMB_COS 0 <== Capture this data varable
SECOND_DN 4017 <== if this data varable exist
THIRD_DN <== if this data varable exist

I want to capture the data after each of the three lines if there is any data. If not return a null vaule to the string.

This data is from a printout from a host to the term.
 
There are a couple ways to do this. One would be to use if waitfor to have your script pause until the string you were interested in appears. Waitfor times out after 30 seconds, so you may need to increase the timeout value by specifying a number in seconds the waitfor command should pause for (place it after the string the waitfor command is looking for).

Another option is when target, which can wait indefinitely for a string of text to come along, then call a procedure that handles the necessary steps.

Once your script has detected the proper string, you can use the termreads or rget command to read the remaining data on that line. Another option that I've used in the past, which may work if all the data being sent at that time will fit on one screen, is to save the current screen to a temporary text file, open that file in my script, then read line by line looking for the data I'm interested in.

Hopefully this has given you a few ideas to work with.


aspect@aspectscripting.com
 
Knob

If I understand this then:

proc main
string DN1
string DN2
string DN3
string vcos

transmit &quot;LD20^M&quot; ;
waitfor &quot;REQ&quot; ;
transmit &quot;PRT^M&quot; ;
waitfor &quot;TYPE &quot; ;
transmit &quot;DNB^M&quot; ;
waitfor &quot;DN&quot; ;
transmit DN1
transmit &quot;^M&quot;
waitfor &quot;CUST &quot;
transmit &quot;^M&quot;
;this is where the data is returned to the terminal
waitfor &quot;VMB_COS&quot;
rget vcos
waitfor &quot;SECOND_DN&quot;
rget DN2
waitfor &quot;THIRD_DN&quot;
rget DN3
 
Yes, that should work (atleast it looks good to me) with one change. I would use &quot;if waitfor&quot; instead of just waitfor. That way the rget command will only be used if the &quot;VMB_COS&quot; string is found. Otherwise, the rget command would grab some string after the waitfor command timed out. You may also need to do a little cleanup of the string after you have retrieved the data, such as a strreplace vcos &quot; &quot; &quot;&quot; to get rid of any extra spaces that may be present.


aspect@aspectscripting.com
 
KNOB;

Well the first approached didnt work so I captured it to file and was able to extract the data that i needed.

Below is the script with a couple of outstanding issues that are documemted.;This script is for a Nortel Meridian PBX.
;The Craft personal must be logged in for this to Work.
;The suytem should be using VMA through the PBX to keep the names sync up.
;A default tn and key were used on the switchroom phone and should be changed to
; match the site where this is ran.
;By useing the test phone there is no interruption to the end user while the change
; is made.
;This program was written from material and examples from Aspect manual and Help,
; Other ideas were contributed from online forms and examples from the Internet.
;
;------------------------------ GLOABAL VARABLES ----------------------------
string dn1 ; 4 digit extension
string firstN ; New First Name
string lastN = &quot;&quot; ; New Last Name
string fullN = &quot;&quot; ; Full name Varable
string Vma = &quot;99&quot; ; Comparison to Voicemail
string vcos = &quot;99&quot; ; Voice mail Class of service
string dn2 ; 2nd extension in MerMail
string dn3 ; 3rd extension in MerMail
string EDN2 = &quot;SECOND_DN&quot; ; Expected String for 2nd extension
string EDN3 = &quot;THIRD_DN&quot; ; Expected String for 3rd extension
string Rdata = &quot;Test.cap&quot; ; Temp file
string Fname = &quot;c:\test.cap&quot; ; File name to be opened and deleted
string LineBuffer ; Line read from file.
string tnb = &quot;132 0 8 11&quot; ; Site Tech phone
string key = &quot;16&quot; ; Telset key to use
string Cdn1 ; Complete dn
string dastri = &quot;&quot;
Integer Rgo = 0

;------------------------------------ MAIN --------------------------------
proc main
when dialog 0 call handler0


dialogbox 0 8 20 264 169 194 &quot;Name Change&quot;
editbox 1 115 20 34 11 DN1 4
editbox 2 115 40 34 11 firstN 12
editbox 3 115 60 34 11 LastN 16
editbox 4 115 80 34 11 TNB
editbox 5 115 100 34 11 key 2
text 8 29 20 80 11 &quot;Directory Number&quot; left
text 9 29 40 34 11 &quot;First Name&quot; left
text 10 29 60 34 11 &quot;Last Name&quot; left
text 11 29 80 66 11 &quot;TNB to use&quot; left
text 12 29 100 56 11 &quot;KEY to use&quot; left
pushbutton 6 35 149 40 13 &quot;OK&quot; ok
pushbutton 7 113 149 40 13 &quot;Cancel&quot; cancel
enddialog

dlgupdate 0 1
dlgupdate 0 2
dlgupdate 0 3
dlgupdate 0 4
dlgupdate 0 5


endproc
;------------------------------ HANDLER0 ----------------------------------
proc handler0
integer event0
dlgevent 0 event0
switch event0
case 6
snext()
endcase
case 7
mdone()
endcase
endswitch
endproc
;------------------------------- SNEXT ------------------------------------
proc snext

string Aname = &quot;C:\PBX NAME CHANGE AUDIT.TXT&quot;
string dateinfo ; Date temp storage.
string year ; year
string month ; Month of year.
string day ; Day of month.
string daystr ; Day of week string.
string hour ; hour.
string minute ; Minute.
string second ; Second.
string stad = &quot;&quot;
; Command to be sent to Audit file.
integer dayweek ; Day of the week.
integer dayyear ; Day of the year.
integer leapyear ; Leap year flag.


substr hour $TIME24 0 2 ; Get the Hour.
substr minute $TIME24 3 2 ; Get the Minuet.
substr second $TIME24 6 2 ; Get the Second.
ltimemisc $LTIME DayWeek DayYear LeapYear ; Get the Day of Week Number.
strcpy dateinfo $DATE ; Copy the date into the string.
strtok month dateinfo &quot;/&quot; 1 ; Get the month.
strtok day dateinfo &quot;/&quot; 1 ; Get the day.
strtok year dateinfo &quot;/&quot; 1 ; Get the year
itoa DayWeek Daystr ; Convert day of week to a string.
strcat stad day ; Start building command to send to the CAT.
strcat stad &quot;/&quot; ;
strcat stad month ;
strcat stad &quot;/&quot; ;
strcat stad year ;
strcat stad &quot; &quot; ;
strcat stad hour ;
strcat stad &quot;:&quot; ;
strcat stad minute
strcat stad &quot;:&quot;
strcat stad second ; Command build finished.


if nullstr lastN ; Verifys that a last name was put in
usermsg &quot;Last name is required!&quot;
main() ; Causing trouble from runing multi times
endif

strcat fullN firstN ; Add First Name to Varable fullN
strcat fullN &quot;,&quot; ; Add , after Frist Name
strcat fullN lastN ; Add Last Name to Varable fullN

strcat Cdn1 &quot;KEY &quot;
strcat Cdn1 key
strcat Cdn1 &quot; scr &quot;
strcat Cdn1 dn1
strcat Cdn1 &quot;^M&quot;

strcat Dastri dn1
strcat Dastri &quot; &quot;
strcat Dastri fullN
strcat Dastri &quot; &quot;
strcat Dastri stad

if fopen 0 Aname APPEND TEXT ;Addes to the audit file what was done.
fputs 0 Dastri
fclose 0
else
fopen 0 Aname CREATE
fputs 0 Dastri
fclose 0
endif
;---------------------------------Start actual transmitting----------------------------------------------
Transmit &quot;****^M&quot; ; Makes sure that craft person is not in any Loads
waitfor &quot;>&quot;
transmit &quot;LD 20^M&quot; ; Rls 19 and on for normal Name changes
waitfor &quot;REQ: &quot;
transmit &quot;prt^M&quot;
waitfor &quot;TYPE: &quot;
transmit &quot;dnb^M&quot;
waitfor &quot;CUST &quot;
transmit &quot;0^M&quot; ; For single Customer Site
waitfor &quot;DN &quot;
transmit DN1
transmit &quot;^M&quot;
waitfor &quot;DATE &quot;

if failure
exit
endif

transmit &quot;^M&quot;
waitfor &quot;PAGE &quot;
transmit &quot;^M&quot;
waitfor &quot;DES &quot;

set capture path &quot;c:\&quot;
set capture query OFF
set capture overwrite on
set capture file Rdata

capture on

transmit &quot;^M&quot;
waitfor &quot;NACT&quot;

capture off

set capture path &quot;C:\Program Files\Procomm Plus\Capture&quot;
set capture query on
set capture overwrite off


if fopen 0 Fname READ TEXT ; Open file for read only.
while not feof 0 ; Loop while not end of file.
fgets 0 LineBuffer ; Get line from file.
strfind LineBuffer &quot;VMB_COS&quot; ; Get Voicemail class of Services
if success
Vcos = LineBuffer
endif
strfind LineBuffer EDN2 ; Get 2nd DN associated with mailbox
if success
DN2 = LineBuffer
endif
strfind LineBuffer EDN3 ; Get 3rd DN associated with mailbox
if success
DN3 = LineBuffer
endif
strfind LineBuffer &quot;SCH0881&quot; ; Non-existane DN in the Switch
if success
usermsg &quot;That phone number does not exist in this switch&quot;
Nmain() ; Causing trouble from runing multi times
exit ; Had to add to stop continue on from last step once completed
endif
endwhile
fclose 0 ; Close file opened for read.
else
errormsg &quot;Couldn't open file `&quot;%s`&quot;.&quot; Fname

endif

strfind Vcos Vma
if success
NoVmail() ; Causing trouble from runing multi times
exit ; Had to add to stop continue on from last step once completed
endif

strreplace Vcos &quot; VMB_COS&quot; &quot;&quot; ; Clean up the Varable Vcos
strfind Vcos &quot;0&quot; ; Assigns a COS to a Mailbox if it doesn't have one
if success
Vcos = &quot;1&quot; ; The Default COS
endif
strreplace DN2 &quot; SECOND_DN&quot; &quot;&quot; ; Clean up the Varable DN2
strreplace DN3 &quot; THIRD_DN&quot; &quot;&quot; ; Clean up the Varable DN3

Transmit &quot;^M&quot;
; Phase 1 (Outing the Name and Mailbox)
waitfor &quot;REQ: &quot;
transmit &quot;chg^M&quot;
waitfor &quot;TYPE: &quot;
transmit &quot;2616^M&quot;
waitfor &quot;TN &quot;
transmit tnb
transmit &quot;^M&quot;
waitfor &quot;ECHG &quot;
transmit &quot;yes^M&quot;
waitfor &quot;ITEM &quot;
transmit Cdn1
waitfor &quot;MARP &quot;
transmit &quot;^M&quot;
waitfor &quot;CPND &quot;
transmit &quot;out^M&quot;
waitfor &quot;VMB &quot;
transmit &quot;out^M&quot;
waitfor &quot;KEY &quot;
transmit &quot;^M&quot;
waitfor &quot;ITEM &quot;
transmit &quot;^M&quot;
; Phase 2 (puting in the new name and adding Voice mail)
waitfor &quot;REQ: &quot;
transmit &quot;chg^M&quot;
waitfor &quot;TYPE: &quot;
transmit &quot;2616^M&quot;
waitfor &quot;TN &quot;
transmit tnb
transmit &quot;^M&quot;
waitfor &quot;ECHG &quot;
transmit &quot;yes ^M&quot;
waitfor &quot;ITEM &quot;
transmit Cdn1
waitfor &quot;MARP &quot;
transmit &quot;^M&quot;
waitfor &quot;CPND &quot;
transmit &quot;new^M&quot;
waitfor &quot;NAME &quot;
transmit fullN
transmit &quot;^M&quot;
waitfor &quot;DISPLAY_FMT &quot;
transmit &quot;^M&quot;
waitfor &quot;VMB &quot;
transmit &quot;new^M&quot;
waitfor &quot;VMB_COS &quot;
transmit Vcos
transmit &quot;^M&quot;
waitfor &quot;SECOND_DN &quot;
transmit dn2
transmit &quot;^M&quot;
waitfor &quot;THIRD_DN&quot;
transmit dn3
transmit &quot;^M&quot;
waitfor &quot;KEEP_MSGS&quot;
transmit &quot;^M&quot;
waitfor &quot; KEY &quot;
transmit &quot;^M&quot;
waitfor &quot;ITEM &quot;
transmit &quot;^M&quot;
; Phase 3 (Retuning the Key back to its null state)
waitfor &quot;REQ: &quot;
transmit &quot;chg^M&quot;
waitfor &quot;TYPE: &quot;
transmit &quot;2616^M&quot;
waitfor &quot;TN &quot;
transmit tnb
transmit &quot;^M&quot;
waitfor &quot;ECHG &quot;
transmit &quot;yes^M&quot;
waitfor &quot;ITEM &quot;
transmit &quot;key &quot;
transmit key
transmit &quot; nul^M&quot;
waitfor &quot; KEY &quot;
transmit &quot;^M&quot;
waitfor &quot;ITEM &quot;
transmit &quot;^M&quot;
waitfor &quot;REQ: &quot;
transmit &quot;END^M&quot;
waitfor &quot;>&quot;

delfile Fname

Fcheck() ; Causing trouble from runing multi times

endproc

;------------------------------------------ NoVmail --------------------------------------

proc NoVmail
; Phase 1 (Removing the Name from the PBX)
transmit &quot;END^M&quot;
waitfor &quot;>&quot;
transmit &quot;LD 95^M&quot;
waitfor &quot;REQ &quot;
transmit &quot;out^M&quot;
waitfor &quot;TYPE &quot;
transmit &quot;name^M&quot;
waitfor &quot;CUST &quot;
transmit &quot;0^M&quot;
waitfor &quot;DIG &quot;
transmit &quot;^M&quot;
waitfor &quot;DN &quot;
transmit dn1
transmit &quot;^M&quot;
waitfor &quot;DN &quot;
transmit &quot;^M&quot;
waitfor &quot;DCNO &quot;
transmit &quot;^M&quot;
; Phase 2 (Putting in the New Name)
waitfor &quot;REQ&quot;
transmit &quot;new^M&quot;
waitfor &quot;TYPE &quot;
transmit &quot;name^M&quot;
waitfor &quot;CUST &quot;
transmit &quot;0^M&quot;
waitfor &quot;DIG &quot;
transmit &quot;^M&quot;
waitfor &quot;DN&quot;
transmit dn1
transmit &quot;^M&quot;
waitfor &quot; NAME &quot;
transmit fullN
transmit &quot;^M&quot;
waitfor &quot; DISPLAY_FMT &quot;
transmit &quot;^M&quot;
waitfor &quot;DN &quot;
transmit &quot;^M&quot;
waitfor &quot;DCNO &quot;
transmit &quot;^M&quot;
waitfor &quot;REQ &quot;
transmit &quot;end^M&quot;
waitfor &quot;>&quot;

delfile Fname

Fcheck() ; Causing trouble from runing multi times

endproc

;--------------------------------------------- Fcheck ---------------------------------------

; Prints the DN back out for a visual verification
proc Fcheck
transmit &quot;LD 20^M&quot;
waitfor &quot;REQ&quot;
transmit &quot;prt^M&quot;
waitfor &quot;TYPE: &quot;
transmit &quot;dnb^M&quot;
waitfor &quot;CUST &quot;
transmit &quot;0^M&quot;
waitfor &quot;DN &quot;
transmit DN1
transmit &quot;^M&quot;
waitfor &quot;DATE &quot;
transmit &quot;^M&quot;
waitfor &quot;PAGE &quot;
transmit &quot;^M&quot;
waitfor &quot;DES &quot;
transmit &quot;^M&quot;
waitfor &quot;NACT&quot;
transmit &quot;end^M&quot;
Mdone() ; Causing trouble from runing multi times

endproc

;--------------------------------------------- Nmain ---------------------------------------

proc Nmain
dn1 = &quot;&quot; ; Reset String Varable to NULL
firstN = &quot;&quot; ; Reset String Varable to NULL
lastN = &quot;&quot; ; Reset String Varable to NULL
fullN = &quot;&quot; ; Reset String Varable to NULL
Cdn1 = &quot;&quot;
main()
while Rgo == 0
main()
endwhile

endproc
;--------------------------------------------- mdone ---------------------------------------
proc mdone
exit
endproc

; pending parts are to beable to run the script until cancel is pressed.
; errors noticed when going to sections. After it completes it wants
; to continue off where it jumped to that section
;

Thanks

 
I've never called main() from a script, so what you're doing is different from anything I've seen before. What I usually recommend doing is have a while 1/endwhile loop in main so that the rest of your script is always being called by main instead of calling main. In the procedures that are calling main now, I would structure them so that the rest of the procedure is not executed, such as by using if/else/endif structures.

aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top