I have a class with a number of properties.
I wish to dump the names and values of those properties ( to console print) (strings and integers only) to
(Pseudocode)
mydump=mydump+nameofpropoerty(i)+" - "valueofproperty(i)+endofline
How do I get a list of properties in a class?
If I use introspection to pull the values, they come back as type Variant(?) sot i can simply call str(valueofproperty(i)) to get it as a string?
Or am I way far afield here?
Variant has a StringValue property, but be careful. If the variant holds an object, you will get an exception.
Thanks Kem: That solves the second part
How do I get a list of properties in a class?
Look at:
http://documentation.xojo.com/index.php/Introspection
Specifically, examine PropertyInfo. Some simple code:
dim ti as Introspection.TypeInfo = Introspection.GetType( MemberOfMyClass )
dim props() as Introspection.PropertyInfo = ti.GetProperties
for each prop as Introspection.PropertyInfo in props
dim name as string = prop.Name
dim value as variant = prop.Value( MemberOfMyClass )
next