Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: Set class's Name change the object's Class property
Message
De
06/12/2007 08:20:51
Lutz Scheffler (En ligne)
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
06/12/2007 07:57:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01273530
Message ID:
01273546
Vues:
13
Hi Alan,

no the name of the class(IOW: .class) should not change. Only the name of the object. Common mistake under VFP developers to mix the class and the instance. <g>

On the opposit the name in the class definition changes the classes name. (The word used after DEFINE CLASS is used only for the instantiation itself (to find the class), but later the name out of the class definition is used for .class)

If you skip the name in class definition, it will use the default.

Fabio checked the wrong thing
CLEAR

lof=CREATEOBJECT("ClassName")
?lof.name
lof.name = 'bla'
*new name, old class (why should the class change?)
?lof.name,lof.class

DEFINE CLASS ClassName	AS Custom
*this defines the .class property as well as the name of an object instansiatet without giving it  a name
*(=CREATEOBJECT(...) vs. _screen.CREATEOBJECT('objname',...))
	Name	= 'ObjectName'

   PROCEDURE Init
	? "Class expected <ClassName>, Observed :"	,this.Class,this.name
*Agnes remark:
*next line sets the name of the object!
        * this not set Class, because this runs in an object
	this.Name = "AnotherName"
	? "Class expected <ClassName>, Observed :"	,this.Class,this.name

ENDDEFINE
Agnes


>Are you talking about the same thing? If you change the name of the class in the init, shouldn't the name of the class change?
>
>>Fabio,
>>
>>Please this is a feature.
>>I use this one down the days where we start with the memberclass* stuff. (There must be an old thread of this)
>>
>>This one allows you to subclass a member like optionbutton but keep the names like Option1, Option2 .. instead of something strange like myopt1 or so.
>>
>>See example
>>
>>CLEAR
>>
>>=CREATEOBJECT("mygroup")
>>=CREATEOBJECT("mygroup2")
>>
>>DEFINE CLASS MyOpt	AS OPTIONBUTTON
>> NAME = 'MyOpt'
>>ENDDEFINE &&MyOpt	AS OPTIONBUTTON
>>
>>
>>DEFINE CLASS MyOpt2	AS OPTIONBUTTON
>> NAME	= 'Option'
>>ENDDEFINE &&MyOpt2	AS OPTIONBUTTON
>>
>>DEFINE CLASS mygroup AS OPTIONGROUP
>> MEMBERCLASS = 'MyOpt'
>> MEMBERCLASSLIBRARY = THIS.CLASSLIBRARY
>>
>> BUTTONCOUNT = 0
>>
>> PROCEDURE INIT
>>  THIS.BUTTONCOUNT = 2
>>  ?THIS.CLASS,THIS.OBJECTS(1).NAME
>> ENDPROC &&mygroup.init
>>ENDDEFINE &&mygroup as optiongroup
>>
>>DEFINE CLASS mygroup2 AS OPTIONGROUP
>> MEMBERCLASS = 'MyOpt2'
>> MEMBERCLASSLIBRARY = THIS.CLASSLIBRARY
>>
>> BUTTONCOUNT = 0
>>
>> PROCEDURE INIT
>>  THIS.BUTTONCOUNT = 2
>>  ?THIS.CLASS,THIS.OBJECTS(1).NAME
>> ENDPROC &&mygroup2.init
>>ENDDEFINE &&mygroup as optiongroup
>>
>>
>>Sp you can mimic your member* stuff in existing classes. O.K.?
>>
>>HTH
>>Agnes
>>>Set the Name property into a class definition change it's Class property to the name value.
>>>
>>>
>>>CLEAR
>>>
>>>=CREATEOBJECT("ClassName")
>>>
>>>DEFINE CLASS ClassName	AS Custom
>>>	Name	= 'ObjectName'
>>>
>>>   PROCEDURE Init
>>>	? "Class expected <ClassName>, Observed :"	,this.Class
>>>        * this not set Class
>>>	this.Name = "AnotherName"
>>>	? "Class expected <ClassName>, Observed :"	,this.Class
>>>ENDDEFINE
>>>
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform