NOTICE: Our Community is moving. Get more information.
Customer has a Windows Forms application which is comprised of a C# WinForm project and a COBOL class library project. Several text boxes are entered on a C# form which then calls a COBOL program to do the validation.The C# project has a reference to the COBOL project so that it can create an instance of the COBOL program before calling it. There are several ways to pass the text box values to the COBOL program.
1. Pass them in linkage, including use of smart linkage (can use smart linkage if the COBOL program is not a class).2. Declaring properties in the COBOL program and setting them from the C# program before calling it.3. Passing the Windows form object to the COBOL program and using its Controls collection to get the Text properties of each text box that needs to be validated.
What is the best method to making the textbox data available to the COBOL program?
What you suggest here in point 3 breaks all rules of encapsulation as those form control fields are marked as private for a reason.
You could create properties or public methods in C# for each of the textbox controls so that you can return the value of these fields when the method is called.
You could then create an interface definition in a separate project that defines each of these properties or methods and you could pass the current form to the COBOL class as a parameter of the interface type so that its methods could be called. You would add references to the interface project in both the C# and COBOL classes.
What I would really suggest is that you create a separate data only class containing properties that you could instantiate and populate in C# and then pass this class to COBOL as a parameter. This just seems like a much simpler and cleaner approach.
Attached is an example.