.NET Example

Consider the sample .NET control, AmortControl. Here is an excerpt from its COPY file, created with the NETDEFGEN utility. See Working with .NET Assemblies in A Guide to Interoperating with ACUCOBOL-GT for more information on using NETDEFGEN.

* .NET Copy Book - Generated On 3/5/2004 10:39:23 AM
     OBJECT @ASSEMBLY
     NAME "@AmortControl"
            VERSION "1.0.1266.13363"
            CULTURE "neutral"
            STRONG "null"
* AmortControl.UserControl1
     NAMESPACE "AmortControl"
     CLASS "UserControl1"
     MODULE "amortcontrol.dll"
         VISUAL
          CONSTRUCTOR,  0, @CONSTRUCTOR1
* System.String get_WhatIfMonths()
          METHOD,  0, "@get_WhatIfMonths"
                    RETURNING "BSTR", TYPE 8
* Void InitializeComponent()
          METHOD,  0, "@InitializeComponent"
* TotalInterest
          PROPERTY_GET, 0, @TotalInterest
                    RETURNING, "BSTR", TYPE 8
* FireCalc  ()
          EVENT, 520214344, @UserControl1_FireCalc

The get_WhatIfMonths method takes no parameters and returns a string of characters. To invoke this method from COBOL, you use the MODIFY verb:

MODIFY AmortControl-handle "get_WhatIfMonths" ( )
          GIVING MY-PICX-STRING.

The method has a return value that is converted and moved to the item specified in the GIVING clause of the MODIFY statement. To get the property TotalInterest:

INQUIRE ctl-handle TotalInterest IN TOT-INTEREST.