Microsoft KB Archive/190789

= PRB: Access Method Fires for Properties that Do Not Exist =

Article ID: 190789

Article Last Modified on 12/11/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q190789



SYMPTOMS
Accessing a property that does not exist in a class still fires the Access method.



CAUSE
This behavior permits the design of classes that support the addition of custom properties at run-time using the AddProperty method. For example, the following class definition adds a new property to the class at run-time when a non-existent property is accessed: x = NewObject("myclass")

?x.NewProp && New Property will be added to class.

?x.NewProp && Note new property value.

x.NewProp="Hello" && Value assigned since property already exists.

?x.newprop

DEFINE Class myclass as Custom PROCEDURE this_access(tcMember) IF ! PEMStatus(this,tcMember,5) this.AddProperty(tcMember) ENDIF RETURN this ENDPROC ENDDEFINE



STATUS
This behavior is by design.



Steps to Reproduce Behavior
Run the following code: x = NewObject('myclass') ?x.BogusProperty

DEFINE class myclass as custom PROCEDURE this_access(tcMember) WAIT WINDOW tcMember RETURN this ENDPROC ENDDEFINE The Access method fires before you receive the invalid property error.

Additional query words: kbVFp600 kbOOP

Keywords: kbprb kbcode KB190789

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.