General advice
COBOL compiler differences
Different COBOL compilers can generate data items differently. The following list contains some pointers that you should be aware of:
•The COBOL record classes are implemented to support MicroFocus COBOL.
•Different compilers create records differently. If you are not certain of what is created, check the documentation that comes with your compiler.
For example, IBM 370 SAA COBOL and MicroFocus COBOL support non-SIGN SEPARATE negative numbers differently. The mapping of positive to negative numbers is different. VA Smalltalk provides classes to handle both compilers. Use AbtCOBOLHostNumericDisplay when working with IBM 370 SAA COBOL. Use AbtCOBOLNumericDisplay when working with MicroFocus COBOL and VA Smalltalk for COBOL.
•Storage of the COBOL COMP data type is processor dependent. VA Smalltalk stores COMP fields in a manner that is compatible with how MicroFocus COBOL stores COMP fields. VA Smalltalk COBOL has a different layout for COMP fields. To make VA Smalltalk COBOL COMP fields compatible with VA Smalltalk COMP fields, set the option in VA Smalltalk COBOL to BINARY(S370).
Passing pointers using the C External Function part
The C External Function part automatically manages pointers to simple data types. There are several behaviors that you should be aware of when manipulating pointers.
Accessing the data in a pointer
Pointer dereferencing for simple data types is accomplished using tear-off attributes. When an attribute with type AbtPointer is torn off, the resulting tear-off contains an attribute with a name matching that of the AbtPointer itself. This tear-off represents the dereferenced pointer that can be used to store data automatically into the pointer field and to retrieve data out of the pointer.
For example, consider the definition:
void myfunction ( long * field1 );
When the above definition is parsed from the C External Function prototypes page, the interface for the part is updated to include the parameter field1 (type=AbtPointer). At run time, this field stores the address of the long integer to be passed. AbtPointer fields can be stored and retrieved directly using this attribute.
When a tear-off attribute for field1 is created, the tear-off will also contain an attribute named field1 which represents the actual value of field1 (not the address of field1).
Storing and retrieving data from a pointer
VA Smalltalk does not automatically allocate memory for pointer fields. Rather, memory for an individual pointer field is allocated the first time data is stored into the field. Make sure that you initialize your pointer fields before you call your DLL.
Storing into char * fields
When VA Smalltalk initially stores data into a pointer to char, memory is allocated with a size large enough to contain the initially stored string.
When using fields of this type, initialize the field to the largest possible string for your external function.
Last modified date: 05/14/2020