Indirect Script Reference
Posted: 03 Mar 2017 15:21
I'm familiar w/ the use of findobject(), getobject(), getexpression(), setexpression(), etc, etc, when using strings to reference objects/expressions in functions that need direct (literal dot-notation) address references.
However, I've had no joy trying to run scripts in this fashion. Example:
A script, script2(val) in Container3, inside Container2, inside Container1, that accepts 1 argument:
Monitor.value = val;
A script in Container1 that needs to run script2():
Container1.Container2.Container3.Script2('Hello World'); // the standard 'direct' reference
What I Need:
decl rootStr = 'Container1.Container2.Container';
decl i;
for(i=0;i<9;i++){ // for Container0 thru Container9
execscript(rootStr+i ,'Hello World'); // imaginary execscript() function to allow script execution by string reference
}
I know that I could attach the target scripts to variable 'val' and have it trigger on a value change but that's such a hack.
Does anyone know of a way to execute a script via a variable reference to the script name?
Thanks so much.
However, I've had no joy trying to run scripts in this fashion. Example:
A script, script2(val) in Container3, inside Container2, inside Container1, that accepts 1 argument:
Monitor.value = val;
A script in Container1 that needs to run script2():
Container1.Container2.Container3.Script2('Hello World'); // the standard 'direct' reference
What I Need:
decl rootStr = 'Container1.Container2.Container';
decl i;
for(i=0;i<9;i++){ // for Container0 thru Container9
execscript(rootStr+i ,'Hello World'); // imaginary execscript() function to allow script execution by string reference
}
I know that I could attach the target scripts to variable 'val' and have it trigger on a value change but that's such a hack.
Does anyone know of a way to execute a script via a variable reference to the script name?
Thanks so much.