To Create and Pass .NET Objects as Parameters

  1. In the special names paragraph of your COBOL program, define the namespace/class of @MICROFOCUS.NETOBJECT. For example:
    COPY NetObjects.def

    The definition file generated by NetDefGen should not be modified.

  2. In the working storage section of the COBOL program define the data type that will hold the reference to the .Net object. For example:
    77 MyTimeObject1       usage handle of OBJECT value 0. 
    77 MyTimeObject2       usage handle of OBJECT value 0. 
    77 MyFontObject        usage handle of OBJECT value 0. 

    The data type must be identified as HANDLE OF OBJECT.

  3. Use the new data type to refer to .Net objects that can be retrieved or passed. For example:
    inquire NetListBox1 @MyClickTime MyTimeObject1 
    inquire NetListBox2 @MyClickTime MyTimeObject2 
    inquire NetFontSelect @SelectedFont MyFontObject 
    modify NetListBox1 "@compareTimes" (MyTimeObject2)  
                              giving ws-ticks  
    modify NetListBox2 "@setFont" (MyFontObject) 
  4. To invoke GET/PUT properties or method calls on the .Net object, add the def file you careated with NetDefGen to the SPECIAL-NAMES section of your COBOL program.
  5. Since all GET/PUT properties and method calls for all .Net objects are defined under a single, generic NetObject class, you must take care not to call a method or use a property that does not belong with the object you are trying to modify. Errors of this nature will not be detected until runtime and will result in the property/method not being found.
  6. Prior to invoking the inquire/modify statements on a .Net object, make sure that the object handle has a value greater than 0, otherwise you will encounter an error. Finally it is good programming practice to destroy objects that outlive their usefulness.