WaitForStream Method Example

The example uses WaitforStream and SendKeys to page through host demonstration screens (using the SlideShow connection type). Note that with the exception of the first instance of SendKeys, this method is only executed if the WaitForStream method returns TRUE.

Sub Main()

 Dim Sys As Object, Sess As Object, MyScreen As Object

 

 Set Sys = CreateObject("EXTRA.System")

 Set Sess = Sys.ActiveSession

' Assumes an open session

 Set MyScreen = Sess.Screen

 

' WaitForStream will wait for up to 9 seconds.

 Sys.TimeoutValue = 9000

 

 ' This will page through a couple of "slide show" host screens.

 MyScreen.SendKeys ("a<Enter>")

 

 ' WaitForStream uses the optional idle time parameter. It will
 ' wait until the string is received followed by 2 seconds of
 'idle time, or until the System timeout value is reached.

 Found1st = MyScreen.WaitForStream("COMMAND ===>", 2000)

 If Found1st Then

  MyScreen.SendKeys ("user1<Enter>")

  Found2nd = MyScreen.WaitForStream("Ready;")

  If Found2nd Then

  MyScreen.SendKeys ("logoff<Enter>")

  Found3rd = MyScreen.WaitForStream("USSMSG10")

  End If

 End If

 If Not (Found1st And Found2nd And Found3rd) Then MsgBox "Error navigating host screens."

End Sub