Object (data type)

A variable of data type object points to an object in your simulation model or is void. You can save any graphically represented object with the data type object. This variable can be a local variable, a formal parameter, a global variable and values in tables.

You can assign both objects and strings to the variables of data type object mentioned above. When you assign an object, Plant Simulation creates an Object Reference, regardless if you specify the object with a relative or an absolute <Path>. When you specify the object with a relative path, Plant Simulation immediately resolves the relative path within the context of the current method and creates an object reference to the calculated object.

Let’s suppose that the method .Models.Frame.method contains the following method call: SubFrame.methodU(Station)

Plant Simulation resolves the relative path Station to an object reference to .Models.Frame.Station, and passes this object reference to the method within the sub-Frame. If the path cannot be resolved to an object, Plant Simulation opens the Debugger.

When a string is passed to a variable, the string is assigned as a path to the variable. Regardless if this path is relative or absolute, Plant Simulation does not resolve it at this point in time. Instead, the path is resolved each and every time when the variable is read.

Let’s suppose that the method .Models.Frame.method contains the following method call: sub-Frame.methodU("Station")

Plant Simulation passes the relative path Station to the method within the sub-Frame. At this point in time such an object neither has to exist within the context of the calling method, nor within the context of the called method as the path is not resolved yet. Let’s suppose that we inserted an object of type Station into the sub-Frame and that this object has the name Station1.

Let’s also suppose that the source code of methodU in the sub-Frame looks like this:

Example

param o: object
Station1.Name := "Station"
o.name := "Station1"
o.name := "Test"  -- ERROR!

Each time the local variable o is accessed, the relative path will be resolved, in fact it will be resolved within the context of this method, meaning that path resolution starts in the sub-Frame. This way it points to .Models.Frame.sub-Frame.Station, which now exists. This Station is then renamed to Station1 so that the path Station cannot be resolved in the next line and Plant Simulation thus opens the Debugger.

Related Topics

The Absolute Path

The Relative Path

Object Reference