>Yes, I was thinking of having a class that could return references to it's own instances of the required classes.
>
>Thanks
>
>Kev
>
>>I doubt you can do it the normal way. Load and Init are events, not methods. You'd have to have whatever class is creating the object first check to see if it already exists and then instantiate it or not as required. It could be as simple as checking "Type('MyObject.Name') = 'C'
>>
>>I suppose you might do it in the Load, but I think it would be simple to do it before.
>>
>>Alan
>>
>>>Hi
>>>
>>>Is this possible from VFP?
>>>
>>>Thanks
>>>Kev
Sorry the last message is incomplete, this is the complete.
>Hi
>
>Is this possible from VFP?
>
>Thanks
>Kev
Is the most near I´m from a Singleton Pattern in VFP ;-D
LPARAMETER loMyObject
loMyObject = .NULL.
loMyObject = THIS.IAmAlone()
IF ISNULL(loMyObject)
ELSE
RETURN .F.
ENDIF
LOCAL loReturn
loReturn = .NULL.
LOCAL ARRAY aClassInst[1]
DIMENSION aClassInst[1]
LOCAL lcClassSeft, lnClassInst
lcClassSeft = this.Class
lnClassInst = 0
lnClassInst = AINSTANCE(aClassInst, lcClassSeft)
IF lnClassInst > 0
loReturn = aClassInst[1]
ENDIF
RETURN loReturn
This code no assure a unique instance, but is the most I can do.
Regards,
José Luis.
Quidquid latine dictum sit, altum sonatur