Accessing Server Properties

<< Click to Display Table of Contents >>

 

Accessing Server Properties

To access an object executing on a server from a Screen object or an ElipseX, use the Application.GetObject method.

The word Application returns the application object related to the current object's context, and the GetObject method searches for an object with the given name within Application on the server, as in the next example.

Sub Button1_Click()
  Application.GetObject("Driver1")._
    Item("tag001").AllowRead = False
End Sub

 

Or else as in the next example.

Sub Button1_Click()
  Application.GetObject("Driver1.tag001").AllowRead = False
End Sub

 

The Item method was used to locate tag001 from a reference to Driver1, because a Driver is a collection of Tags. After locating an object, its properties and methods can be freely accessed.

In case users want to accomplish another operation with Driver1 or tag001, another alternative for the previous script would be the one described on the next example.

Sub Rectangle1_Click()
  Set obj = Application.GetObject("Driver1")
  obj.Item("tag001").AllowRead = False
  obj.Item("tag002").AllowRead = False
End Sub

 

In this case, the variable obj is pointing to object Driver1, and the next time users want to access some object descending from Driver1 inside this script, they can use the variable obj directly. This brings a performance enhancement, since every call to the GetObject method accesses the server only once. With this technique, users avoid unnecessary calls to a server. This example uses the Set command, explained later. Notice that using variables also makes code clearer and more easily modifiable. In case users want to change the object to execute commands, change the attribution line of this variable.

The word Application in scripts can indicate either functions executed on an Elipse E3 Viewer or on a Server. In this case, the Application object knows beforehand which functions must be executed in each case. However, users cannot execute Elipse E3 Viewer functions inside a server, and users cannot execute server functions inside an Elipse E3 Viewer.

Was this page useful?