Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Call win forms from native cobol program with copy books

$
0
0

Hi,

When passing parameters from native code to managed code COBOL you cannot directly use a COBOL group item in the linkage section. You can instead define the group item as a string and then set the group item to this string.

I have fixed your two programs so that they now work.

Calling native program:

      $set ooctrl(+p) 
       identification division.
       program-id. Program1.
       class-control.
           objClass is class "$ole$WinForms.CallingClass".
       configuration section.

       data division.
       working-storage section.
        01 objInstance object reference.
           COPY "NAME.CPB".
      
       procedure division.
           invoke objClass "new" returning objInstance
           invoke objInstance "openForm1" using "Form 1 opened"
           invoke objInstance "openForm2" using "Form 2 opened"
           move "Hello" to name-test
           move "world" to details
           invoke objInstance "openForm3" using WW-TEST-RECORD
           
           goback.

       end program Program1.



Called managed class:

       class-id WinForms.CallingClass.

       working-storage section.
       01 objForm type System.Windows.Forms.Form.
       method-id InstanceMethod.
       local-storage section.
       procedure division.

           goback.
       end method.
       method-id openForm1.
       procedure division using frmTitle as string.
           set objForm to new type WinForms.Form1
           set objForm::Text to frmTitle
           invoke objForm::ShowDialog()
           goback.
       end method.
       method-id openForm2 public.       
       procedure division using frmTitle as string.
           set objForm to new type WinForms.Form2
           set objForm::Text to frmTitle
           invoke objForm::ShowDialog()
           goback.
       end method.    
       
       method-id openForm3.  
        copy "NAME.CPB".     
       procedure division using astring as string.
           set WW-TEST-RECORD to astring
           set objForm to new type WinForms.Form2
           set objForm::Text to WW-TEST-RECORD
           invoke objForm::ShowDialog()
           goback.
       end method.
         end class.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>