Today's Smalltalk 4 You looks at making external API calls using VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:
You can also watch it on YouTube:
Today we'll take a look at how to make external API calls from VA Smalltalk. IN this example, we'll call the MessageBoxA API in Windows:
The code looks like this:
| pf | pf := PlatformFunction fromArray: #('C' 'MessageBoxA' nil 'user32.dll' #(#uint32 #pointer #pointer #uint32) #int32). pf callWith: PlatformGlobals::HwndNull with: 'this is some text' asPSZ with: 'this is a caption' asPSZ with: PlatformConstants::MbYesno
To understand what's going on in the ByteArray of arguments, have a look at class PlatformFunction:
Bear in mind that this example is a bit artificial; the class CwPrompter exists in VA< and uses this API already. However, it does give you a simple example of making an API call, and you can follow the same pattern for your own work.
Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.
[st4u240-iPhone.m4v ( Size: 3344361 )]