Calling a C platform function from a method
For the C sample add the following method in your application:
invokeCATM
"This method calls the C ATM function in the CATM DLL.
The method assumes the record wrapper has already been
created and that the constants in the CATM sample
structure have been placed in a pool dictionary"
| atmStruct platformFunction |
atmStruct := SampleCATMStruct new.
atmStruct pinNumber: '12345'.
platformFunction := PlatformFunction
callingConvention: 'c'
function: 'atm'
library: 'catm'
parameterTypes: #(uint32 pointer)
returnType: #none.
platformFunction coroutineCallWithArray:
(Array with: AtmQuery with: atmStruct)
threadKey: nil.
Transcript show: (atmStruct firstName); cr;
show: (atmStruct lastName); cr;
show: (atmStruct checkingBalance); cr.
Type the following on the System Transcript window and run it:
MyExtFunc new invokeCATM
You should see the following on your System Transcript window:
John
Smith
7890.03
 
Tip icon
The example above specified atm for the function to be called. This can be done because the make file preserved case sensitivity by using the link /NOI option. If /NOI was not specified for the link in the make file, you would have specified ATM. Be sure you understand the link options being used for the library when creating a platform function.
Last modified date: 05/15/2020