Big news! The community will be moving to a new platform April 21. Read more.
Big news! The community will be moving to a new platform April 21. Read more.
Absent Member.
Absent Member.
3216 views

Winforms: calling 2nd form

Jump to solution

I am working through "Tutorial: Developing .NET Managed COBOL", trying to learn Visual COBOL. 

I developed Form1, then Menu1 and made it my startup program - all fine and working.  Then to extend the exercise I added a button to Menu1 to call Form1  using the cobol command

call "Form1".

but it fails with error "173 Called program file not found in drive/directory [Form1]"

What can I be doing wrong?  Please help!  Surely the syntax is correct, and both forms can be seen in Solution Explorer.

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

The call statement is used to execute COBOL procedural programs as subprograms.

When you want to call a method in a COBOL class such as a Windows Forms class you need to instantiate the class as an object and then invoke its methods using the COBOL invoke statement.

You might want to take a look at the managed COBOL Concepts section of the docs here:

Example:

       method-id button1_Click final private.
       01 myform  type testform2.Form2.
       procedure division using by value sender as object e as type System.EventArgs.
           
           set myform to new testform2.Form2
           invoke myform::ShowDialog

View solution in original post

0 Likes
7 Replies
Micro Focus Expert
Micro Focus Expert

The call statement is used to execute COBOL procedural programs as subprograms.

When you want to call a method in a COBOL class such as a Windows Forms class you need to instantiate the class as an object and then invoke its methods using the COBOL invoke statement.

You might want to take a look at the managed COBOL Concepts section of the docs here:

Example:

       method-id button1_Click final private.
       01 myform  type testform2.Form2.
       procedure division using by value sender as object e as type System.EventArgs.
           
           set myform to new testform2.Form2
           invoke myform::ShowDialog

View solution in original post

0 Likes
Absent Member.
Absent Member.

Thank you - that works, and I understand more, so a double win!

0 Likes
Vice Admiral
Vice Admiral

Chris,

the link to the docs appears to be broken...

0 Likes
Micro Focus Expert
Micro Focus Expert

You might want to try this one

–Ғɑɳօ
0 Likes
Vice Admiral
Vice Admiral

Hmmmm.   It appears to be the new 2.3 doc.  Thanks, although I was unable to find the specific Managed-calling-Managed subject matter in the above examples.

0 Likes
Micro Focus Expert
Micro Focus Expert

What is it exactly that you are looking for? The section on Interoperability talks about various calling techniques that can be used to call between native/managed, etc. There are also some tutorials that cover this topic within the knowledgebase.

Go to the search bar at the top right-hand side of this page and click on the arrow and select Search Visual COBOL. Then enter in the search term:

    call statement

You should see 5 articles listed under the Wiki category where each article covers a different calling scenario for native and managed combinations.

Is this what you are looking for?

0 Likes
Vice Admiral
Vice Admiral

Here is what I found:

1. this forum article itself in the forum

2. A wiki titled "Handle multiple WinForm forms in Visual COBOL"

3. A forum article "using 'Call' in Method

4. A wiki article "Visual COBOL for Visual Studio Getting Started with Solutions, Projects and the COBOL CALL Statement - Managed" that included a "2433_Visual COBOL Call Managed Tutorial.zip" and some related wiki articles covering other types of mixed calls, etc.

From these, I gleaned what I needed to know.  Sometimes it isn't very easy to find what you are looking for in the "official" Doc.

Thanks

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.