What is an object

To better understand the object oriented language, we must explain in a more precisely way what the "object" word means. In the previous sections you have already met the term of an object several times:
- At first you've created the following PROMOTIC objects in the application tree ("BoilerPlant", "Boiler1", "Data", "Panel", etc.)
- Next you have created folowing variables in the "Data" object (PmData type) "Power" and "Temperature" (these are the Var type objects)
- Then you have created the grafic items (Slider, Text, etc.) in the panel.
The object concept can be explained several ways. For the following explanation, we can use a simple example. We will explain the basic concepts by using the imaginary object that represents some (non-existing) window of OS Windows (this window object is not real, it is used only for this explanation).
1) Object has PROPERTIES
The "window" object can hold for example the following properties:
- X .. X position of the left upper angle
- Dy .. size in the Y direction
- Background .. background color, etc.
Each property has its name (X, Dy, Background) and its value.
Two operations can be made with properties:
- it is possible to find out the value of an property (we say that we can read the property). The object property is read in VBScript like follows:
Variable = Object.PropertyName
- it is possible to set the value of an property (we say that we can write into the property). The object property is written in VBScript like follows:
Object.PropertyName = Value
Note: The previous examples of VBScript (like the following ones) are only schematic and they'll be explained later on. It is important to keep in mind that it is always necessary to state both the object and the property name and these two terms are separated by a period.
Some of the properties are allowed both reading and writing, some of the properties are intended only for reading.
2) Object Holds METHODS
The objekt windows can hold for example the following methods:
- Print .. print the content of a window to a printer, etc.
- SaveToBmp .. save the content of a window into a file of the bitmap type (bmp).
It is possible to perform only one action with the method: we can call the method. By calling a method an appropriate operation performs, for example printing to a printer.
A method can return a value. For example it is often returned a flag with the operation result, it can return the output of a complex calculation, etc.
A method can hold parameters (and it mostly does) that closer define how the operation have to be performed. For example, at the SaveToBmp method it can be said by the parameter into which file the content has to be saved.
In VBScript language a method can be called as follows:

If the method does not have parameters and we need the returned value, then:

Result = Object.MethodName()

If a method has two parameters and we need the returned value, then:

Result = Object.MethodName(Parameter1, Parameter2)

If we do not need the returned value, then:

Object.MethodName Parameter1, Parameter2

This means that if we do not need the returned value(s), the parameters are not written inside brackets, but there is a space between the method name and parameters instead.

3) Object holds EVENTS
The window object can hold the following events:
- onOpen .. opening a window was performed
- onClose .. closing a window was performed
- onMouseClick .. the mouse clicked on a window
Using properties and methods allows you to perform operations over object(s). But an event works exactly the opposite way – the object uses its event to tell you that something has happened to it. The event is not read, written or called – the event happens.
The event can hold parameters as well. But these parameters are not set by you (like in case of properties and methods) - by the parameters the object itself closer defines what happened to it. For example, in case of the onMouseClick event the information would be in event parameters if the click was made by the left or by the right mouse button.
Each event may trigger a script that is executed once the event happens. In the PROMOTIC system each script is attached to some event therefore we call this concept event-based programming.
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice