Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Class property bug?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00489001
Message ID:
00489011
Vues:
14
This is really funny. It looks like by assigning the name property -outside the Init method- you are renaming both the class AND the created object. I never saw this before.

I rewrote the "C" class like this and that seems to give the expected result.
DEFINE CLASS "C" AS Custom
*	name = "D"
	proc init
		this.Name = "D"
	endproc
ENDDEFINE
>I came across an interesting anomaly with the Class property and was wondering if anyone else thought this was a bug. Try the following code:
>------
>
>LOCAL x, y
>CLEAR
>
>x = CREATEOBJECT("A")
>? "x.name = " + x.name
>? "x.class = " + x.class
>?
>
>y = CREATEOBJECT("C")
>? "y.name = " + y.name
>? "y.class = " + y.class
>
>RELEASE x, y
>RETURN
>
>DEFINE CLASS "A" AS Custom
> PROC Init
> THIS.Name = "B"
> ENDPROC
>ENDDEFINE
>
>DEFINE CLASS "C" AS Custom
> Name = "D"
>ENDDEFINE
>
>-----
>In the first example, class A returns a classname of “A” and a name of “B”, which is correct. In the second example, class C returns a classname of “D” and a name of “D”, which is dead wrong. Somehow, the class name is migrated to the name value. The code produces the same results under all version of VFP, including 7.
>
>Thanks,
>Keith
Hector Correa
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform