# Force timer to execute by script

**URL:** <https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025>\
**Category:** Ignition\
**Created:** [August 13, 2013, 1:00pm UTC](https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025 "2013-08-13T13:00:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [August 13, 2013, 1:00pm UTC](https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025/1 "2013-08-13T13:00:48Z")

</div>

Can we force a timer execution by scripting ?  
like the button.doClick()  
timer.do???

---

<div class="post-metadata">

**Author:** ![Ron.Lor](https://avatars.discourse-cdn.com/v4/letter/r/f17d59/32.png) [@Ron.Lor](https://forum.inductiveautomation.com/u/Ron.Lor)\
**Post date:** [August 13, 2013, 6:21pm UTC](https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025/2 "2013-08-13T18:21:09Z")

</div>

In the window that your timer is in, you can set the “running” property in the timer component to true, or 1. Do something like event.source.parent.getComponent(‘Timer’).running = 1. To stop the timer, set the running property back to 0.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [August 14, 2013, 12:00pm UTC](https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025/3 "2013-08-14T12:00:28Z")

</div>

I would like on particiular case to trigger the timer which is running without waiting for the next cycle time.

---

<div class="post-metadata">

**Author:** ![RRRancher](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@RRRancher](https://forum.inductiveautomation.com/u/RRRancher)\
**Post date:** [August 14, 2013, 3:24pm UTC](https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025/4 "2013-08-14T15:24:47Z")

</div>

What I would do is…

Create a Boolean memory tag named something like TimedToggle.  
Create a Boolean memory tag named something like ForceRun.

Create a Timer script that runs at the rate at which you need your timed operation to occur. In that timer script, toggle your TimedToggle tag true as the timer times out.

```auto
system.tag.write('TimedToggle', 1)
```

Create a Tag Change script that will execute whatever you need done at a timed rate, but can be forced to run at any time by the ForceRun tag as shown below. For this example, I am incrementing an integer memory tag named MyValue every time the timer trips or the ForceRun tag is set to true.

[code]qv = system.tag.read(‘TimedToggle’)  
timedToggle = qv.value  
qv = system.tag.read(‘ForceRun’)  
forceRun = qv.value

# if either tag is true, increment MyValue and reset both tags to false

if forceRun == 1 or timedToggle == 1:  
qv = system.tag.read(‘MyValue’)  
myValue = qv.value + 1  
system.tag.write(‘MyValue’, myValue)  
system.tag.write(‘TimedToggle’, 0)  
system.tag.write(‘ForceRun’, 0)  
[/code]

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [August 14, 2013, 3:37pm UTC](https://forum.inductiveautomation.com/t/force-timer-to-execute-by-script/7025/5 "2013-08-14T15:37:49Z")

</div>

I hoped a method on the timer script object to directly trigger it  
without additionnal tagchange scripts and tags !  
I will post a feature request !

Thanks for your solution, it enable to wait for this feature.
