I need to create my own Singleton Class using Visual FoxPro 9.0
I tried this:
[pre]
oRef1 = CreateObject("Singleton")
oRef2 = CreateObject("Singleton")
oRef1.cTest = "Some Text"
?oRef1.cTest && Some Text
?oRef2.cTest && Prints nothing
Release oRef1, oRef2
Clear All
Return
*-- Singleton class
Define Class Singleton As Custom
cTest = ""
Procedire Init
If Type("This.Ref") = "U"
This.AddProperty("Ref", THIS)
Endif
Return This.Ref
Endproc
Enddefine
[/pre]
I can't get the same instance. Any help?
Thanks a lot!
I tried this:
[pre]
oRef1 = CreateObject("Singleton")
oRef2 = CreateObject("Singleton")
oRef1.cTest = "Some Text"
?oRef1.cTest && Some Text
?oRef2.cTest && Prints nothing
Release oRef1, oRef2
Clear All
Return
*-- Singleton class
Define Class Singleton As Custom
cTest = ""
Procedire Init
If Type("This.Ref") = "U"
This.AddProperty("Ref", THIS)
Endif
Return This.Ref
Endproc
Enddefine
[/pre]
I can't get the same instance. Any help?
Thanks a lot!