Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can an object know of it's existence?
Message
De
02/12/2003 13:58:17
 
 
À
02/12/2003 10:59:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00855003
Message ID:
00855128
Vues:
22
Hi Jim,

>And I do have a need for it, BTW. I am testing Download #20453, creating a multimedia timer requiring a callback. The only way I have found to set up the callback to operate properly is to pass it the obectname.procedure(), hence needing the NAME set to the object's reference. Just trying to get it down to omytimer = CREATEOBJECT("hptimer") if at all possible.

I haven't looked at the callback tool (but will be one of these days...)
The code should give you what you need: defaulting for the "automatic" name, either from creating or the name defined in the .prg or .vcx, with the option to overwrite it at create time.

My guess is, setting the name in the .prg / .vcx is the easiest way, but that can be personal preference.

If callback's are possible into methods of a subobject, PropSpermer() feels a little less awkward.

HTH

thomas
clear
CLEAR ALL
= PubSpermer("myclass")
= PubSpermer("myclass", "MySet1")
= PubSpermer("myclass1")
= PubSpermer("myclass1", "MySet2")
LIST MEMORY LIKE My*
= PubSpermer("myclass", "goMyStore")
= PropSpermer("myClass", "MyProp")
SET STEP ON 

FUNCTION ObjSpermer(tcClass, tcName)
return IIF(EMPTY(m.tcName), ;
		CREATEOBJECT(m.tcClass), ;
		CREATEOBJECT(m.tcClass, m.tcName) )

FUNCTION PubSpermer(tcClass, tcName)
LOCAL loTmp, lcVar
loTmp =  ObjSpermer( m.tcClass, m.tcName)
lcVar = loTmp.Name
IF TYPE(lcVar) == "U"
	PUBLIC &lcVar
	STORE m.loTmp TO (m.lcVar)
ELSE
	WAIT WINDOW lcVar + " already in scope!"
endif
return

FUNCTION PropSpermer(tcClass, tcName)
LOCAL loTmp, lcVar
loTmp =  ObjSpermer( m.tcClass, m.tcName)
lcVar = loTmp.Name
IF TYPE("goMyStore." + lcVar) == "U"
	goMyStore.Addproperty(m.lcVar)
	STORE m.loTmp TO ("goMyStore." + m.lcVar)
ELSE
	WAIT WINDOW lcVar + " already exists"
endif
return

DEFINE CLASS myclass AS CUSTOM
	PROCEDURE INIT
	LPARAMETERS tcObjName
		IF !EMPTY(m.tcObjName)
			this.Name = m.tcObjName
		endif
	ENDPROC
ENDDEFINE

DEFINE CLASS myclass1 AS myclass
	name = "MyDefined"
ENDDEFINE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform