Constructor

Greetings all!

I’m creating my own custom plugin for Windows and am having great success thus far converting my classes, but I’ve hit a snag.

How does the Constructor method work in the plugins SDK?

I’ve created a Constructor method with no parameters e.g. a zero constructor which works fine, but when I attempt to add another constructor method with a parameter of a REALstring, Xojo crashes. I must be doing something wrong. BTW the DLL I create compiles fine.

[code]static void ConstructorGaol(REALobject instance, long param, REALstring gaol)
{
ClassData(HousingData2_Definition, instance, HousingData2Data, me);

REALUnlockString(me->sGaol);
me->sGaol = gaol;
REALLockString(me->sGaol);

}[/code]

Could anyone please supply me an example of how it’s supposed to be done?

Cheers
Grant

if would only call REALUnlockString and REALLockString if parameter is not nil.

Thanks Christian and Jean-Paul. Is it a bad thing to lock null REALstrings?

Cheers
Grant

[quote=288481:@Grant Singleton]Thanks Christian and Jean-Paul. Is it a bad thing to lock null REALstrings?

Cheers
Grant[/quote]

REALLockString and REALUnlockString internally got NULL check so if you get null string passed in then you do not really have to check if its null. NULL string in Xojo is treated as empty string.

Well, which version got that NULL check?

And an if() there doesn’t hurt and avoids the extra function call.

Just for the record, this is entirely correct and probably dates back to the first plugin SDK.

Yes Andrew Barry gave guaranty that the Lock and Unlock commands did internally NULL checks back then.