Capturing Snapshot of Variable in an Event script (or Macro)

Moderator: Moderator Group

Capturing Snapshot of Variable in an Event script (or Macro)

Postby azman » Tue Jun 14, 2016 12:44 pm

Hi All,

I'm looking to to store info from 3 different Variables (a snap shot)into an event script (or even a Macro),
When the scheduled ''event'' is triggered, I want the info that was in the variables at the time when the event was created, not its current value.
I want to be able to store multiple events (not too many but more than one) with captured info.
I can get the variable in no problem but then its referencing the current variable state,
I'm also playing with listview, but recalling different columns I finding I need another variable, which is the same issue just a different variable - doesn't solve my issue.

I seem to be going around in circles, it seems quiet straight forward but each avenue I take leads me back to where I began,
I'm sure I'll wake up tomorrow & the light bulb will go on....
...but in the interim any advice would be greatly appreciated,

Kind Regards

Az
azman
 
Posts: 87
Joined: Tue Feb 02, 2010 11:43 pm

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby jbaltaziewicz » Tue Jun 14, 2016 1:54 pm

Hi Az,

why exactly don't you want to use another variable? There has to be some special reason for that.
I can think of quite a lot of different ways to accomplish your goal, but they all include at least one additional variable.


Best regards,

Janina
jbaltaziewicz
 
Posts: 1
Joined: Wed Sep 02, 2015 1:10 pm

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby azman » Wed Jun 15, 2016 4:00 am

Hi Janina,

The situation I'm looking to achieve involves triggering a script from an event,
the event is created via automated process (user clicks a WDCustomscript button with WDEventScript,EventName,Script, plus various other scripts to determine start & end date),
I have data from a Variable that I would like to capture when an event is created, as part of the 'script command' in the event.
I need the variable to continue to be dynamic for the purpose of adding new events with different variable values,
For example, Var=255 is added to 'Event 1' script window, script example WDEventScript,EventName,DeviceSetParam,2,3,RGB Multiply|Red,Var
Then a second event is added, say 'Event 2' but the variable has changed, Var=125, but still WDEventScript,EventName,DeviceSetParam,2,3,RGB Multiply|Red,Var
Event 1 is triggered but references the 'current' value of the variable (125), not the original (255).
The events are also not necessarily in chronological order.
If I reference a list view, I can store the variable info easily but recalling it still poses an issue, because I still need to use a variable in my event script
'Event 1' Script - DeviceSetParam,2,3,RGB Multiply|Red,WDlistview1.Cell.Var_2.1 (Column = Var_2)
'Event 2' Script - DeviceSetParam,2,3,RGB Multiply|Red,WDlistview1.Cell.Var_2.1
When the event triggers it will reference the current Variable value.
I'm still recalling a Variable that changes...i need to capture a snapshot from a variable, when adding the script to the event.
Effectively I need a script inside my event not to use variables...but at the same time need the info from a variable.
azman
 
Posts: 87
Joined: Tue Feb 02, 2010 11:43 pm

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby malkuth23 » Wed Jun 15, 2016 8:39 am

That is one of the most confusing things I have read today.

This does not seem to be a widget problem, but a programming problem. Try writing it out. I like to work on a white board or paper when I get stuck on logic problems like this.
I am willing to bet you are making a logical leap somewhere in there that a human can infer, but a computer needs carefully defined.

Keep in mind that a variable is always current. It has no history. If you need to store the state of a variable that is about to change, simply store the variable to another variable, then change the original.
Name your variables intelligently so that you can easily trace back your logic.
Comment your code. Even if you are the only one to ever use it. Comment it like you are explaining it to someone else.
Matthew Newman-Saul
Theatrical Concepts
mattns@theatrical.com
User avatar
malkuth23
 
Posts: 350
Joined: Tue Apr 20, 2010 7:14 pm
Location: New Orleans, LA

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby AViefhues » Wed Jun 15, 2016 8:49 am

Hi azman,

do you really need a varible inside the eventscript or could you wirte the needed value directly inside the script?

If you can do so, this could be a solution for you:

Script inside the button for the event creation:

1 Script_combined = Script_base
2 Script_base += 125
3 WDEventCreate,TestEvent
4 WDEventScript,TestEvent,Script_combined

