Passing Parameters in Visual COBOL (Managed COBOL)

I am trying to pass a parameters from a Windows Form program to a regular program. For example. I have a TestForm.cbl which pertains to a form and looks roughly as follows in the solution explorer:

TestForm.cb

      TestForm.resx

       TestForm.Designer.cbl

 

This form is invoked by a regular program (program named is tps000.cbl) as follows:

           set TestForm to new TPSSTART.TestForm()

           invoke type System.Windows.Forms.Application::EnableVisualStyles()

           invoke Testform::ShowDialog.

 

 After the form is displayed, I want to be able to return a parameter or parameters back to tps000.cbl after the user has clicked on event/object on the form. For example, in the TestForm.cbl I have the following code:

method-id TestForm_FormClosing final private.

procedure division using by value sender as object e as type System.Windows.Forms.FormClosingEventArgs.

           IF ENTER-FLAG = 0

            goback returning ENTER-FLAG

           END-IF.

end method.

 

The above code of returning an enter flag obviously does not work because that is not the way to pass parameters. I want to know how to pass parameters between form programs and non-form programs.  

  • Verified Answer

    The simplest way to achieve this is to define one or more properties on the form which you can set during the lifetime of the form and retrieve after calling ShowDialog. At the top of the form class, define some data items such as:

    01 EnterFlag binary-long property.
    01 MyMessage string property.
    

    You can set these data items anywhere in the form:

    method-id TestForm_FormClosing final private.
    procedure division using by value sender as object e as type System.Windows.Forms.FormClosingEventArgs.
        set MyMessage to "test message"
    end method
    

    Then in your procedural program, you retrieve them by doing some thing like:

    set testf to new TPSSTART.TestForm()
    invoke testf::ShowDialog
    set enter-flag to testf::EnterFlag
    display testf::MyMessage