Understanding record structures
To map VA Smalltalk objects into the flat memory structures used by most 3GLs, VA Smalltalk uses objects called Record Structures. Record structures are a staging area where the data passed to and from the external function is assembled.
The parameters that are added to the external function part's public interface are really record structures built by VA Smalltalk. If you look at the public interface for the C External Function part in this example, you will see three record structures:
hps
A long integer handle to a presentation space for drawing the graph
numPoints
A long integer indicating how many points to draw
aptl
An array of (x,y) coordinates
Because there is no quick form for the array of points, a script is required for setting this parameter. Also, hps, the presentation space, is an attribute of the form that is not included in the form's public interface, so you must set that value in a script also.
Setting the values for the first two parameters is easy; you can simply assign integer values to those attributes. To set up the array of points, you need to understand how VA Smalltalk maps these type definitions into a record structure.
typedef struct _PTL
{
long x;
long y;
} PTL;
typedef PTL PPTL10];
Internally, VA Smalltalk creates object tables, which are dictionaries of type information, much like type definitions in C or the data division of a COBOL program. For a structure like PTL, the record structure defined above, VA Smalltalk creates a compound type definition from the object table:
rsPoint := AbtCompoundType new name: #pointStruct;
addField: (AbtCLongField new name: #x);
addField: (AbtCLongField new name: #y).
For PPTL, which is an array of these record structures, aptl's record structure would then be created by these additional definitions:
rsArray := AbtArrayField new name: #pointArray;
count: (rows size);
arrayType: rsPoint.
array := rsArray newRecord.
Notice the class names AbtCLongField and AbtArrayField used in the previous scripts. These classes are the VA Smalltalk equivalent of C long integers and arrays.
For a complete list of C data types, COBOL data types, and their VA Smalltalk class equivalents, refer to Visual Programming User Reference.
Of course, VA Smalltalk handles the record structures automatically when it parses your C source code. But knowing about these structures gives you the information you need to write scripts that interface to external functions.
Last modified date: 07/27/2020