Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks for creating this site - I expect to be visiting it often as I continue to try to grow my bag of tricks!..."

Geography

Where in the world do Tek-Tips members come from?

Looking for Data in a scrolling Screen

iamwhatiam (TechnicalUser)
4 Jun 03 22:11
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.
knob (Programmer)
4 Jun 03 22:53
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
http://www.aspectscripting.com

iamwhatiam (TechnicalUser)
5 Jun 03 1:05
Knob

If I understand this then:

proc main
string DN1
string DN2
string DN3
string vcos
  
  transmit "LD20^M"    ;
  waitfor  "REQ"       ;
  transmit "PRT^M"     ;
  waitfor  "TYPE "     ;
  transmit "DNB^M"     ;
  waitfor  "DN"        ;
  transmit DN1
  transmit "^M"
  waitfor  "CUST "
  transmit "^M"
;this is where the data is returned to the terminal
  waitfor "VMB_COS"
  rget vcos
  waitfor "SECOND_DN"
  rget DN2
  waitfor "THIRD_DN"
  rget DN3
knob (Programmer)
5 Jun 03 1:55
Yes, that should work (atleast it looks good to me) with one change.  I would use "if waitfor" instead of just waitfor.  That way the rget command will only be used if the "VMB_COS" 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 " " "" to get rid of any extra spaces that may be present.

aspect@aspectscripting.com
http://www.aspectscripting.com

iamwhatiam (TechnicalUser)
6 Jun 03 21:33
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 = ""                        ; New Last Name
string fullN = ""                        ; Full name Varable
string Vma = "99"                         ; Comparison to Voicemail
string vcos = "99"                        ; Voice mail Class of service
string dn2                            ; 2nd extension in MerMail    
string dn3                            ; 3rd extension in MerMail    
string EDN2 = "SECOND_DN"                    ; Expected String for 2nd extension
string EDN3 = "THIRD_DN"                    ; Expected String for 3rd extension
string Rdata = "Test.cap"                    ; Temp file
string Fname = "c:\test.cap"                       ; File name to be opened and deleted
string LineBuffer                                  ; Line read from file.
string tnb = "132 0 8 11"                    ; Site Tech phone
string key = "16"                        ; Telset key to use      
string Cdn1                            ; Complete dn
string dastri = ""
Integer Rgo = 0

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


