Connecting parameters
Now you have given VA Smalltalk enough information to find the DLL and the procedure to call. The next step is to have VA Smalltalk parse the procedure declaration, so it knows how many parameters are required and what their data types are.
There are two ways to give VA Smalltalk the information it needs:
•Use the Record settings page to parse the include file or copybook for record declarations. You can then choose from the declared records to build up and order the procedure's parameter list and specify the procedure's return.
•Use the Prototypes settings page to parse the include file or COBOL source file for procedure declarations. You can then choose from the declared procedures, and the procedure's parameter list is built for you and given default names.
It is usually easier to use the Prototypes settings page, but you can use whichever technique you prefer. In this example, we will continue by using the Prototypes settings page.
Parsing
Select the Prototypes settings page. If you are using the C External Function part, type the full path name to catm.h or, if you are using the COBOL External Function, type the full path name to atm.cbl. If you prefer, use the Find push button to search your directories for the file you want. Select the Parse push button to have VA Smalltalk read the file and find any entry points and their parameters.
The parser will run much faster if your include or source file includes only the definitions it needs. If your file includes toolkit or compiler files, it will take much longer to parse.
From the list of procedure names, select atm (or ATM if you are using COBOL) and then select OK to save the settings.
After parsing, you can edit parameters from the Records page only. To view and access a record definition for editing, select Edit from the pop-up menu of the To be passed field of the Records page.
Using quick forms
When you return to the Composition Editor, notice that the public interface for the external function part has changed. Now, it includes the parameters needed for the function call:
•atmAction and pcustomer for C
•actionCode and atmCustomer for COBOL
Note:
Because C and COBOL naming rules are different from those of VA Smalltalk scripts, the parser automatically transforms variable and function names. All underscores or dashes are removed, and the first character is changed to lowercase for function names, or to uppercase for types, variables, and all other names.
To build the contents of the window part, create quick forms for the action code and customer record attributes. As you place each quick form in the window part, the attribute is torn off for you and all of the labels, text fields, and connections are created for you. Change the labels and alignment of the quick forms to make the window part look the way you want.
Add a push button and connect its clicked event to the execute action of the external function part.
Your final connections should look like the following:
Test your visual part. For the atmAction type 1 if you are using C, or Q if you are using COBOL. Enter 12345 as the pinNumber and then select Find to make the function call. The rest of the fields in your visual part will be filled in with the customer's data.
Last modified date: 05/14/2020