See my previous post here.
I thought I'd figured out the problem. And the script's been working fine. But, I added more lines to be watched for and it didn't work as I expected it to.
I'm connecting to Medicare's claims site. In my script, I wait for the logon prompt, then send a user-ID and password. At this point, I may get back any of several messages, including (but not limited to) the following:
For reference, here's a snip of my script:
Note: "RespondWith" is simply a proc to transmit the string and to write the info to a log file.
Here's the issue - I originally had the expired password waitfor [red](1)[/red] after the other checks - at [red](3)[/red]. When the expired password prompt was displayed, my script didn't see it, but instead simply went onto the next step after the "endif". I moved the check for the expired password to the 1st spot (as shown above) and it worked correctly. Well, that is, my script executed the steps inside the if/endif loop WITH THE EXCEPTION of step [red](2)[/red] - this text was displayed, but my script didn't execute these statements.
I checked to make sure the if/endif nesting is correct, and it is.
I could capture all text to a capture file and read that, but I'd prefer not to do that - seems like my script should be working correctly.
Any ideas why I seem to have so much trouble with "waitfor" statements??
I thought I'd figured out the problem. And the script's been working fine. But, I added more lines to be watched for and it didn't work as I expected it to.
I'm connecting to Medicare's claims site. In my script, I wait for the logon prompt, then send a user-ID and password. At this point, I may get back any of several messages, including (but not limited to) the following:
Your Password has expired.
You must pick a new one.
Enter your current password:
Invalid logon id
System Unavailable
Date : mm/dd/yyyy Time: hh:mm
User Id: xxxxxxxx
1) Transmit files
2) Receive files
3) List files
4) User Configuration
LO) Logoff
For reference, here's a snip of my script:
Code:
if [b][red](1)[/red][/b][highlight]waitfor[/highlight] "current password" TimeOutValue
PasswordPrompt:
dialogbox 0 6 15 172 143 2 Title
.. <snipped> ..
; At this point, the password appears to be valid, try to change
RespondWith(PasswordText)
if [highlight]waitfor[/highlight] "Enter your new password" TimeOutValue
RespondWith(NewPwdText)
[highlight]waitfor[/highlight] "Confirm your new password" TimeOutValue
RespondWith(NewPwdText)
endif
if [highlight]waitfor[/highlight] "Rejected" TimeOutValue
errormsg "" "Password is invalid. Disconnecting from CEDI.`nPlease try again or contact Tech Support."
hangup
goto EndRoutine
endif
; Password has been changed, log new password in INI file
if [b][red](2)[/red][/b][highlight]waitfor[/highlight] "updated" TimeOutValue
IniPwdText = NewPwdText
rewind 1
fwrite 1 IniLogonID 9
fwrite 1 IniPwdText 8
endif
endif
endif
endif
;-----------------
; If bulletin board responds that ID or password are invalid,
; display a screen and let the user try again or cancel
if [highlight]waitfor[/highlight] "Invalid logon" TimeOutValue
sdlgmsgbox "CONNECTION ERROR!" "Invalid logon ID or Password!" EXCLAMATION OKCANCEL Choice BEEP
hangup
if Choice == 1 ; OK pressed
goto ActionPrompt
else ; other choice was to cancel
goto endroutine
endif
endif
; If bulletin board responds that the system is not available
; at this time, display a screen and exit the script
if [highlight]waitfor[/highlight] "System Unavailable" TimeOutValue
errormsg "CONNECTION ERROR!" "System is not available!`nPlease try again later."
hangup
goto endroutine
endif
; If bulletin board responds that access is denied,
; display a screen and exit the script
if [highlight]waitfor[/highlight] "Access Denied" TimeOutValue
errormsg "CONNECTION ERROR!" "Access is denied.`nPlease contact System Administrator!"
hangup
goto endroutine
endif
[b][red](3)[/red][/b]
; Check to see if we're at the menu
[highlight]waitfor[/highlight] "O) Logoff " TimeOutValue
Here's the issue - I originally had the expired password waitfor [red](1)[/red] after the other checks - at [red](3)[/red]. When the expired password prompt was displayed, my script didn't see it, but instead simply went onto the next step after the "endif". I moved the check for the expired password to the 1st spot (as shown above) and it worked correctly. Well, that is, my script executed the steps inside the if/endif loop WITH THE EXCEPTION of step [red](2)[/red] - this text was displayed, but my script didn't execute these statements.
I checked to make sure the if/endif nesting is correct, and it is.
I could capture all text to a capture file and read that, but I'd prefer not to do that - seems like my script should be working correctly.
Any ideas why I seem to have so much trouble with "waitfor" statements??