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!

More "waitfor" blues

Status
Not open for further replies.

CUDaveS

Technical User
Jun 12, 2007
17
0
0
US
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:

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
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??
 
In a case where you have to watch for multiple possible strings, I recommend using a procedure that another user sent me ages ago that works great for this kind of situation. It uses multiple when target commands, reporting to the calling procedure which, if any, of the strings was received first in the specified timeout value. It is setup for three strings, but should be easily extendable to four in your case. You can find it here:


 
I tried using WaitList, but for some reason, that didn't work either. I modified it to have up to 6 strings and WaitList came back with value 0 (none).

I'll try again, just for S & G and I'll report back... but I don't believe it's going to make a difference.
 
Well, I said I'd report back.
I modified WaitList to allow up to 5 strings to wait for. It works as it's designed... that is, it looks for one of the strings sent in to the function, if it doesn't find one, it times out and the response is sent back to the script.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top