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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hangup & Script stopping problems

Status
Not open for further replies.

lsavana

Programmer
May 21, 2004
2
US
I am a VFP programmer and created this script last year. This was my one and only time to use ASPECT. I'm including the pertinent blocks of script and will give a brief view of what we are doing. Files are created and sent to a folder (fWATCHDIR). We then start ProComm Plus 4.8 on Windows XP (running compatible with Windows 95) to dial a vendor, send a file, and capture the screen to a TXT file. This TXT file is then used to log the file's confirmation number or failure to be sent.

The problems that I am encountering are:
1. Hangup and/or disconnect cause the phone icon to hangup. But the app may sit for up to 2 - 3 minutes before it actually continues with the next file in the folder. I added the redundant commands when the problem was first encountered.
2. If the folder becomes empty and then files are added to it, the script stops running (the icon of the man running, actually stops moving). The user monitoring the file transfer must click the script icon to start it again.

I have searched everywhere for any insight to these problems. They are not consistent so they are very hard to determine a cause. I have the script on 5 different PCs all configured the same and the problem occurs on any one of them and any time.

I have thoroughly searched this site and have found several great ideas for enhancements that we have planned in the future. I appreciate any input ahead of time.
Thanks,
Laura

Code:
;**********************************************************
;* MACROS definitions
;**********************************************************
#define fWATCHDIR "C:\acca\kansascity7150\"      ;The directory to watch for files.
#define fBACKUPDIR "C:\orders_sent\"         	 ;The directory to move files to.
#define fLOGFILE "C:\acca\logfile.txt" 		 ;The error/log file.
#define fPROCOMM "C:\acca\procomm.txt" 		 ;The ProComm file.
#define szENTRY "Kansas City" 	    	         ;The entry to dial.

;**********************************************************
;*  Main
;**********************************************************
proc Main
   string Cmd

   strfmt s0 "YES"
   strfmt s1 " "

   when USEREXIT call Done ; Trap when user tries to exit script.

   while strcmp s0 "YES"
     startprocess()
   endwhile
   fclose 1

   if isfile fPROCOMM
     Cmd = "del C:\ACCA\PROCOMM.TXT"     ; Set DOS command to execute.
     DOS Cmd HIDDEN                      ; Run DOS command hidden.
   endif
   
endproc


;**********************************************************
;*  StartProcess
;**********************************************************
proc StartProcess

 string szMsg, szFile
   
 if fopen 1 fPROCOMM APPEND TEXT       ; Open procomm file for read only.
  fputs 1 "ProComm is running!"
 else
  statmsg "Error - Couldn't open the procomm file `"%s`"." fPROCOMM
      ;Error if not able to create procomm file.
 endif

 if fopen 0 fLOGFILE APPEND TEXT       ; Open log file for read only.
  logit("***************************************************")
  strfmt szMsg ("Date: %s") $date    ;Info for log file.
  logit(szMsg)
  strfmt szMsg ("Time: %s") $time
  logit(szMsg)
  logit("")
 else
  statmsg "Error - Couldn't open the log file `"%s`"." fLOGFILE  
      ;Error if not able to create log file.
 endif
   
 WatchIt(&szFile)                      ;Watch for files.
 yield
 ACCA(szFile)
 yield
 SendIt(szFile)                        ;Connect and upload file to host.
 yield
 MoveIt(szFile)                        ;Move file to backup dir.
 yield
 logit("Done.")
  
endproc


;**********************************************************
;* WatchIt 
;**********************************************************
proc WatchIt
param string szFile

 string szDir, szMsg

 szDir = fWATCHDIR
 strcat szDir "*.txt"
 while 1
  if findfirst szDir                 ;Find first file matching spec.
   szFile = $filespec              ;Get filename.
   strfmt szMsg ("File found: %s") $filespec
   logit(szMsg)
   exitwhile
  endif
  strfmt s0 "NO"
 endwhile
endproc


;**********************************************************
;* SendIt              * 
;**********************************************************
proc SendIt
param string szFile

 string thestring
   
 integer Row,iTemp			;,iNum

 set dial retries 3                    ;Set dial retries to 3.
 if strncmp s1 "0" 1
  dial DATA szENTRY                     ;Dial the host system.
  while $dialing                        ;Loop while dialing.
  endwhile
 else
  if strncmp s1 "2" 1
   dial DATA szENTRY                   ;Dial the host system.
   while $dialing                      ;Loop while dialing.
   endwhile
  else
   if strncmp s1 "3" 1
    dial DATA szENTRY                 ;Dial the host system.
    while $dialing                    ;Loop while dialing.
    endwhile
   else
    if strncmp s1 "4" 1
     dial DATA szENTRY               ;Dial the host system.
     while $dialing                  ;Loop while dialing.
     endwhile
    else
     logit("Problems with store number.")
    endif
   endif
  endif
 endif

 if $carrier                              ;Check to see if connected.
  if strncmp s1 "0" 1
   waitfor "Username: "
   transmit "7150^M" 
   waitfor "Password: "
   transmit "KLEVINE^M"
   logit("Username: 7150")
   logit("Password: KLEVINE")
  else
   if strncmp s1 "2" 1
    waitfor "Username: "
    transmit "2146^M"
    waitfor "Password: "
    transmit "LEVINE^M"
    logit("Username: 2146")
    logit("Password: LEVINE")
   else
    if strncmp s1 "3" 1
     waitfor "Username: "
     transmit "3900^M"
     waitfor "Password: "
     transmit "MLEVINE^M"
     logit("Username: 3900")
     logit("Password: MLEVINE")
    else
     if strncmp s1 "4" 1
      waitfor "Username: "
      transmit "7701^M"
      waitfor "Password: "
      transmit "LEVINE^M"
      logit("Username: 7701")
      logit("Password: LEVINE")
     endif
    endif
   endif
  endif
  waitfor "Please start your upload now."
  iTemp = 1                             ;Set iTemp value to 1 (for loop.)
  sendfile XMODEM szFile                ;Upload file using XMODEM.
  while iTemp == 1                      ;While file transfer is going on. 
   iTemp = $XFERSTATUS                ;Store value in $XFERSTATUS in iTemp
   yield                              ;Yield processor time.
  endwhile

  for Row = 0 upto 24 		    ; Loop through each row on screen.
   termgets Row 0 thestring 79         ; Get line specified by row.
   if strcmp thestring "Press any key to end this call."
    disconnect
    hangup
    exitfor
   endif
  Logit(thestring)	            ; Write line from screen to file.
  endfor

  disconnect                            ;Hangup from host.
  yield

 else                                     ;If not connected log error.
  logit("Problems connecting to host system.")
 endif  
endproc


;**********************************************************
 
Taking things in reverse order, it looks to me like the script will stop working when all files have been processed as s0 will be changed from YES to NO at the end of the WatchIt procedure since the if findfirst command will fail and drop down to the strfmt s0 "NO" command. When the WatchIt procedure returns back to StartProcess, which then returns to the main procedure, while strcmp s0 "YES" will be false, the remaining commands in main will execute, and the script will then end. If you do not wish for this to happen, then you'll need to comment out the strfmt command.

Depending on where an accidental disconnect occurred, I could see the commands in the SendIt procedure taking a bit to work through. I would first recommend putting all of the commands below the if $carrier/endif block into a second if $carrier/endif block. This will keep those commands from executing if a connection was not made. By default, the waitfor command will timeout after 30 seconds. The sendfile command will also sit for some period of time trying to send even though there is no connection present before it times out.

aspect@aspectscripting.com
 
Thanks, Knob. It is working fine now. I knew from reading other posts that you would have the answer.
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top