Skip to main content

Is it possible to associate an EVENT PROCEDURE with a non-gui handle to an instance of a .NET class?


#ACUCOBOL9.2.1
#non-guihandle
#.net
#Events

Is it possible to associate an EVENT PROCEDURE with a non-gui handle to an instance of a .NET class?


#ACUCOBOL9.2.1
#non-guihandle
#.net
#Events

I believe so, but am not positive. I assume you have tried this with some .net control, and didn't get the expected results. What did you try, what were you expecting, and what did you actually see happen?


Is it possible to associate an EVENT PROCEDURE with a non-gui handle to an instance of a .NET class?


#ACUCOBOL9.2.1
#non-guihandle
#.net
#Events

Good question. I was confused due to an omission in the documentation for the CREATE statement.

In the Reference Guide, it says this:

Format 2

CREATE   assembly-namecreates a non-graphical .NET object.

CREATE "assembly-name" 

NAMESPACE { IS } "namespace"

CLASS-NAME { IS } "class-name"
 
HANDLE { IN } object-handle
       { IS }

Remaining phrases are optional.

VERSION { IS } "version"

CULTURE { IS } "culture"

STRONG-NAME { IS } "strong-name"

CONSTRUCTOR { IS } CONSTRUCTORNo parameters...

MODULE { IS } "module"

FILE-PATH { IS } "file-path"

Notice that there is no EVENT PROCEDURE clause listed above for Format 2.

However, just now I noticed that there is an EVENT PROCEDURE clause in the sample program under: extend Programming Guides > A Guide to Interoperating with ACUCOBOL-GT Version 9.2.2 > Working with .NET Assemblies > Calling .NET from COBOL > Using .NET Assemblies in COBOL > Sample Program.

The sample program does this, which looks like the complete answer:

*CREATE  - instantiate a NON-GUI CLASS.
CREATE "@My.Assembly"
NAMESPACE IS "My.Test.Namespace"
CLASS-NAME IS "MyClass"
EVENT PROCEDURE IS EVENT-PROC
HANDLE IS MY-NONGUI-HANDLE.

Thanks for making me dig deeper. If possible, I'd like Micro Focus to update the Reference Guide so that this is better documented under Format 2 of the CREATE statement.


Is it possible to associate an EVENT PROCEDURE with a non-gui handle to an instance of a .NET class?


#ACUCOBOL9.2.1
#non-guihandle
#.net
#Events

Thanks! I will alert docs to get this corrected.