Hello,
every few years I tend to revisit some basic concepts and still find unexpected behaviour that leaves me somehow doubtful. This time is about the Name property of a class:
This is what I get as results:
and this is what I get if I uncomment the Name assignment within the definition of MyClass:
My questions are:
1) Shouldn't the second line in the top results show "Myclass Myclass1" instead of "Myclass Myclass"?
Regards,
Dario
every few years I tend to revisit some basic concepts and still find unexpected behaviour that leaves me somehow doubtful. This time is about the Name property of a class:
Code:
LOCAL loObject AS Object
loObject = CreateObject( "MyContainerClass" )
DEFINE CLASS MyContainerClass AS Container
ADD OBJECT MyObject_1 AS MyClass
FUNCTION Init( ) AS Boolean
WITH This
? .MyObject_1.Class, .MyObject_1.Name
LOCAL MyObject_2 AS Object
MyObject_2 = CreateObject( "MyClass" )
? MyObject_2.Class, MyObject_2.Name
.AddObject( "MyObject_3", "MyClass" )
? .MyObject_3.Class, .MyObject_3.Name
ENDWITH
RETURN .T.
ENDFUNC
ENDDEFINE
DEFINE CLASS MyClass AS Session
* Name = "MyName"
ENDDEFINE
This is what I get as results:
Code:
Myclass MYOBJECT_1
Myclass Myclass
Myclass MYOBJECT_3
and this is what I get if I uncomment the Name assignment within the definition of MyClass:
Code:
Myname MYOBJECT_1
Myname Myname
Myname MYOBJECT_3
My questions are:
1) Shouldn't the second line in the top results show "Myclass Myclass1" instead of "Myclass Myclass"?
2) Why all Class properties are renamed to "Myname" in the bottom results (and the second line still shows "Myname" instead of "Myname1")?VFP Help said:The default name for new objects is the type of object plus a unique integer.
Regards,
Dario