ActiveX Example

Consider the ActiveX control, Microsoft Rich Textbox Control 6.0. Here is an excerpt from its COPY file, created with the AXDEFGEN utility. See Using ActiveX Controls and COM Objects in A Guide to Interoperating with ACUCOBOL-GT for more information on AXDEFGEN.

...
      * LoadSave constants.
           
      * LoadSaveConstants
           CLASS @LoadSaveConstants
               CLSID, 9FAEAB20-894B-11CE-9576-0020AF039CA3
               NAME, "LoadSaveConstants"
      * long rtfRTF
               ENUMERATOR, @rtfRtf, 0
      * long rtfText
               ENUMERATOR, @rtfText, 1
           
...
      * Microsoft Rich Textbox Control 6.0
           
      *** Primary Interface ***
           
      * RichTextBox
           CLASS @RichTextBox
               CLSID, 3B7C8860-D78F-101B-B9B5-04021C009402
               NAME, "RichTextBox"
...
      * LoadFile
      * Loads an .RTF or text file into a RichTextBox control.
               METHOD, 37, @LoadFile,
                   "BSTR bstrFilename",
                   "VARIANT vFileType"
                       OPTIONAL 1
...

The LoadFile method takes two parameters: bstrFilename and vFileType. vFileType is an OPTIONAL parameter. bstrFileName is a BSTR type, and vFileType is a VARIANT type. To invoke this method from COBOL, you use the MODIFY verb:

  MODIFY RICH-TEXT-BOX-1 LoadFile ("myfile.rtf", rtfRtf).

The ACUCOBOL-GT run-time system automatically converts the parameters to the appropriate type and invokes the method. The LoadFile method does not have a return value. If the method had a return value that was not void, it would be converted and moved to the item specified in the GIVING clause of the MODIFY statement.

The syntax is as if LoadFile is a property whose value is its parameter list. For example, the following is also valid:

  MODIFY RICH-TEXT-BOX-1 PROPERTY 37 = ("myfile.rtf", rtfRtf).

Note that 37 is the property number of LoadFile. The equals sign is optional. Commas in the parameter list are optional. The parameters may be arithmetic expressions.