Highlighted
Respected Contributor.
Respected Contributor.
373 views

Passing Parameters in Visual COBOL (Managed COBOL)

Jump to solution

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.  

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Passing Parameters in Visual COBOL (Managed COBOL)

Jump to solution

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

View solution in original post

2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Passing Parameters in Visual COBOL (Managed COBOL)

Jump to solution

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

View solution in original post

Highlighted
Respected Contributor.
Respected Contributor.

Re: Passing Parameters in Visual COBOL (Managed COBOL)

Jump to solution

That worked, thank you!

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.