PRB: Access Method Fires for Properties that Do Not Exist

ID: Q190789


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 6.0


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.


MORE INFORMATION

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 :
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: December 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.