I’m creating properties within a new class in my plugin but have come across a problem…how are arrays treated in the SDK so I can access them via Xojo.
For example I have a custom class and I want to have a property which is an array of objects. The following is an example of string of course:
[code]dim Fruits() as FruitData = array(“Apple”, “Orange”, “Banana”, “Pineapple”)
MyClass.MyFruits() = Fruits[/code]
How do I treat the getter and setter functions in the SDK to make this work? Is it a REALobject or REALarray? Can’t seem to work this out. Can’t find an example. Any help appreciated.
It is a REALarray and also a REALobject in the terms of you can retain the Array by calling REALLockObject and REALUnlockObject if you want to store reference to it in your plugin.
The SDK has accessors to get elements from your array. There is also Insert and UBound, but no Delete or Append.
So for your example above where your assigning the Object to your class then you will probably want to call REALLockObject on it to retain it while your class wants to own the reference and then in your destructor you will want to call REALUnlockObject on it.
My plugin won’t load and in fact clobbers other plugins as well if I include the double parenthesis "AlertsData()", but will if I remove them. AlertINFD2 is a custom class defined in my plugin.
You can not have a computed property to be an array in Xojo, hence my question above.
Remove the computed property and instead create two methods which act as a getter and a setter. Use the Assigns keyword on the setter so that user in Xojo can use it in an assignment statement instead of a Sub call.
[quote]REALproperty
This structure is used by a plugin to define a property or a computed property. The difference between the two fundamental types is that a computed property defines a REALproc for the getter and/or setter, while the non-computed property specifies REALstandardGetter and/or REALstandardSetter.
…
getter: a REALproc for a computed property’s getter, which should be declared as @Type@ GetterName( REALobject, long ). The second parameter is the value specified in the “param” field. Use REALstandardGetter and the “param” field to create a non-computed property (see “param” field for more information).
setter: a REALproc for a computed property’s setter, which should be declared as void SetterName( REALobject, long, @Type@ ). The second parameter is the value specified in the “param” field. Use REALstandardSetter and the “param” field to create a non-computed property (see “param” field for more information).[/quote]
So you need to use REALstandardGetter and REALstandardSetter. As soon as you provide your own getter or setter method, it becomes a computed property.
Like I said, all properties registered by the plugins API are computed. The documentation is wrong and the current behavior dates back at least a decade. A bug report against the documentation would be helpful if you have time.
That they are computed properties in the plugin is clear, but when using REALstandardGetter and REALstandardSetter don’t they become regular properties within Xojo?
Maybe the bracket () is on wrong thing ? as in should not be on AlertsData but on AlertINFD2.
And of course as they say don’t use REALstandardGetter and REALstandardSetter, And remember when you make the Getters and setters that they also take RBInteger param (if not then your asking for getting crash)
If I remove the parenthesis(), the compiler becomes happy again, but doesn’t recognise the property as an array, which I need it to do so I can access the array elements via the standard dot notation.