dialogbox 0 8 20 264 169 194 "Name Change"
   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 "Directory Number" left
   text 9 29 40 34 11 "First Name" left
   text 10 29 60 34 11 "Last Name" left
   text 11 29 80 66 11 "TNB to use" left
   text 12 29 100 56 11 "KEY to use" left
   pushbutton 6 35 149 40 13 "OK" ok
   pushbutton 7 113 149 40 13 "Cancel" 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 = "C:\PBX NAME CHANGE AUDIT.TXT"
   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 = ""
                           ; 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 "/" 1            ; Get the month.
    strtok day dateinfo "/" 1            ; Get the day.
    strtok year dateinfo "/" 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 "/"                    ;
    strcat stad month                ;
    strcat stad "/"                    ;
    strcat stad year                ;
    strcat stad " "                    ;
    strcat stad hour                    ;
    strcat stad ":"                    ;
    strcat stad minute
    strcat stad ":"
    strcat stad second                ; Command build finished.


    if nullstr lastN                        ; Verifys that a last name was put in
     usermsg "Last name is required!"
     main()                                             ; Causing trouble from runing multi times
    endif  
  
   strcat fullN firstN                        ; Add First Name to Varable fullN
   strcat fullN ","                        ; Add , after Frist Name
   strcat fullN lastN                        ; Add Last Name to Varable fullN
  
   strcat Cdn1 "KEY "
   strcat Cdn1 key
   strcat Cdn1 " scr "
   strcat Cdn1 dn1
   strcat Cdn1 "^M"
   
   strcat Dastri dn1
   strcat Dastri " "
   strcat Dastri fullN
   strcat Dastri " "
   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 "****^M"                        ; Makes sure that craft person is not in any Loads
 waitfor ">"
 transmit "LD 20^M"                        ; Rls 19 and on for normal Name changes
   waitfor "REQ: "
   transmit "prt^M"
   waitfor "TYPE: "
   transmit "dnb^M"
   waitfor "CUST "
   transmit "0^M"                        ; For single Customer Site
   waitfor "DN   "
   transmit DN1
   transmit "^M"
   waitfor "DATE "
   
   if failure
    exit
   endif
    
   transmit "^M"
   waitfor "PAGE "
   transmit "^M"
   waitfor "DES "
   
   set capture path "c:\"
   set capture query OFF
   set capture overwrite on
   set capture file Rdata
   
   capture  on
   
   transmit "^M"   
   waitfor "NACT"
   
   capture off
   
   set capture path "C:\Program Files\Procomm Plus\Capture"
   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 "VMB_COS"                 ; 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 "SCH0881"                 ; Non-existane DN in the Switch
          if success   
            usermsg "That phone number does not exist in this switch"
            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 "Couldn't open file `"%s`"." 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 "      VMB_COS" ""                 ; Clean up the Varable Vcos
   strfind Vcos "0"                         ; Assigns a COS to a Mailbox if it doesn't have one
    if success
     Vcos = "1"                             ; The Default COS
    endif
   strreplace DN2 "       SECOND_DN" ""                 ; Clean up the Varable DN2
   strreplace DN3 "       THIRD_DN" ""                 ; Clean up the Varable DN3
  
   Transmit "^M"    
  ;                                Phase 1   (Outing the Name and Mailbox)
   waitfor "REQ: "   
   transmit "chg^M"
   waitfor "TYPE: "
   transmit "2616^M"
   waitfor "TN   "
   transmit tnb
   transmit "^M"
   waitfor "ECHG "
   transmit "yes^M"
   waitfor "ITEM "
   transmit Cdn1
   waitfor "MARP "
   transmit "^M"
   waitfor "CPND "
   transmit "out^M"
   waitfor "VMB "
   transmit "out^M"
   waitfor "KEY "
   transmit "^M"
   waitfor "ITEM "
   transmit "^M"
  ;                               Phase 2 (puting in the new name and adding Voice mail)
   waitfor "REQ: "                
   transmit "chg^M"
   waitfor "TYPE: "
   transmit "2616^M"
   waitfor "TN "
   transmit tnb
   transmit "^M"
   waitfor "ECHG "
   transmit "yes ^M"
   waitfor "ITEM "
   transmit Cdn1
   waitfor "MARP "
   transmit "^M"
   waitfor "CPND "
   transmit "new^M"
   waitfor "NAME "
   transmit fullN
   transmit "^M"
   waitfor "DISPLAY_FMT "
   transmit "^M"
   waitfor "VMB "
   transmit "new^M"
   waitfor "VMB_COS "
   transmit Vcos
   transmit "^M"
   waitfor "SECOND_DN "
   transmit dn2
   transmit "^M"
   waitfor "THIRD_DN"
   transmit dn3
   transmit "^M"
   waitfor "KEEP_MSGS"
   transmit "^M"
   waitfor " KEY "
   transmit "^M"
   waitfor "ITEM "
   transmit "^M"
 ;                         Phase 3  (Retuning the Key back to its null state)  
   waitfor "REQ: "                
   transmit "chg^M"
   waitfor "TYPE: "
   transmit "2616^M"
   waitfor "TN   "
   transmit tnb
   transmit "^M"
   waitfor "ECHG "
   transmit "yes^M"
   waitfor "ITEM "
   transmit "key "
   transmit key
   transmit " nul^M"
   waitfor "     KEY "
   transmit "^M"
   waitfor "ITEM "
   transmit "^M"
   waitfor "REQ: "
   transmit "END^M"
   waitfor ">"  
   
   delfile Fname
    
  Fcheck()                        ; Causing trouble from runing multi times
  
endproc

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

proc NoVmail
;                                             Phase 1 (Removing the Name from the PBX)
  transmit "END^M"
  waitfor ">"
  transmit "LD 95^M"
   waitfor "REQ  "
   transmit "out^M"
   waitfor "TYPE "
   transmit "name^M"
   waitfor "CUST "
   transmit "0^M"
   waitfor "DIG  "
   transmit "^M"
   waitfor "DN   "
   transmit dn1
   transmit "^M"
   waitfor "DN   "
   transmit "^M"
   waitfor "DCNO "
   transmit "^M"
 ;                                            Phase 2 (Putting in the New Name)  
   waitfor "REQ"
   transmit "new^M"
   waitfor "TYPE "
   transmit "name^M"
   waitfor "CUST "
   transmit "0^M"
   waitfor "DIG  "
   transmit "^M"
   waitfor "DN"
   transmit dn1
   transmit "^M"
   waitfor "  NAME "
   transmit fullN
   transmit "^M"
   waitfor "  DISPLAY_FMT "
   transmit "^M"
   waitfor "DN   "
   transmit "^M"
   waitfor "DCNO "
   transmit "^M"
   waitfor "REQ  "
   transmit "end^M"
   waitfor ">"
 
   delfile Fname
   
   Fcheck()                         ; Causing trouble from runing multi times

 endproc

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

;                               Prints the DN back out for a visual verification
  proc Fcheck
   transmit "LD 20^M"
   waitfor "REQ"
   transmit "prt^M"
   waitfor "TYPE: "
   transmit "dnb^M"
   waitfor "CUST "
   transmit "0^M"
   waitfor "DN   "
   transmit DN1
   transmit "^M"
   waitfor "DATE "
   transmit "^M"
   waitfor "PAGE "
   transmit "^M"
   waitfor "DES "
   transmit "^M"
   waitfor "NACT"
   transmit "end^M"
   Mdone()                     ; Causing trouble from runing multi times
 
  endproc
 
 ;---------------------------------------------  Nmain  ---------------------------------------
  
  proc Nmain
  dn1 = ""                         ; Reset String Varable to NULL
  firstN = ""                        ; Reset String Varable to NULL
  lastN = ""                        ; Reset String Varable to NULL
  fullN = ""                        ; Reset String Varable to NULL
  Cdn1 = ""
  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

knob (Programmer)
10 Jun 03 1:06
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
http://www.aspectscripting.com

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close