It is currently April 19th, 2024, 6:15 am

ActionTimer can't make repeat work

Get help with creating, editing & fixing problems with skins
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

ActionTimer can't make repeat work

Post by Active Colors »

I might be overlooking something simple in my code. It just doesn't work.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
CurN=0

[Count]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat ObjIconWGet, 5, 11
ObjIconWGet=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw]
DynamicVariables=1
Disabled=0
I basically want to increment the CurN variable by one 11 times.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer can't make repeat work

Post by jsmorley »

Active Colors wrote: April 22nd, 2021, 9:53 am I might be overlooking something simple in my code. It just doesn't work.

Code: Select all

[Rainmeter]
Update=1000

[Variables]
CurN=0

[Count]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat ObjIconWGet, 5, 11
ObjIconWGet=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw]
DynamicVariables=1
Disabled=0
I basically want to increment the CurN variable by one 11 times.
Works for me. Don't forget that you have to have an action that executes the ActionTimer measure.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure Count "Execute 1"]

[Variables]
CurN=0

[Count]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat ObjIconWGet, 5, 11
ObjIconWGet=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw]
DynamicVariables=1
Disabled=0
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer can't make repeat work

Post by jsmorley »

Now mind you, this will count with a delay of 5 milliseconds between each increment, so watch the log carefully, as it will all happen in a blink of an eye...
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: ActionTimer can't make repeat work

Post by Active Colors »

jsmorley wrote: April 22nd, 2021, 9:58 am Works for me. Don't forget that you have to have an action that executes the ActionTimer measure.
Ah, I forgot about this! And when refreshing my memory by checking the docs I simply didn't read it by the end where it explicitly says:
"The plugin will take no action unless triggered with one of these commands".

However the variable stops at the value 1. I believe the action is repeated 11 times but the variable is not incremented after the first cycle. Am I overlooking something here again?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer can't make repeat work

Post by jsmorley »

Active Colors wrote: April 22nd, 2021, 10:05 am Ah, I forgot about this! And when refreshing my memory by checking the docs I simply didn't read it by the end where it explicitly says:
"The plugin will take no action unless triggered with one of these commands".

However the variable stops at the value 1. I believe the action is repeated 11 times but the variable is not incremented after the first cycle. Am I overlooking something here again?
It counts up to 11 for me with exactly your code...


1.png


Be sure you are using DynamicVariables=1 where you are "using" the value of #CurN#.
You do not have the required permissions to view the files attached to this post.
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: ActionTimer can't make repeat work

Post by Active Colors »

jsmorley wrote: April 22nd, 2021, 10:07 am It counts up to 11 for me with exactly your code...

Be sure you are using DynamicVariables=1 where you are "using" the value of #CurN#.
My bad. I had DefaultUpdateDivider=-1 in [Rainmeter]. It works now. Thank you! :thumbup:
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: ActionTimer can't make repeat work

Post by Active Colors »

jsmorley wrote: April 22nd, 2021, 10:07 am It counts up to 11 for me with exactly your code...

Be sure you are using DynamicVariables=1 where you are "using" the value of #CurN#.
I am facing another problem now with slightly modified code.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure Count "Execute 1"]

[Variables]
CurN=0
CurS=0

[Count]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Set1, 5, 10
Set1=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw][!SetVariable CurS "(#CurN#)"][!Update][!Redraw]
UpdateDivider=1
DynamicVariables=1
Disabled=0
Here CurN becomes 10 and supposedly CurS should become 10 as well but CurS stays one cycle beyond and after 10 repeats it stays 9. Any idea why is it happening?
Capture.PNG
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer can't make repeat work

Post by jsmorley »

Active Colors wrote: April 22nd, 2021, 10:50 am I am facing another problem now with slightly modified code.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure Count "Execute 1"]

[Variables]
CurN=0
CurS=0

[Count]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Set1, 5, 10
Set1=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw][!SetVariable CurS "(#CurN#)"][!Update][!Redraw]
UpdateDivider=1
DynamicVariables=1
Disabled=0
Here CurN becomes 10 and supposedly CurS should become 10 as well but CurS stays one cycle beyond and after 10 repeats it stays 9. Any idea why is it happening?
Capture.PNG
Yes. The value of #CurN# is still the old value during the execution cycle, so setting #CurS# to the value of #CurN# during the cycle will always be one update behind. Use this:

Set1=[!SetVariable CurN "(#CurN#+1)"][!SetVariable CurS "(#CurN#+1)"][!Update][!Redraw]

As with all bangs, any #Variables# are evaluated and resolved when the action is "read" in its entirety.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ActionTimer can't make repeat work

Post by jsmorley »

I hope I was clear. With this action:

Set1=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw][!SetVariable CurS "(#CurN#)"][!Update][!Redraw]

What happens is that on each update of the measure the action option is read and parsed. Any formulas or #Variables# will be resolved at that time. So what will be passed to Rainmeter on the first execution of this statement is:

[!SetVariable CurN "(0+1)"][!Update][!Redraw][!SetVariable CurS "(0)"][!Update][!Redraw]

Then the bangs will be executed in order, but in a sense all at once. So even though you have that extra (and pointless) !Update in the middle, it doesn't matter. The ActionTimer plugin has control of things until the action statement is completed. It's too late to "update" the value of #CurN# in the middle, it has already been resolved and set to "0" at that point, and in effect isn't a variable anymore.
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: ActionTimer can't make repeat work

Post by Active Colors »

jsmorley wrote: April 22nd, 2021, 10:53 am Yes. The value of #CurN# is still the old value during the execution cycle, so setting #CurS# to the value of #CurN# during the cycle will always be one update behind. Use this:

Set1=[!SetVariable CurN "(#CurN#+1)"][!SetVariable CurS "(#CurN#+1)"][!Update][!Redraw]

As with all bangs, any #Variables# are evaluated and resolved when the action is first "read" in its entirety.
I see now! I supposed that using [!Update] bang in the middle would update the variable during the cycle but I see now that it stays like that for the current cycle and only applied at the end.


I can't use +1 for my needs since in the actual code I have section variable, but you've given me a hint for a workaround. This is my final view:

Code: Select all

[Variables]
CurN=1
CurS=0
CurW=0

N=11

[Count]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Set1, 5, #N# | Wait 5 | Set2
Set1=[!SetVariable CurN "(#CurN#+1)"][!Update][!Redraw][!SetVariable CurS "([ObjIcon#CurN#:W])"][!Update][!Redraw][!SetVariable CurW "(#CurW#+#CurS#)"][!Update][!Redraw]
Set2=[!CommandMeasure Count2 "Execute 1"]
UpdateDivider=1
DynamicVariables=1
Disabled=0

[Count2]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Set3
Set3=[!SetVariable CurW "(#CurW#+#CurS#)"][!Update][!Redraw]
UpdateDivider=1
DynamicVariables=1
Disabled=0
Basically, when there are #N# visible ObjIcon(1-N) meters it calculates their total sum of their widths. That's all :)

Thank you again! This is now resoled :p