Highlighted
Honored Contributor.
Honored Contributor.
1042 views

CCW type project, can also be called from Managed?

Jump to solution

OK, I have put together a scenario where I have a Native Console COBOL program code calling (invoking) a Managed Win-Forms COBOL program code (class/method).  This was based on the CCW tutorial plus lots of additional assistance with things like Interfaces (thanks all!).  I have attached what I have so far in 2 zip files (2 different solutions - one for the caller and one for the called).

My question is:  How would I also "call / invoke" this very same code from another Managed program code (class/method) - (another Managed solution) ???

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: CCW type project, can also be called from Managed?

Jump to solution

It is actually much easier to call the managed WinForm app from another managed program as you do not go through the extra COM Interop layer.

Add a new managed console project to your ManWin1 solution called ManCon1 and add a reference to the ManWin1 project by right-clicking on References-->Add Reference then choose Solution and select the ManWin1 project and save.

Then paste the following code into the new Program1.cbl that was created.

       program-id. Program1 as "ManCon1.Program1".

       data division.
       working-storage section.
       01  junk                        pic x(01).
       01  anInstance     type ManWin1.vcClass.
       01  passed-info.
           05  passed-info-1           pic x(20).
           
       procedure division.

           display spaces upon crt.
           display "ManCon1 managed Console Program..." at 0303.
           display
            "...calling (invoking class method in) ManWin1..." at 0503.
       
           set anInstance to new ManWin1.vcClass
           move "this is passed info" to passed-info.
           invoke anInstance::method1(passed-info)
           
           
           display "...back from ManWin1..." at 0703.
           display "Press Enter to exit..."  at 0803.
           accept junk at 0903.
           
           goback.

       end program Program1.

View solution in original post

0 Likes
2 Replies
Highlighted
Honored Contributor.
Honored Contributor.

RE: CCW type project, can also be called from Managed?

Jump to solution

I think I need to re-attach the other zip...

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: CCW type project, can also be called from Managed?

Jump to solution

It is actually much easier to call the managed WinForm app from another managed program as you do not go through the extra COM Interop layer.

Add a new managed console project to your ManWin1 solution called ManCon1 and add a reference to the ManWin1 project by right-clicking on References-->Add Reference then choose Solution and select the ManWin1 project and save.

Then paste the following code into the new Program1.cbl that was created.

       program-id. Program1 as "ManCon1.Program1".

       data division.
       working-storage section.
       01  junk                        pic x(01).
       01  anInstance     type ManWin1.vcClass.
       01  passed-info.
           05  passed-info-1           pic x(20).
           
       procedure division.

           display spaces upon crt.
           display "ManCon1 managed Console Program..." at 0303.
           display
            "...calling (invoking class method in) ManWin1..." at 0503.
       
           set anInstance to new ManWin1.vcClass
           move "this is passed info" to passed-info.
           invoke anInstance::method1(passed-info)
           
           
           display "...back from ManWin1..." at 0703.
           display "Press Enter to exit..."  at 0803.
           accept junk at 0903.
           
           goback.

       end program Program1.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.