Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Access and Assign
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00169870
Message ID:
00170466
Views:
32
Hi Ned,

>I wonder if access/assign have any other "features" that we need to be aware of. Let me know if you find any.

Depends on what features you want. *g* My session about access and assign methods at DevCon included a section about bugs in access and assign methods. Some examples are:

1) If you assign the same object reference three times to a property that has an assign method, the object is released.

2) ActivePage_Assign does work for keyboarding only, not when you activate a page by clicking on it.

3) While array indexes are not supposed to be validated before the assign/access method are called, this is only true for character indexes. Numerical indexes can only range from 0 to 65000, giving you one element more than before.

4) When you use WITH...ENDWITH, any THIS_Access method is bypassed.

5) Using array properties as a controlsource still causes a lot of problems, especially with character indexes.

6) Assign/access methods behave completely differently in the debugger, so you can't really debug them.

7) Under some circumstances that I haven't to be able to reproduce yet, VFP causes an error "property or method does not exist", when you try to access an object that returns a different reference in the THIS_Access method and the property doesn't exist in the object itself, but in the one you return in This_Access.

And of course there are some gotchas you must be aware of:

1) Assign methods are not called when an object is created, so even with an Assign method you can't rely on proper values, when the developer initialized a property wrongly in the Properties Window

2) A property that has an assign method can hardly be watched in the debugger, because the debugger displays the actual value which doesn't have to match the value you get when you access the property.

3) Within an assign method the same assign method is not fired again, even when it's a number of level above in the calling stack. This means you can't call generic code in the assign/access method that might access the same property. Obviously this is not only true for direct calls, but also for indirect calls via a hotkey, a timer or an outside event.

4) For native VFP properties, the access method does only fire when you access a property in code, not when VFP accesses a property.

5) You can only create an assign method for read/writable native VFP properties, not for read-only properties.

Does this help?

Christof
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform