# writeBlocking to a Memory Tag works in Script Console but not in Gateway Timer Event Script

**URL:** <https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710>\
**Category:** Ignition\
**Tags:** vision, scripting, ignition80\
**Created:** [April 11, 2024, 7:49pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710 "2024-04-11T19:49:59Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Keen](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Eric\_Keen](https://forum.inductiveautomation.com/u/Eric_Keen)\
**Post date:** [April 11, 2024, 7:49pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/1 "2024-04-11T19:49:59Z")

</div>

Hello all - very new to Ignition scripting.

I am simply trying to copy the value of one memory tag to a different memory tag. This code works in the scripting console. I am able to write to a memory tag "P1UptimeBit" based on the tag "SPOOF Press 1 Line Speed". However, as soon as I copy it over to a Gateway Timer Event Script specified to fire every second, the tag no longer updates. Code below...

```auto
writevalue = system.tag.readBlocking(["[default]TEST/SPOOF Press 1 Line Speed"])
system.tag.writeBlocking(["[default]TEST/P1UptimeBit"], writevalue)

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 11, 2024, 7:57pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/2 "2024-04-11T19:57:00Z")

</div>

> [@Eric\_Keen](#):
>
> writevalue = system.tag.readBlocking(["[default]TEST/SPOOF Press 1 Line Speed"])  
> system.tag.writeBlocking(["[default]TEST/P1UptimeBit"], writevalue)

Rather surprised it worked in the Console. Reading a tag gets a "qualified value" with three parts: value, quality, and timestamp.

You want to grab the value portion of it and writ it to another tag.

Try this:

```python
writevalue = system.tag.readBlocking(["[default]TEST/SPOOF Press 1 Line Speed"])[0].value
system.tag.writeBlocking(["[default]TEST/P1UptimeBit"], [writevalue])

```

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 11, 2024, 8:00pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/3 "2024-04-11T20:00:19Z")

</div>

To clarify further,:

```python
["[default]TEST/SPOOF Press 1 Line Speed"]

```

is a list of tags, even if it's a list of one. The `[0]` after it says the you want to get the qualified value at position 0. Things that you can iterate over start at an index of 0.

The `.value` at the end gets the value portion of the qualified value.

---

<div class="post-metadata">

**Author:** ![Eric\_Keen](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Eric\_Keen](https://forum.inductiveautomation.com/u/Eric_Keen)\
**Post date:** [April 11, 2024, 8:01pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/4 "2024-04-11T20:01:29Z")

</div>

Hey Jordan - thanks for the quick reply. I copied that directly into the Gateway Event Script and still no luck. Your code runs in the Script Console as well... Dumb question - how do I get my code to show up formatted in the forum?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 11, 2024, 8:01pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/5 "2024-04-11T20:01:52Z")

</div>

Welcome to the forum, Eric. Please have a read of [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). It might save us some confusion.  
.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 11, 2024, 8:02pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/6 "2024-04-11T20:02:17Z")

</div>

On the writing of tags, you again have a list of tags, thich also requires a list of values. That's why there are brackets around both.

---

<div class="post-metadata">

**Author:** ![Eric\_Keen](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Eric\_Keen](https://forum.inductiveautomation.com/u/Eric_Keen)\
**Post date:** [April 11, 2024, 8:02pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/7 "2024-04-11T20:02:45Z")

</div>

Got it - and updated my original post. Thanks guys.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 11, 2024, 8:04pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/8 "2024-04-11T20:04:13Z")

</div>

> [@Eric\_Keen](#):
>
> I copied that directly into the Gateway Event Script and still no luck.

- Did you remember to save the project?
- Is there any error in the logs?

---

<div class="post-metadata">

**Author:** ![Eric\_Keen](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Eric\_Keen](https://forum.inductiveautomation.com/u/Eric_Keen)\
**Post date:** [April 11, 2024, 8:07pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/9 "2024-04-11T20:07:38Z")

</div>

It seems all I needed to do here was save the project - as silly as it feels to admit. Thanks Jordan.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 11, 2024, 8:36pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/10 "2024-04-11T20:36:05Z")

</div>

> [@JordanCClark](#):
>
> Rather surprised it worked in the Console. Reading a tag gets a "qualified value" with three parts: value, quality, and timestamp.

IIRC under the hood it knows how to handle qualified values.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2024, 9:08pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/11 "2024-04-11T21:08:05Z")

</div>

More than that, it's deliberate that you're allowed to pass qualified values through, in case you want to write an explicit quality code and/or timestamp to, say, a memory tag.

---

<div class="post-metadata">

**Author:** ![Eric\_Keen](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@Eric\_Keen](https://forum.inductiveautomation.com/u/Eric_Keen)\
**Post date:** [April 11, 2024, 10:30pm UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/12 "2024-04-11T22:30:13Z")

</div>

So did I inadvertently pass all of those parameters (quality, timestamp, value) to the memory tag - is that possible? ...or does Ignition make an assumption if a parameter is not specified?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [April 12, 2024, 11:41am UTC](https://forum.inductiveautomation.com/t/writeblocking-to-a-memory-tag-works-in-script-console-but-not-in-gateway-timer-event-script/88710/13 "2024-04-12T11:41:23Z")

</div>

> [@Eric\_Keen](#):
>
> So did I inadvertently pass all of those parameters (quality, timestamp, value) to the memory tag - is that possible?

You did. `readBlocking()` returns a list of QualifiedValues, in a 1:1 relationship with the paths passed in the list of TagPaths. `writeBlocking()` accepts a list of objects in a 1:1 relationship with the paths passed in the list of TagPaths. Those objects can be QualifiedValue objects.

If you wanted just the value attribute of the QualifiedValue then you would use code as @JordanCClark showed.
