Properties, Styles, and Methods

ActiveX controls have properties and styles just like ACUCOBOL-GT controls. In addition, ActiveX controls provide functions called methods. To set a property or style or to invoke (call) a method, you use the MODIFY verb. Use INQUIRE to get the value of a property or to get the style flags.

ActiveX methods can take any number of parameters or no parameters. They can also take optional parameters (i.e., parameters that can be omitted). You specify the parameters in COBOL by enclosing them in parentheses. If there are no parameters, include empty parentheses (). Optional parameters are always last. For example, if a method has three parameters, one of which is optional, the first two are required. The last one is optional and therefore may be omitted. For more information on ActiveX methods, refer to ACUCOBOL-GT User Interface Programming > Supporting Concepts > Methods .

Note that ActiveX properties and methods should always be prepended with an "@" sign in case they clash with COBOL reserved words or ACUCOBOL-GT graphical control property and style names. The "@" symbol identifies the relationship of the name to ActiveX. The same holds true for ActiveX enumerators.

When programming with ActiveX controls and COM objects, you can create simpler statements by using named parameters. ActiveX controls and COM objects provide the option of using named parameters as a shortcut for typing parameter values in MODIFY and INQUIRE statements. With named parameters, you can provide any or all of the parameters, in any order, by assigning a value to the named parameter. This is especially useful when an ActiveX/COM method or property has several optional arguments that you do not always need to specify.

Note: You cannot use named parameters to avoid entering required parameters. You can omit optional parameters only.

Generally, if the COBOL program passes a parameter in binary or numeric form with no decimal point, the runtime creates a variant of type VT_I4 (4-byte signed integer) before passing it to the property or method. If the program passes the parameter in numeric with a decimal point or in floating point, then the runtime creates a variant of type VT_R8 (8-byte floating point number). And if the COBOL program passes an alphabetic or alphanumeric parameter, then the runtime creates a variant of type VT_BSTR (Unicode string) before passing it to the property or method.

Note that you do not have to make a conversion from an ACUCOBOL-GT Working Storage item to a variant datatype in order to pass data to an ActiveX/COM property or method. The runtime handles all conversion that is required for you. For example, if you have a method in your definition file like this:

METHOD, 10, @Send,
     "VARIANT" @From, TYPE 12,
     "VARIANT" @To, TYPE 12,
     "VARIANT" @Subject, TYPE 12,
     "VARIANT" @Body, TYPE 12,
     "VARIANT" @Importance, TYPE 12

You do not have to convert your data before passing it. Rather, all you need to consider is what data to pass. (The runtime does the conversion so focus on the content.) In this case, you would pass sender, recipient, subject, message, and importance.

If the ActiveX or COM object with which your program is interacting expects the parameter of a different variant type, you must tell the runtime by using the AS type-num phrase in the parameter expression of the MODIFY or INQUIRE statement (where type-num indicates the variant type to pass). The runtime then converts the parameter to the variant type that you specify before passing it to the object.

You can tell from the object's documentation and the name of the parameter whether the object expects a particular variant type, such as boolean.