Page 1 of 1
Execute scripts on child objects
Posted: 07 Apr 2015 15:30
by bval123
I have some scripts inside of a container that I'd like to be executed from its parent interface:
Code: Select all
-- Interface
--- ScriptA
--- Container
----- ScriptB
E.g., inside of ScriptA, i'd like to be able to do something like
.
Currently I'm handling this pattern by having an expression that I set from the parent, and a script inside that executes "on expression".
Any ideas?
Re: Execute scripts on child objects
Posted: 08 Apr 2015 01:16
by ndivuyo
I'm a little unclear, you want to trigger ScriptA() from inside ScriptA()?? Or did you mistype and meant trigger Container.ScriptB() or...
Maybe your question is different, but if you don't already know: you execute scripts that are set to 'Manual' by just typing their name.
So if ScriptB() was set to execute 'Manual', then in ScriptA() you would just type: Container.ScriptB();
That would execute ScriptB()
Is this your question, or something else?
Re: Execute scripts on child objects
Posted: 08 Apr 2015 13:25
by bval123
To clarify, and to show whats not working:
Code: Select all
interface
button
scriptA()
container
expA
scriptB()
I want to execute scriptB from scriptA (basically, having a button that is a sibling to a container that triggers a script inside that container). This currently doesn't work and gives me a syntax error.
Code: Select all
// inside ScriptA, set to trigger on expression 'x' to serve as a click handler for button
// this works
setexpression(container, 'expA', 1);
// this is a syntax error
container.scriptB();
Re: Execute scripts on child objects
Posted: 08 Apr 2015 17:57
by ndivuyo
Does this example help you? Obviously you would never set things up like I did in my example, but just to show how you manipulate child expressions/scripts. I only use setexpression if I need to use a string name.
(by the way i'll probably delete the attachment after you see it)
Re: Execute scripts on child objects
Posted: 08 Apr 2015 18:16
by bval123
Thanks for the example, it was more or less the setup I had.
The problem was embarrassingly just a typo in a different part of the template that was causing issues with the call to the script, I've got it working now
Re: Execute scripts on child objects
Posted: 08 Apr 2015 23:31
by ndivuyo
ok cool I'm going to delete my attachment to save space