


When programming with ActiveX controls and OLE objects, you can MODIFY property values using COBOL data items, literals, and figurative constants. You can also pass them as parameters to methods using MODIFY.
When passing parameters to an ActiveX control or OLE object method, the ACUCOBOL-GT runtime converts the COBOL parameters into VARIANT parameters. VARIANT parameters have a data type associated with them. There are over 40 different VARIANT types. Each type name starts with "VT_". For example, VT_I4 is a four byte signed integer. VT_R8 is an 8 byte real (floating point) number. VT_BSTR is a string. The rules applied by the runtime to determine the VARIANT type are given at the end of this section.
A method or property can act differently depending on the type of data passed to it in a VARIANT. For example, there is a type of VARIANT parameter called VT_UNKNOWN, commonly used to represent OLE objects. A property or method might expect either VT_I4 or VT_UNKNOWN (i.e., IUnknown pointer) and will act differently depending on which one it receives (see section 3.7.1 "AXDEFGEN Copybooks " for more information on IUnknown). If the runtime converts an OLE object handle to a VT_I4 instead of a VT_UNKNOWN, the property or method being called might not act as expected. The runtime determines which of the two VARIANT types to pass based on the USAGE parameters of the COBOL data item.
There is also a generic VARIANT type named VT_VARIANT. Some ActiveX and OLE methods and properties take VT_VARIANT parameters. This usually means that they accept more than one type of VARIANT parameter. For example, you could pass a VT_I4, VT_R8, or a VT_BSTR as a VT_VARIANT parameter. The ActiveX or OLE property or method could convert the passed parameter into a specific VARIANT type. It could also act differently depending on the type of VARIANT that was passed. For example, suppose an ActiveX or OLE object had a table where rows could be referred to by a character string name or by their numeric index. A method that returns a row in the table could take either the name or index of the row as a parameter. The method could assume that if the parameter is a VT_BSTR, it is a row name; and if the parameter is a VT_I4, it is a numeric index.
If the ActiveX control or OLE object property or method parameter is one of the standard VARIANT types, ACUCOBOL-GT will do its best to convert the COBOL data to the expected type. For example, if an ActiveX control property is type VT_I4 (i.e. 4 byte integer), and the COBOL data type is PIC X(10), ACUCOBOL-GT will try to convert the value of the PIC X(10) item into a number and pass it as a VT_I4 type VARIANT.
If the property or method parameter type is VT_VARIANT, then ACUCOBOL-GT converts the COBOL data item into a specific VARIANT type parameter using the following rules:
1. The PICTURE and USAGE clause determine the type.
2. If the data item is alphabetic, alphanumeric, or alphanumeric edited, it is passed as a VT_BSTR.
3. If the data item is USAGE HANDLE or POINTER, and the property or method parameter type is VT_VARIANT, it is passed as a VT_UNKNOWN. If the data item is another binary (USAGE COMP-..., BINARY, HANDLE, POINTER, etc.), it is passed as a VT_I4.
4. If the data item is USAGE FLOAT or DOUBLE, it is passed as a VT_R8. If the data item is another numeric type, it is passed as a VT_I4.