Script_combinded is a string-variable.
Script_base is a string-variable with the value = DeviceSetParam,2,3,RGB Multiply|Red,
You need both variables becouse it is not possible to set a variable to the value (DeviceSetParam,2,3,RGB Multiply|Red,) with "variable =...". I think the commas are the problems.

Now you can replace the 125 in line 2, with the value you want to store in the eventscript.
User avatar
AViefhues
 
Posts: 37
Joined: Tue Jan 25, 2011 4:28 pm
Location: Gelsenkirchen

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby Janina Baltaziewicz » Wed Jun 15, 2016 9:08 am

Hi there,

the last post is nearly perfect, I would just recommend the command "VAdd" instead of " += ", as you can only add real values with this syntax and no variables.
So it would be something like:

Var = 255
Script_base = DeviceSetParam,2,3,RGB Multiply|Red,
VAdd,Script_combined,Script_base,Var

-> Script_combined = DeviceSetParam,2,3,RGB Multiply|Red,255

If your Var-value is located somewhere in the middle of your command, you would have to use the VAdd-command twice, you could also use the Text Combiner Node with Variable Input Nodes if you wanted to. This would be a bit more comfortable to handle if you had more variable values you wanted to insert in your command.
Janina Baltaziewicz
Technical Support Specialist
User avatar
Janina Baltaziewicz
 
Posts: 50
Joined: Tue Jun 14, 2016 2:08 pm

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby AViefhues » Wed Jun 15, 2016 9:41 am

Hallo Janina,

"Script_base = DeviceSetParam,2,3,RGB Multiply|Red," just set Script_base to "DeviceSetParam".
I think the first comma leeds the interpreter to end with the script.
So you have to put the wohle string "DeviceSetParam,2,3,RGB Multiply|Red," into a variable first.

The "+=" operator can be used with variables, you just have to remember the blankspaces before and after the operaor.

The script in my post ist tested, I'm using many of these in my projects.
User avatar
AViefhues
 
Posts: 37
Joined: Tue Jan 25, 2011 4:28 pm
Location: Gelsenkirchen

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby Janina Baltaziewicz » Wed Jun 15, 2016 11:50 am

Ah, you're right.

I did not pay attention to what I was writing, I just defined the value of Script_base at the Variable Tool itself and of course that worked well.
Thanks for the hint ;)
Janina Baltaziewicz
Technical Support Specialist
User avatar
Janina Baltaziewicz
 
Posts: 50
Joined: Tue Jun 14, 2016 2:08 pm

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby azman » Wed Jun 15, 2016 12:05 pm

Hi Guys,

Thank you...
My apologies as my brain was in a feedback loop, a serious lack of sleep can be blamed for that.
Each methods I was using was adding the Variable ''name'' in the Event not the actual Variable ''value''.

The Vadd script has allowed me to add scripts in the Events with values.

Cheers
azman
 
Posts: 87
Joined: Tue Feb 02, 2010 11:43 pm

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby aferors » Thu Jun 16, 2016 10:19 am

Hey mate, im not sure if you already have your fix there.

have you considered creating a separate set of variables and at a certain time executing a copy of all the vars from one to the other (var=var) and then them being your snap shot as they arn't updating all the time. Just an idea.
Drew Ferors
Senior Technician
drew.ferors@tdc.com.au


Technical Direction Company, Sydney Australia
www.tdc.com.au
User avatar
aferors
 
Posts: 21
Joined: Thu Dec 13, 2012 12:18 am
Location: Sydney, Australia

Re: Capturing Snapshot of Variable in an Event script (or Ma

Postby azman » Thu Jun 16, 2016 1:55 pm

Hey Drew,

I am actually now combining Variables to create a new variable,

The issue I was having was the Variable 'name' being saved in the script, not the 'value'.

Looking back my error was creating an entry using the WDEventScript,EventName,Script & adding/typing 'part' of the script with the variable within it, i.e WDEventScript,EventName,DeviceSetParam,2,3,RGB Multiply|Red,VARIABLE

the correct way is to just make the 'whole' script as a Variable
i.e NEW VARIABLE = DeviceSetParam,2,3,RGB Multiply|Red,VARIABLE
WDEventScript,EventName,NEW VARIABLE

Cheers

Az
azman
 
Posts: 87
Joined: Tue Feb 02, 2010 11:43 pm


Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 8 guests