User's Guide

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:

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

VisualAge 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 VisualAge initially stores data into a pointer to char, memory is allocated with a size large enough to contain the initially stored string.

Tip icon
When using fields of this type, initialize the field to the largest possible string for your external function.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]