# Write to tag based on a Boolean vale

**URL:** <https://forum.inductiveautomation.com/t/write-to-tag-based-on-a-boolean-vale/11032>\
**Category:** Ignition\
**Created:** [January 12, 2016, 6:01pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-based-on-a-boolean-vale/11032 "2016-01-12T18:01:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [January 12, 2016, 6:01pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-based-on-a-boolean-vale/11032/1 "2016-01-12T18:01:03Z")

</div>

Hey guys, so I have this Boolean tag that comes on meaning Press change over has started, when the bit goes off I want to grab the time it went off and store it, so I create a check-box component and an label component and a custom tag called date. in my check-box component I made a custom property called date and in the expression window I used "now()’ so basically that time is always running. Now in script editor under mouse clicked event handler I used the following code:

```auto
value = event.source.parent.getComponent('CheckBox').Date

if (event.source.selected == 0):
	system.tag.writeToTag('Press Lines/Press 1/ChangeOver_Date', value)
```

I have the tag value bind to the label. every time I select the box nothing happens so thats great and when I un-select it the time stamp changes and thats great as well. Now I need this to happen when the tag value changes. I pretty much did all this to test and make sure date is changed when the bit goes off now I need to apply this to a tag. should I change the PropertyChange or StateChange under event handler?  
using 7.7.4 version

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [January 12, 2016, 7:25pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-based-on-a-boolean-vale/11032/2 "2016-01-12T19:25:27Z")

</div>

I would put this in a gateway tag change script or on the tag’s built in event scripts(if you are running a newer version of Ignition)

---

<div class="post-metadata">

**Author:** ![r\_beall](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@r\_beall](https://forum.inductiveautomation.com/u/r_beall)\
**Post date:** [January 12, 2016, 9:57pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-based-on-a-boolean-vale/11032/3 "2016-01-12T21:57:08Z")

</div>

Not sure what version you’re running but the new tag events (inside a tag) are pretty freakin awesome.

I’ve been using them for similar instances.

[docs.inductiveautomation.com/di … ge+Scripts](https://docs.inductiveautomation.com/display/DOC/Tag+Change+Scripts)

---

<div class="post-metadata">

**Author:** ![Mr.K001](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Mr.K001](https://forum.inductiveautomation.com/u/Mr.K001)\
**Post date:** [January 13, 2016, 3:29pm UTC](https://forum.inductiveautomation.com/t/write-to-tag-based-on-a-boolean-vale/11032/4 "2016-01-13T15:29:53Z")

</div>

Still using 7.7.4, Wanted to wait a bit longer before having to update to version 8.0  
Got another question, so when my ChangeOver bit turns off the Press job is ready to go and I want to start a timer and have it count till that ChangeOver bit comes back on since that mean the next job is getting ready to go in this way I can figure out how long a job was in the press line, now I know I can use a timer component and bind the running property to the ChangeOver bit and have it start counting when the bit goes off now how should I approach having it stop counting when the bit comes on?
