The software products by Gurux are based on the Microsoft COM technology,
and are designed to be Automation (formerly OLE Automation) compatible.
This means that the components by Gurux can be used with all automation
compatible languages, including scripting languages supported by Microsoft
Scripting Technologies.
To support the scripting languages, the VARIANT data type often has to be used as parameter type. For C++ programmers, using VARIANT data type does not hide the intended format of the data, but for Visual Basic and C# programmers the format of the data may not be as obvious.
Since the VARIANT data type can represent almost any kind of data, the programmer often has to explicitly set the data type wished to use as a parameter. This is particularly important, when using data access methods.
An example of data access method SetValue The first parameter of the SetValue method is the data to be set. The parameter is defined as VARIANT (in Visual Basic) or object type (in C# environment). Second parameter is the value type.
This method can be used in Visual Basic, for example, the following way:
To support the scripting languages, the VARIANT data type often has to be used as parameter type. For C++ programmers, using VARIANT data type does not hide the intended format of the data, but for Visual Basic and C# programmers the format of the data may not be as obvious.
Since the VARIANT data type can represent almost any kind of data, the programmer often has to explicitly set the data type wished to use as a parameter. This is particularly important, when using data access methods.
An example of data access method SetValue The first parameter of the SetValue method is the data to be set. The parameter is defined as VARIANT (in Visual Basic) or object type (in C# environment). Second parameter is the value type.
This method can be used in Visual Basic, for example, the following way:
Dim data as String
data = "123"
GXProperty1.SetValue data, GX_VT_BYTE, False
In the C# environment, the VARIANT data type is shown as Object.
In C#, the method is used as follows:
string data;
data = "123"
GXProperty1.SetValue(data, GX_VT_BYTE, False);
The number 123, in the examples above, can be a byte, a word, an integer,
or some other data type, describing integer numbers. At the lowest level,
the communication is sending and receiving byte arrays.
There is no way of knowing, what type of data the programmer actually intends to use. If the exact size of the parameter is not known, the wrong size of the allocated byte buffer may result a data packet not understandable to the receiving device.
In C# language, the object data type is the base class of every class, including standard data types. When a parameter is specified in the accurate format, it is automatically accurate for methods that are specified to use the object type.
Note: A programmer should also be aware of the size differences of some data types between C# and C++. If basic VARIANT type is used with C++ language, the data type has to be explicitly set, since the VARIANT type is only a struct, with union of data type flag, and different data type members. There are also a number of VARIANT wrapper classes, such as CComVariant. The wrapper classes are designed to help the use of VARIANT data type. If such a class is used, the programmer should ensure that the data is set to correct format. VARIANT wrapper classes usually contain methods to change the data type.
GetValue | SetValue
There is no way of knowing, what type of data the programmer actually intends to use. If the exact size of the parameter is not known, the wrong size of the allocated byte buffer may result a data packet not understandable to the receiving device.
- CBool
- CByte
- CChar
- CDate
- CDbl
- CDec
- CInt
- CLng
- CObj
- CShort
- CSng
- CStr
In C# language, the object data type is the base class of every class, including standard data types. When a parameter is specified in the accurate format, it is automatically accurate for methods that are specified to use the object type.
Note: A programmer should also be aware of the size differences of some data types between C# and C++. If basic VARIANT type is used with C++ language, the data type has to be explicitly set, since the VARIANT type is only a struct, with union of data type flag, and different data type members. There are also a number of VARIANT wrapper classes, such as CComVariant. The wrapper classes are designed to help the use of VARIANT data type. If such a class is used, the programmer should ensure that the data is set to correct format. VARIANT wrapper classes usually contain methods to change the data type.
GetValue | SetValue
Using the components from development environment
Using from .NET | Using from Visual Basic | Using from C++ |