In config.txt, I have the following strings:
Dispatcher=argo
Address=10.5.23.14
User=joe
In my script.js, I have the variables:
var Dispatcher, Address, User;
In script.js, I read config.txt, parse strings and get name/value pairs:
ConfigPair = ConfigString.split("=");
VarName = ConfigPair[0];
VarValue = ConfigPair[1];
What I want is to assign VarValue to the VarName variable. Say, if I get "Address" in VarName and "10.5.23.14" in VarValue, I want to set Address variable to 10.5.23.14.
I don't want to do something like that:
if (VarName == "Dispatcher") {
Dispatcher = VarValue;
} else if (VarName == "Address") {
Address = VarValue;
} else if bla-bla-bla
I want to somehow "read" the value of VarName and assign VarValue to the corresponding variable. Is it possible to do it in Windows Script Host (JScript)? I played with eval, but failed to make it work. Any ideas?
Thanks, Racoon