Article Preview
Buy Now
FEATURE
Inside Xojo
Exploring Delegates, WebFile, and WebPicture
Issue: 15.2 (March/April 2017)
Author: Christian Schmitz
Author Bio: Christian Schmitz is the creator of the Monkeybread Software Xojo Plugins.
Article Description: No description available.
Article Length (in bytes): 24,653
Starting Page Number: 27
Article Number: 15204
Related Link(s): None
Excerpt of article text...
There are often features of Xojo that we forget about or don't fully use. Today we'll explore a few of these more deeply. In particular, we'll explore delegates, WebFile, and WebPicture.
Delegates
How to pass function pointers
With REALbasic 2007 Release 4 the new delegate feature was introduced to the language. You can declare delegate data types, use them for properties, assign methods, and invoke them. This is excellent for callbacks or to keep a list of functions around for calling by name or index. And, of course, for declares, it is very handy to pass Xojo functions to be called from a C library.
Delegates decouple the interface of the code from its implementation. This is comparable to events or interfaces in Xojo. Somewhere you declare the interface to a method, somewhere else you have a method which you assign, and somewhere else you call it. With the decoupling, you can treat methods as variables and pass them around. You can even store them in a dictionary!
Defining a delegate
...End of Excerpt. Please purchase the magazine to read the full article.