I have a class in my Delphi app where I would like an easy and dynamic way of resetting all the string properties to ” and all the boolean properties to False
As far as I can see on the web it should be possible to make a loop of some sort, but how to do it isn’t clear to me.
I have a class in my Delphi app where I would like an easy
Share
Please note, the following code works only for published properties of a class! Also, the instance of a class passed to the function below must have at least published section defined!
Here is how to set the published string property values to an empty string and boolean values to False by using the old style RTTI.
If you have Delphi older than Delphi 2009 you might be missing the tkUString type. If so, simply remove
it from the following code:
Here is a simple test code (note the properties must be published; if there are no published properties in the class, at least empty published section must be there):