Waiting Methods |
Top Previous Next |
There are several waiting methods that allow to wait for specifics events or event sequence, blocking the code execution until the event is raised or the operation times out. Main methods are:
VB [Boolean] = tnxxxx.WaitForConnect ([TimeOut As Integer]) [Boolean] = tnxxxx.WaitForScreen ([TimeOut As Integer]) [Boolean] = tnxxxx.WaitForUnlock ([TimeOut As Integer]) [Boolean] = tnxxxx.WaitFor (StrValue As String, [TimeOut As Integer]) [Integer] = tnxxxx.WaitFor (StrValues As Array of String, [TimeOut As Integer])
Delphi [Boolean] := tnxxxx.WaitForConnect ([TimeOut : Integer]); [Boolean] := tnxxxx.WaitForScreen ([TimeOut : Integer]); [Boolean] := tnxxxx.WaitForUnlock ([TimeOut : Integer]); [Boolean] := tnxxxx.WaitFor (StrValue : String, [TimeOut : Integer]); [Integer] := tnxxxx.WaitFor (StrValues : Array of String, [TimeOut : Integer]);
WaitForConnect waits until the telnet connection is successfully established. WaitForScreen waits until a new screen arrives after the connection is established or an AID key was sent. WaitForUnlock waits until the host system turns to an unlocked state. WaitFor waits for a screen containing the specified string or strings.
The following graphic shows the sequence of actions corresponding to the WaitFor method:
Examples:
VB: Private Sub cmdGetInfo_Click() telnet.Host = Edit1.Text If (telnet.Connect(10000) Then telnet.Type("Anonymous") telnet.PressAndWait("ENTER") telnet.Type("srch "+Edit2.Text+"@E") telnet.WaitFor("Library") Edit3.Text = telnet.GetText(20,5,30) telnet.Disconnect() End If End Sub
Delphi: procedure TForm1.GetInfoClick(Sender: TObject); begin TNB32701.Host := Edit1.Text; if TNB32701.Connect(10000) then begin TNB32701.Type('Anonymous'); TNB32701.PressAndWait('ENTER'); TNB32701.Type('srch '+Edit2.Text+'@E'); TNB32701.WaitFor('Library'); Edit3.Text := TNB32701.GetText(20,5,30); TNB32701.Disconnect(); end; end;
|