Hello, i want to load all variables from sketch and want to check some variables in the specific class and do some changes, how i can get class from Field ?
import java.lang.reflect.Field;
testClass test = new testClass(125); // save some number, wich we want to edit or read/write
void setup() {
println(test); // only chech if return "toString" is good
final Class <?extends PApplet> c = getClass(); // read all variables
final Field[] fields = c.getDeclaredFields(); // get it to the array
int x = fields[0].i; // <-- I dont know hot to load the class "test" and get var "i", can you help me ?
// HOW TO GET FIELD CLASS NAME LIKE A "testClass" ?
// ... AND after that load list of variables in the class and get someone or rewrite to this variable some other number..
exit();
}
class testClass { // class for test
int i = 0;
testClass(int i) {
this.i = i;
}
String toString() {
return "This is class, iam returning some string...";
}
}
Thanks, George.