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

What command to use when waiting for more than one system prompt msg?

Status
Not open for further replies.

khmerboi83

Technical User
Aug 20, 2009
3
0
0
US
Hello everyone, I'm a rookie to aspect scripting. I have been reading a lot of the help content and I think I have some basic knowelge on how procom works. I have been given this project to work on for a couple weeks now. We are trying to get all of our Medicare and Medicaid connection automated for upload and download. every morning I create a batch file and upload my claims to Medicare and also download reports. I got the script to have it look in a directory if there are file to upload if not goto next step to look for download file. Now I can't get the downloading part to work. What command do I use when waiting for more than one system prompt message. Here's the script I wrote. Can anyone help.........

proc main

;VARIABLES DECLARED BELOW
string absolutepath

;BEGINS LOGIN TO MEDICARE RR
waitfor "lease Login:^M^J" FOREVER
transmit "123^M"
waitfor "Password?" FOREVER
transmit "ABC^M"
waitfor "Press <RETURN> to continue ->"
transmit "^M"

;AT MAIN MENU
;UPLOADING CLAIMS

absolutepath="L:\RCSYSTEM\Claims\RRMed\Claims\claims.dat"

waitfor "Selection:"
if findfirst "L:\RCSYSTEM\Claims RRMed\Claims\*.dat"
while findfirst "L:\RCSYSTEM\Claims RRMed\Claims\*.dat"
transmit "2^M"
waitfor "**** Select Protocol:" forever
transmit "z"
pause 1
rename $FILESPEC absolutepath
sendfile ZMODEM absolutepath
waitfor "Press <RETURN> to continue" forever
delfile absolutepath
endwhile
endif

;DOWNLOADING CLAIMS
transmit "1^M"
pause 5
waitfor "**** Select Protocol:"
transmit "z"
waitfor "Press Y/N to continue or q to quit"
transmit "y^M"

;IF THERE ARE FILE TO DOWNLOAD IT WILL START HERE
;THEN SYSTEM PROMPT THIS MESSAGE

waitfor "Press <RETURN> to continue"
transmit "^M"

;IF THERE ARE NO FILE TO DOWNLOAD
;SYSTEM PROMPT THIS MESSAGE

waitfor "**** Press q to quit"
transmit "q^M"

;SCRIPT ENDS HERE

;BEGIN TO DAIL UP MEDICARE RR REMITS
DIAL DATA "Medicare RR Remits"

;Waits for successful connection
while $DIALING
endwhile
endproc


 
Are you needing to look for two different prompts at the same time? If so, you can use a nifty bit of code that another user posted here a while back that will look for up to three strings and report to your main script which of the three (if any) was seen first. You can find it at the below link:


 
Yes, the two prompt I need to look for are "Press <RETURN> to continue" and "**** Press q to quit". The waitlist example is a little confusing. I don't know where I would apply the waitlist in my script. This is the downloading part I'm having trouble with. Thanks again for you help.

transmit "1^M"
pause 5
waitfor "**** Select Protocol:"
transmit "z"
waitfor "Press Y/N to continue or q to quit"
transmit "y^M"

;IF THERE ARE FILE TO DOWNLOAD IT WILL START HERE
;THEN SYSTEM PROMPT THIS MESSAGE

waitfor "Press <RETURN> to continue"
transmit "^M"

;IF THERE ARE NO FILE TO DOWNLOAD
;SYSTEM PROMPT THIS MESSAGE

waitfor "**** Press q to quit"
transmit "q^M"
 
I have the "waitlist" section of code in an include file because I use the same code in multiple scripts. So, my include file looks like this:

Code:
;---------------------------------------------------------------------
;  Procs.inc	(procedures "include" file)
;  This include file contains definitions for standard procedures
;---------------------------------------------------------------------
;
;  The following variables must be globally defined:
;	WaitListStat (integer)

;---------------------------------------------------------------------

;---------------------------------------------------------------------
;	WaitList
;           Wait for a list of up to five strings
;
;  Passed:  INT:     maximum # of seconds to wait
;           STRING:  Data string #1
;           STRING:  Data string #2
;           STRING:  Data string #3
;           STRING:  Data string #4
;           STRING:  Data string #5
;
;     Use $NULLSTR to ignore a parameter.
;
;  On Exit: Global WaitListStat = Data string # or 0
;---------------------------------------------------------------------
PROC WaitList
	PARAM INTEGER  maxTime
	PARAM STRING   string1, string2, string3, string4, string5

	INTEGER  loopControl

