Restriction: |
---|
MicroFocus.COBOL.RuntimeServices are supported for .NET managed code only. |
MicroFocus.COBOL.RuntimeServicesInterop
Namespace: MicroFocus.COBOL.RuntimeServices
Assembly: MicroFocus.COBOL.RuntimeServices (in MicroFocus.COBOL.RuntimeServices.dll) Version: 1.2.3.4
The Interop type exposes the following members.
Name | Description | |
---|---|---|
CobCall(String) |
Calls the instance of a procedural program" with no parameters
| |
CobCall(String, Object) |
Calls the instance of a procedural program" with parameters
| |
CobCallObject |
Calls the instance of a procedural program" with parameters
| |
CobCancel |
Cancels the instance of a procedural COBOL program
| |
CobLoad |
Fetches the instance of a procedural COBOL program
|
A procedural COBOL program is represented by a singleton instance of a COBOL class. This instance is maintained by the run-time system. In order to invoke a COBOL method directly from another .NET language it is necessary to first locate this instance using the CobLoad method so that the entry points in it can then be directly invoked as methods. The COBOL program can also be cancelled using the CobCancel method.
In order to invoke a COBOL method you also need to add a reference to the MicroFocus.COBOL.Runtime assembly to your project.
Note: |
---|
You should never explicitly instantiate the class of a procedural COBOL program as this can lead to unpredictable behaviour. |
The following example shows a procedural COBOL program being called and then cancelled from another language.
C#:
using Sum; using System; using MicroFocus.COBOL.RuntimeServices; class MainClass { public static void Main(string[] args) { int n1 =3, n2 = 4, n3 = 0; SUM sum = (SUM)Interop.CobLoad("SUM"); sum.SUM(ref n1, ref n2, ref n3); System.Console.WriteLine("Total = " + n3); Interop.CobCancel("SUM"); } }
linkage section. 01 val1 pic s9(8) comp-5. 01 val2 pic s9(8) comp-5. 01 val3 pic s9(8) comp-5. procedure division using val1 val2 val3. add val1 to val2 giving val3. exit program.