Establishes a connection with a remote host. Corresponds to the Connect action.
App.Connect([connection][,alreadyConnected][,onFirstRecieve)
Newlook Smartclient
Newlook Server
This method can be used in one of the following three ways:
Establishes a connection with a defined connection definition.
connection - (String, Optional)
Specifies the predefined connection definition to use.
alreadyConnected - (Integer, Optional)
Specifies the action to take if Newlook is already connected. Refer to AlreadyConnected constants for a list of pre-defined values that can be used with this parameter. If alreadyConnected is left blank, nlConnPrompt is used.
onFirstReceive- (String, Optional)
Introduced in Version 11.1.
Specifies the name of the script or macro to run when this connection is established, and a screen is received. This parameter is particularly useful in multi-session environments where you want to provide a single call-back to notify the visible session that the current session has connected. If App.OnReceive is also set, the logic specified in the onFirstReceive parameter of the Connect method is executed first.
Leaving the Connect parameter blank forces the Connect Dialog to be displayed when the script runs. This option may be suitable if you wish to give users a choice of pre-defined connections.
Fig 1. Connect Dialog that displays if the Connection parameter is left blank.
Note: the option to generate the Connect dialog by leaving the Connection parameter blank is not supported in Newlook Server.
The following script connects to the pre-defined connection "Test Connection" and runs the "Events.OnFirstReceive" function after a connection is established.
function ConnectToHost()
{
App.Connect("Test Connection", nlConnTerminate, "Events.OnFirstReceive");
}
Dynamically create or modify a connection definition at run-time, and connect to it.
connection - (String, Optional)
Specifies a connection string. To dynamically modify or create a connection at run-time a valid connection string must be specified, with each connection property specified as an input=val pair, where 'input' is a string that is the name of the Connection property and 'val' is the value being supplied for that property.
alreadyConnected - (Integer, Optional)
Specifies the action to take if Newlook is already connected. Refer to AlreadyConnected constants for a list of pre-defined values that can be used with this parameter. If alreadyConnected is left blank, nlConnPrompt is used.
onFirstReceive- (String, Optional)
Introduced in Version 11.1.
Specifies the name of the script or macro to run when this connection is established, and a screen is received. This parameter is particularly useful in multi-session environments where you want to provide a single call-back to notify the visible session that the current session has connected. If App.OnReceive is also set, the logic specified in the onFirstReceive parameter of the Connect method is executed first.
Properties that can be specified in a Connection string include:
To override an existing connection definition, you must specify the name of the connection you wish to override in the Connection property of the Connection string.
It is also possible to modify printer connections using this action. This is useful if you need to create a generic printer connection that can then be modified for different IP addresses and printer devices.
Note that it is not possible to override Advanced print settings or the HPT/SCS setting.
The following script creates the connection "MyConnection", and then connects to it:
function ConnectToHost()
{
App.Connect("Connection=MyConnection;Network Address=192.168.1.1;Network Port=23;Display Device=JULIE1;Date Format=MM/dd/yyyy", nlConnTerminate, "Events.OnFirstReceive");
}
The following script connects to the existing "MyHost" connection definition, overwriting the Network Address, Display Device and Date Format properties in the connection definition with the values defined in the method's parameters. All other values in the existing connection definition will be unchanged:
function ConnectToMyHost()
{
App.Connect("Connection=MyHost;Network Address=acme.looksoftware.com;Display Device=JULIE1;Date Format=MM/dd/yyyy", nlConnTerminate);
}
The following script connects to the existing "GenericPrinter" definition with custom Network Address and Printer Device properties:
function ConnectToPrinter()
{
App.Connect("Connection=GenericPrinter;Network Address=192.168.1.1; Printer Device=TESTPRT", nlConnTerminate);
}
Specifies the Telnet 5250 URL to connect to.
connection - (String, Optional)
Specifies the telnet 5250 URL to connect to.
alreadyConnected - (Integer, Optional)
Specifies the action to take if Newlook is already connected. Refer to AlreadyConnected constants for a list of pre-defined values that can be used with this parameter. If alreadyConnected is left blank, nlConnPrompt is used.
onFirstReceive- (String, Optional)
Introduced in Version 11.1.
Specifies the name of the script or macro to run when this connection is established, and a screen is received. This parameter is particularly useful in multi-session environments where you want to provide a single call-back to notify the visible session that the current session has connected. If App.OnReceive is also set, the logic specified in the onFirstReceive parameter of the Connect method is executed first.
To connect to a telnet 5250 session, use the following syntax:
tn5250://[username]:[password]@IP address:[port number]/[device name]:[case-sensitive]
nl5250://[username]:[password]@IP address:[port number]/[device name]:[case-sensitive]
To connect to a secure telnet 5250 session, use the following syntax:
tn5250s://[username]:[password]@IP address:[port number]/[device name]:[case-sensitive]
nl5250s://[username]:[password]@IP address:[port number]/[device name]:[case-sensitive]
The following script connects to the host via a tn5250 URL with the username JULIEM and password ab123AB with the case sensitive option turned on:
function 5250Connect()
{
App.Connect("tn5250://JULIEM:[email protected]:23/:case-sensitive", nlConnTerminate);
}
Returns a Boolean indicating the success or failure of the method.
Connect Action | DBConnect Method | Sessions | OnCustomEvent property