#ifdef ASPDEBUG
	STRFMT S0 "WaitList on `"%s`" `"%s`" `"%s`" `"%s`" `"%s`"" string1 string2 string3 string4 string5
	logit(S0)
#endif

	WaitListStat = 0

	WHEN TARGET 0 string1 CALL WaitListS1
	WHEN TARGET 1 string2 CALL WaitListS2
	WHEN TARGET 2 string3 CALL WaitListS3
	WHEN TARGET 3 string4 CALL WaitListS4
	WHEN TARGET 4 string5 CALL WaitListS5

   FOR loopControl = 1 UPTO maxTime
      PAUSE 1
      IF WaitListStat
         RETURN
      ENDIF
   ENDFOR

   ;; Failure, never received any.  Clear them all and exit.
   WHEN TARGET 0 CLEAR
   WHEN TARGET 1 CLEAR
   WHEN TARGET 2 CLEAR
   WHEN TARGET 3 CLEAR
   WHEN TARGET 4 CLEAR

ENDPROC

PROC WaitListS1
   WHEN TARGET 0 CLEAR
   WHEN TARGET 1 CLEAR
   WHEN TARGET 2 CLEAR
   WHEN TARGET 3 CLEAR
   WHEN TARGET 4 CLEAR
   WaitListStat = 1
ENDPROC

PROC WaitListS2
   WHEN TARGET 0 CLEAR
   WHEN TARGET 1 CLEAR
   WHEN TARGET 2 CLEAR
   WHEN TARGET 3 CLEAR
   WHEN TARGET 4 CLEAR
   WaitListStat = 2
ENDPROC

PROC WaitListS3
   WHEN TARGET 0 CLEAR
   WHEN TARGET 1 CLEAR
   WHEN TARGET 2 CLEAR
   WHEN TARGET 3 CLEAR
   WHEN TARGET 4 CLEAR
   WaitListStat = 3
ENDPROC

PROC WaitListS4
   WHEN TARGET 0 CLEAR
   WHEN TARGET 1 CLEAR
   WHEN TARGET 2 CLEAR
   WHEN TARGET 3 CLEAR
   WHEN TARGET 4 CLEAR
   WaitListStat = 4
ENDPROC

PROC WaitListS5
   WHEN TARGET 0 CLEAR
   WHEN TARGET 1 CLEAR
   WHEN TARGET 2 CLEAR
   WHEN TARGET 3 CLEAR
   WHEN TARGET 4 CLEAR
   WaitListStat = 5
ENDPROC

Then, in my main script, I'll reference the include file:
Code:
	integer WaitListStat = 0

#include "Procs.inc"
	
proc main

The way to reference the waitlist procedure then is coded like this:
Code:
;-------------------
;  Handle the response after logging in
    [b]WaitList(5,"current password", "Invalid logon", "System Unavailable", "Access Denied", "$NULLSTR")[/b]

    switch WaitListStat
      case 0
        exitswitch
      endcase
; If bulletin board responds that password has expired,
; prompt for a new one and change on the fly
      case 1      ; Expired password
        ChangePassword(&PwdChgStatus)
; ChangePassword returns with an integer status        
;  0 = Password change rejected
;  1 = Password successfully changed
;  3 = Cancel pressed from dialog box
;  9 = Unknown error occurred
      endcase
;-----------------

; If bulletin board responds that ID or password are invalid,
; display a screen and let the user try again or cancel
      case 2
        sdlgmsgbox "CONNECTION ERROR!" "Invalid logon ID or Password!" EXCLAMATION OKCANCEL Choice BEEP
        logit(">> Connection error - Invalid Logon ID or Password <<")
        hangup

        if Choice == 1      ; OK pressed
          logit("  - attempting again.")
          goto ActionPrompt
        else          ; other choice was to cancel
          logit("  - cancelled")
          goto endroutine
        endif
      endcase

; If bulletin board responds that the system is not available
; at this time, display a screen and exit the script
      case 3
        errormsg "CONNECTION ERROR!" "System is not available!`nPlease try again later."
        logit(">> Connection error - System not available <<")
        hangup
        goto endroutine
      endcase

; If bulletin board responds that access is denied,
; display a screen and exit the script
      case 4
        errormsg "CONNECTION ERROR!" "Access is denied.`nPlease contact System Administrator!"
        logit(">> Connection error - Access denied! <<")
        hangup
        goto endroutine
      endcase
    endswitch


Of course, there's a bunch of extraneous code in there, but you should get the general idea of what's happening and how it works.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top