Adding the parts
Begin by creating a new visual part. Add a Form part and a Push Button part. Open the settings of the Form part and set the border width to 1. Change the label of the Push Button part to Draw.
Setting the points
To hold the list of points that are graphed, add an ordered collection. To create an attribute-to-script connection that fills in its contents, connect its self attribute to the following script:
defaultRows
"Answer some dummy data"
| collection |
collection := self subpartNamed:
'Ordered Collection1'.
collection add: 0@0;
add: 50@50;
add: 90@25;
add: 120@125;
add: 145@110;
add: 170@120;
add: 180@105;
add: 200@130.
^collection.
Creating the function interface
Add a C External Function part to any open space of the free-form surface. Open the settings for the external function part and change the following settings:
File name
Type CGRAPH, the dynamic link library where the procedure is stored.
Entry point name
Type drawGraph, the name of the procedure to call. Remember that this name is usually case-sensitive, depending on the options you use when creating the DLL. Notice the /NOI link option in cgraph.mak that maintains case-sensitivity in this example.
Entry point type
Select 16 or 32, depending on whether your compiler produces 16- or 32-bit object code.
Calling convention
Select C.
Use the Prototypes page to parse the include file, cgraph.h, and build the function's parameter list. From the list of procedure names, select drawGraph and then select OK to save the settings.
Note:
Because cgraph.c includes many of the OS/2 toolkit's include files, be sure that you parse cgraph.h, instead of cgraph.c.
Tip icon
The parser will run faster if you suppress the informational and warning messages that are displayed in the System Transcript, by executing these statements:
AbtCLangParser messageLevel: 0.
AbtCOBOLLangParser messageLevel: 0.
Also, VA Smalltalk normally keeps a DLL open until you shut down VA Smalltalk. This can be an inconvenience during development when a DLL needs to be replaced after rebuilding it. To force VA Smalltalk to close the DLL send the closeLibrary message to your External Function part.
Because this function takes an array as a parameter, a script is required to set up the data properly.
Last modified date: 05/14/2020