Welcome! Log In Create A New Profile

Advanced

Programatically Adding A Property To A Class

Posted by kevinw 
kevinw
Programatically Adding A Property To A Class
June 06, 2008 05:47PM
In VFP, there is an AddProperty() function to add a property (member) to a class at runtime. I can't see anything like this in the WD12 Help - does anybody know a way to do this?

TIA, Kevin
Nope, no direct support in W-Language.
So what you can do is :

property is structure
  _value is variant  // the value
  _name is string  // property ID
  _targetType is int  // use wlConstants -> for instance wlEntier ( france )
end

dynPropertySample is class
  PRIVATE 
      _properties  is dynamic array of 0 property  // you can use an assoc. array too...

  procedure addProp(newProp is property)
    // add newProp to :_properties

  procedure getProp(pName is string)
     // get property by ID (pName) and convert it into _targetType
     // return "converted to TargetType" value

  procedure deleteProp(pName is string)

end


Bjoern
IMO it is normal to give some feedback.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: