Thursday, October 13, 2005

VFP's ADDPROPERTY Function

Sheesh - the things that just seem to slip through....

Someone on the ProFox list was asking why his VFP objects created with
SCATTER NAME didn't have an AddProperty method.

For example, if you do USE HOME(2)+"DATA\CUSTOMER"
Then
SCATTER NAME loCustomer

The object is essentially an Empty object and has no methods or events.
Which means you can't add new properties to it, right?

Not in VFP 9. (uh correction, not in VFP 8 either - thanks Colin for noting it) Kevin Cully of http://www.cullytechnologies.com noted the
AddProperty function that lets you add properties to objects that don't have
the AddProperty method.

=AddProperty(loCustomer, 'NewProperty', .T.)

Very handy as I use SCATTER NAME in lots of different places. Thanks for the
tip, Kevin!

2 comments:

Colin Nicholls said...

Hi Andrew. ADDPROPERTY() was introduced in VFP 8.0 I think.

Andrew MacNeill said...

Right you are - thanks Colin