Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cascading Assign bug
Message
De
23/10/2001 17:58:27
 
 
À
23/10/2001 16:34:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00572229
Message ID:
00572355
Vues:
29
>Hi Glen, I believe this one's by design. It has to do with how VFP loads class definitions into memory. For class properties and methods it racks this information once. Therafter subsequent instances share this information.
>
>To illustrate, try this:
>
>
>  DEFINE CLASS RatFace AS Custom
>    nTtest= SECONDS()
>  ENDDEFINE
>
>
>If you instance many objects of class Ratface, all will have the same nTest property. If on the other hand you do this
>
>
>  DEFINE CLASS RatFace AS Custom
>    Ntest= 0
>
>  FUNCTION INIT
>     This.ntest= SECONDS()
>  ENDDEFINE
>
>
>Then each instance gets its own nTest value, as you would expect.
>
>Therefore remember this: VFP stores class definitions once, and this information is shared by all subsequent instances of the class. This is a sensible optimization that reduces both the memory footprint and instantiation times of subsequent class instances.
>
>**--** Steve
>
>
>
>>I have had a problem with cascading assign events. See the attacjed code for an example. The first assign executes and then quits!
>>
>>
>>
>>local lo
>>clear
>>lo= createobject('cascader')
>>lo.changex()
>>lo.showx()
>>lo = ''
>>
>>define class cascader as container
>>	iMax	=	4
>>	function init
>>		local i
>>		for i = 1 to this.iMax
>>			this.addobject('c'+transform(i),'cobj',i)
>>		endfor
>>	endfunc
>>
>>	function changex
>>		set step on
>>		this.c1.x = 2
>>
>>	function showx
>>		local lxobj, i
>>		for i = 1 to 4
>>			lxobj = evaluate('this.c'+transform(i))
>>			? 'this.c'+ transform(i) +'.x = ' + transform(lxobj.x)
>>		endfor
>>
>>enddefine
>>
>>define class cObj as custom
>>	x	=	0
>>	i	=	0
>>
>>	function init
>>		lpara tni
>>		this.i = tni
>>	endfunc
>>
>>	function x_assign
>>		lparameters txVal
>>		local lxobj
>>		this.x= txVal
>>		if this.i < this.parent.iMax
>>			lxobj =	evaluate('this.parent.c'+transform(this.i+1))
>>			lxobj = lxobj.x + (2 * this.x)
>>		endif
>>
>>enddefine
>>
>>
>>Anyideas? Bug or Feature?
>>
>>Glenn

Thanks Steve,

I understand the static property value assignment as you illustrated, but I do not unerstand nor appreciate the dynamic event processing as per my illustration. Each object must have a unique entity in memory so that each may support independent data and behaviors, therefore each unique identity must fire its events in its own space and time.

This may be by "design" but I believe the design is flawed, aka "bug".


Thanks
Glenn
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform