I have some recursive code that parses a file and sets values of properties in a class based on those values.
It's fairly flexible and dynamic though, so the class it's writing to may not always have properties to hold all the values.
How do I test for the existence of a property in a class before setting it?
If I try set a property that doesn't exist I get <PROPERTY DOES NOT EXIST>
I have set up a Catch to catch that error and swallow it, but hoping for a more elegant solution?
Try {
// First check the property exists
set help = $property(pObject,propname) // THROWS ERROR HERE IF PROPERTY DOESN'T EXIST
// doing stuff
Set $property(pObject,propname) = value
}
Catch ex {
If (ex.Name = "<PROPERTY DOES NOT EXIST>")
{
// Do nothing
}
}