CallableAttribute Class

MicroFocus.COBOL.RuntimeServices

Makes non-COBOL static methods callable from COBOL with the verb CALL.

Restriction:
MicroFocus.COBOL.RuntimeServices are supported for .NET managed code only.
Inheritance Hierarchy

SystemObject
  SystemAttribute
    CallableAttribute
      MicroFocus.COBOL.RuntimeServicesCallableAttribute

Namespace:  MicroFocus.COBOL.RuntimeServices
Assembly:  MicroFocus.COBOL.RuntimeServices (in MicroFocus.COBOL.RuntimeServices.dll) Version: 1.2.3.4
Syntax

[EditorBrowsableAttribute(EditorBrowsableState.Never)]
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method)]
public sealed class CallableAttribute : CallableAttribute

The CallableAttribute type exposes the following members.

Constructors

  NameDescription
Public methodCallableAttribute
Makes non-COBOL static methods callable from COBOL with the verb CALL.
Top
Remarks

In early version our .Net products, you could call a non-COBOL static method from COBOL using the verb CALL. This caused the COBOL Compiler or run-time system to use the first method it found with the required name and signature. This might have been a COBOL-enabled method or unexpectedly a .NET Framework method.

Note: that this relates only to the COBOL CALL/CANCEL verbs. Any method can be invoked by using the INVOKE verb, or inline invocation syntax.

Now, you are required to the MicroFocus.COBOL.RuntimeServices.CallableAttribute attribute on the non-COBOL methods and on the class and assembly containing them. This then enables you to call the methods from COBOL safely. The COBOL Compiler automatically applies this attribute to procedural COBOL programs at the assembly, class and method level.

To apply the attribute manually:

  1. Set the MicroFocus.COBOL.RuntimeServices.CallableAttribute attribute on the assembly, class and method that is to be called. This attribute is in the MicroFocus.COBOL.RuntimeServices assembly.
  2. Add the following references to your project before compiling: MicroFocus.COBOL.RuntimeServices and MicroFocus.COBOL.Runtime. You can add these using Add References within Visual Studio.

Note: The attribute needs to be applied to the Assembly, Class and Method.

Examples

The following example, in C#, shows the attribute placed on the assembly, class and method that is to be called:
C#
[assembly: MicroFocus.COBOL.RuntimeServices.CallableAttribute()]
[MicroFocus.COBOL.RuntimeServices.CallableAttribute()               
public class MyCs
{
   [MicroFocus.COBOL.RuntimeServices.CallableAttribute()]
   public static void MyCS()
   {
   }

   [MicroFocus.COBOL.RuntimeServices.CallableAttribute()]
   public static int GetMeaningofLife()
   {
       return 42;
   }
}
See Also

Reference