# Toggle a boolean PLC tag via script

**URL:** <https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567>\
**Category:** Ignition\
**Created:** [May 23, 2013, 1:54pm UTC](https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567 "2013-05-23T13:54:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryankipp](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bryankipp](https://forum.inductiveautomation.com/u/bryankipp)\
**Post date:** [May 23, 2013, 1:54pm UTC](https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567/1 "2013-05-23T13:54:04Z")

</div>

Please forgive the newbie question!!

I have created a two state rotary switch (Auto/Man, Start/Stop) and am trying to get the syntax correct for toggling a Boolean tag in the processor. The script as written is:

system.tag.read (“Intake/TEST\_TOGGLE”)

if “Intake/TEST\_TOGGLE” == 1:  
system.tag.write(“Intake/TEST\_TOGGLE”, 0)  
else:  
system.tag.write(“Intake/TEST\_TOGGLE”, 1)

It will set the tag value to “1” if it is a “0”, but won’t reset the bit to “0” if it is a “1”

There is a part two to this question, but I’ll hold off until I have part one answered!!

Thanks!

---

<div class="post-metadata">

**Author:** ![bryankipp](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bryankipp](https://forum.inductiveautomation.com/u/bryankipp)\
**Post date:** [May 23, 2013, 2:17pm UTC](https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567/2 "2013-05-23T14:17:56Z")

</div>

I found a solution to this. Changed the script to:

x = system.tag.read (“Intake/TEST\_TOGGLE”)

if x.value is True:  
system.tag.write(“Intake/TEST\_TOGGLE”, 0)  
else:  
system.tag.write(“Intake/TEST\_TOGGLE”, 1)

It works perfectly!

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 23, 2013, 2:23pm UTC](https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567/3 "2013-05-23T14:23:11Z")

</div>

![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")

---

<div class="post-metadata">

**Author:** ![Justino\_Zavala](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@Justino\_Zavala](https://forum.inductiveautomation.com/u/Justino_Zavala)\
**Post date:** [November 5, 2025, 11:14pm UTC](https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567/4 "2025-11-05T23:14:25Z")

</div>

I know this thread is very old, but come with the same problem today. Why is it not possible to do:

system.tag.write( “Intake/TEST\_TOGGLE”, not system.tag.read (“Intake/TEST\_TOGGLE”))

I tried and it just not work.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 5, 2025, 11:20pm UTC](https://forum.inductiveautomation.com/t/toggle-a-boolean-plc-tag-via-script/6567/5 "2025-11-05T23:20:02Z")

</div>

Try this:

```python
system.tag.write("Intake/TEST_TOGGLE", not system.tag.read("Intake/TEST_TOGGLE").value)

```

`system.tag.read` returns a QualifiedValue object; you need to pull the value out.
