An object of class PlatformFunction represents an external function. To create an instance of PlatformFunction, to call the function, and pass it the correct parameters, do the following:
For example:
aPlatformFunction := PlatformFunction callingConvention: 'c16' function: '_entrypoint' library: 'DLLNAME' parameterTypes: #( struct ) returnType: #none.Creating functions manually contains a table that shows the supported calling conventions, their meaning, and the platforms supported.
aRecordStructure := MyRecordStructure new.
aRecordStructure inputParm1: 'Input Value 1'. aRecordStructure inputParm2: 'Input Value 2'.
If a data field in a record structure is an array, IBM Smalltalk provides additional methods you can use to set the values of the items in the array. The method selectors are based on the names of the fields with At: or At:put: appended: For example, the following COBOL declaration:
01 Test PIC X OCCURS 5.
would result in the following generated selectors:
aPlatformFunction coroutineCallWith: aRecordStructure threadKey: nil.
The PlatformFunction method coroutineCallWith: calls the external function, passing it the parameters in the specified record structure. The argument threadKey: nil specifies that IBM Smalltalk should not run the function in a separate thread.
If you want to pass multiple record structures to the external function, you can use one of the following techniques:
To call the sample external function, create a new application called MyExtFunc, specifying MySampleCExtFunc or MySampleCOBOLExtFunc as its prerequisite (depending on the language you are using). If you are working with the C sample, add SampleCATMConstants to the list of pool dictionaries in the class definition; for the COBOL sample, add SampleCOBOLATMConstants to the pool dictionaries in the class definition.