Connect

Establishes a link between the BlueZone Host Automation object and the BlueZone Display session. Connect must be called before any other BlueZone Host Automation object methods that access data in the host screen.

Parameters
SessionShortName
Uniquely identifies the BlueZone Display session. The session name corresponds to the HLLAPI Short Name Session Identifier configured in the Options API settings in the BlueZone Display emulator. See Example 1 below.

As an option, when the BlueZone session is embedded, using an exclamation point (!) can be used in place of an actual SessionShortName. When ! is used, the BZHAO auto-determines the session name. See Example 2 below.

[Blank]
If the SessionShortName parameter is omitted completely, the BZHAO connects to the session that is running in the foreground. If no session is running in the foreground, then the first session found is used.
ConnectRetryTimeout
Optional: Used to set the time in seconds that Connect spends attempting to connect to the BlueZone session. Also, as an option, a zero (0) can be used to cause the Connect to abort if the first attempt fails. See Example 3 below.
Returns
0 for success; or a non-zero error code. Refer to Error codes for a complete listing of error code descriptions.
Remarks
The object can only be connected to one display session at a time. When connecting to multiple sessions, any previously connected session is automatically disconnected.
Example 1
Set bzhao = CreateObject( "BZWhll.WhllObj" )
UserId = "John"
Password = "Smith"
ResultCode = bzhao.Connect( "A" )
If ( ResultCode = 0 ) Then
   bzhao.WriteScreen Userid, 5, 63
   bzhao.WriteScreen Password, 6, 63
   bzhao.SendKey "<Enter>"
   bzhao.WaitReady 10, 1
End If
Example 2
Dim host, SessionName, SessionId
Sub LoginToHost
   Set bzhao = CreateObject( "BZWhll.WhllObj" )
   bzhao.SetBrowserWnd window.top
   bzhao.ConnectToHost 2, 0 'zero means BZHAO must auto-determine session id
   bzhao.Connect "!"        '! means BZHAO must auto-determine session name
   SessionName = bzhao.GetSessionName()
   SessionId = bzhao.GetSessionId()
   bzhao.addConnectionCallback 2, SessionId, "ConnectionCallback"
   'additional login statements
   bzhao.Disconnect  'break link with session when done
End Sub
Sub ConnectionCallback
   bzhao.Connect SessionName   'connect to the same session
   'additional logoff statements
   bzhao.Disconnect
End Sub
Example 3
Set bzhao = CreateObject( "BZWhll.WhllObj" )
UserId = "John"
Password = "Smith"
ResultCode = bzhao.Connect( "A", 5 ) 'try to connect for 5 seconds
If ( ResultCode = 0 ) Then
   bzhao.WriteScreen Userid, 5, 63
   bzhao.WriteScreen Password, 6, 63
   bzhao.SendKey "<Enter>"
   bzhao.WaitReady 10, 1
End If