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

Can I use "WaitForString" with multiple responses?

Status
Not open for further replies.

junoflydog

Technical User
Nov 6, 2011
5
US

How can I use "WaitForString" with multiple responses?

This might not even be the correct command to use.

I want to send a command then wait for a response before I proceed. I have no problem writing this code waiting for a single known response, but I may need to wait or have a conditional branch depending on multiple responses. I will have a set of known responses I can test against, but only one response will occur.

For example the response may be "completed" or "not found". One response I would want to continue the macro, the other end or branch to a new macro.


.Transmit my_Command

.WaitForString "completed" ' continue with macro_1
or
.WaitForString "not found" ' end macro or go to macro_2


*************
almost something like ->

.WaitForString {
"completed" then continue
"not found" then macro_2
"error" then End Sub
}

**************


If there is a better command, I am open for suggestions.

Thanks,
JunoFlyDog
 



hi,
Code:
   dim strings(1), i

   strings(0) = "completed" 
   strings(1) = "not found"

   do  while scrn.waitforstring(strings(i),r,c)
      i=i+1
      if i > 1 then i = 0
   loop


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks for the quick response. That didn't work for me.

By putting .StatusBar comments, I can tell it gets to the loop with proper command syntax (no errors), but never triggers on the test string.

I would think this would never work unless this has worked for you in the past. My thinking is that since the terminal window is a stream, the correct test variable would have to be selected when the text scrolled through, otherwise the loop would miss the data stream.

Any other thoughts?

JunoFlyDog

 



exactly WHAT code are you using?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 

Atachmate Reflection's Visual Basic

a terminal emulator


 
Sorry,

Not thinking clearly since this is an Atachmate forum.

I am simply writing a macro that will send a command, then branch (or pause) waiting for a reply.

Other than that, I don't know what you mean by "WHAT code are you using".


 



I cannot help you if you will not post your code!!!

I do not have a crystal ball!!!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry, didn't follow what you were asking. I get to the looping portion because the status bar displays "in loop", but this macro never ends.


Code:
Sub my_park()
    With Session

       My_Macros.my_screen_worklist  ' this macro calls a worklist page
   
       Dim my_Search(1), i

       my_Search(0) = "end of worklist"
       my_Search(1) = "no tickets"
 
       i = 0
  
       .StatusBar = "before loop"

       Do While .WaitForString(my_Search(i))
          i = i + 1
          If i > 1 Then i = 0
          .StatusBar = "in loop"
       Loop

       .StatusBar = "after loop"
            
    End With
End Sub

 

ExtraHELP said:
Description

Waits until the specified text appears on the screen. The Screen object will wait for the amount of time set in System.TimeoutValue.

Syntax

rc = object.WaitForString (Text [,Row [,Col [,Page]]])

-or-

object.WaitForString String [,Row [,Col [,Page]]]

Element Description
rc The return value.
object The Screen object.
String The text string that you want the Screen object to wait for.
Row The row where you expect the string to appear.
Col The column where you expect the string to appear.
Page VT session only -- the screen page.Note: This parameter is ignored for release 6.0 of EXTRA!o.

Copyright 1996 - 1999, Attachmate Corporation. All rights reserved.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top