finding variables?? reflection?
Monkey Forums/Monkey Programming/finding variables?? reflection?
| ||
Say I was to save a text file VariableName = Value Would I be able to use reflection to find the variable "VariableName" without having to hardcode variable names into a load routine.. Im not familiar with reflection and I just wanted to know if its something I can use to do this? Then I can invest some time into learning how to do it. |
| ||
Reflection allows you to find fields, functions, methods etc etc by name or any that belong to the class or instance. I guess one way of achieving what you want is to output the information relating to that instance, like Class name and then any fields you require with a value. That way, when you load the file, you can find the class and the fields to be set to value. GetClass:ClassInfo( name:String ) GetField:FieldInfo( name:String,recursive?=True ) I haven't attempted anything like this yet so there may be a better way to achieve the same thing using reflection but I can't think how at the moment. |