| Home | Previous Lesson: Creating Proxy Objects for Jaguar CTS Components Next Lesson: Instantiating Jaguar CTS Components |
Okay, we have done all the homework and we are ready to write the code and make use of those objects. First we need to declare a global variable of n_jag_connection, since we need that object throughout the application.
n_jag_connection g_JaguarConnection
Write the following code to connect to the Jaguar server. First, we are creating an instance of the connection object. That will automatically takes care of populating the connection information. Next, we are connecting to Jaguar server by calling ConnectToServer() function.
Object: Application
Event: Open
IF not IsValid( g_JaguarConnection ) THEN
g_JaguarConnection = CREATE n_jag_connection
End IF
IF g_JaguarConnection.ConnectToServer() <> 0 THEN
MessageBox("Jaguar", "Cannot connect to server")
HALT CLOSE
Else
w_mdi_frame.SetMicroHelp( "Connected to Jaguar Server " )
END IF
The following code in the Application Close event disconnects from Jaguar and destroys the instance.
Object: Application
Event: Close
IF IsValid( g_JaguarConnection ) THEN
g_JaguarConnection.DisconnectServer()
End IF
DESTROY g_JaguarConnection
| Home | Previous Lesson: Creating Proxy Objects for Jaguar CTS Components Next Lesson: Instantiating Jaguar CTS Components |