How do you find the names and values of the members of a Type programmatically.

davidlub

Member
Licensed User
Longtime User
Hi,

This is my first question though I have been using B4A very happily for a while.

Question:

If I define a type as:

Type T (a as String, b as String)

I would like a function like:

m = membersof("T")

which would return say a list {"a","b"} and then if

Dim t1 as T
t1.a = "test"
s = valueof(t1,"a")
would return "test".

I need this to automatically save the values of a type variable.

I had quite a good look at the documenation but could not find if such functions exist.

Thanks

David
 

davidlub

Member
Licensed User
Longtime User
It can be done with reflection. However there is a much easier way to save types (including complex types, and list of types and so on).
You should either use KeyValueStore class or use RandomAccessFile.WriteObject.

Brilliant. The WriteObject method is what I was looking for.

Thanks.

David
 
Upvote 0
Top