Action on variable change

Moderator: Moderator Group

Action on variable change

Postby plbrunet » Wed Jul 20, 2016 2:56 am

Hi everyone.

Is there a way to execute a script every time a variable changes? Like an action script but for variables?

Thank you.
Pierre-Luc Brunet
Audio - Video - Show Control
http://plbrunet.com
https://ca.linkedin.com/in/pierrelucbrunet
User avatar
plbrunet
 
Posts: 65
Joined: Fri Mar 13, 2009 11:49 pm
Location: Montréal, Canada

Re: Action on variable change

Postby Christian Hinxlage » Wed Jul 20, 2016 7:46 am

Hi Pierre-Luc,

Please find a small project attached.
Something like that?

Regards

Christian
You do not have the required permissions to view the files attached to this post.
Christian Hinxlage
Technical Support Manager

Christie Digital Systems Canada Inc.
www.christiedigital.com
User avatar
Christian Hinxlage
Site Admin
 
Posts: 78
Joined: Wed Jul 22, 2015 9:58 pm

Re: Action on variable change

Postby plbrunet » Wed Jul 20, 2016 9:18 pm

Hi Christian,

That's interesting. I would have to play with the delay to see if it can handle faster changes.
I suppose there is not a more direct way of going about it.

Thank you.
Pierre-Luc Brunet
Audio - Video - Show Control
http://plbrunet.com
https://ca.linkedin.com/in/pierrelucbrunet
User avatar
plbrunet
 
Posts: 65
Joined: Fri Mar 13, 2009 11:49 pm
Location: Montréal, Canada

Re: Action on variable change

Postby Dennis Kuypers » Fri Jul 22, 2016 11:56 am

Hi,

there are a couple of tricks you can do. For integers you can build a construct of

Nodes: Variable->Delay->Script

In the script you check if variable does not equal delay. Then it will trigger once per change. If the variable is constantly chaning and never rests on one value then your script will only trigger once, tough. Alternatively you can use a Delta node and check if the Delta != 0.

For text variables you can have a shadow variable that is updated by your script, so for example:
Code: Select all
(a node checks for:) if myvar != _myvar
{
' somthing has changed
' do stuff...
' and set shadow variable
_myvar = myvar
}


Dennis
Dennis Kuypers
(former Product Developer, Software)
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm

Re: Action on variable change

Postby plbrunet » Fri Jul 29, 2016 4:32 pm

Great,

A colleague of mine also pointed out the trick of putting a variable into a label and using Action Script node to trigger script on label changes.

Thank you guys for those options.
Pierre-Luc Brunet
Audio - Video - Show Control
http://plbrunet.com
https://ca.linkedin.com/in/pierrelucbrunet
User avatar
plbrunet
 
Posts: 65
Joined: Fri Mar 13, 2009 11:49 pm
Location: Montréal, Canada


Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 15 guests

cron