# Write tag value to new Memory Tag

**URL:** <https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020>\
**Category:** Ignition\
**Created:** [February 17, 2023, 6:19pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020 "2023-02-17T18:19:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [February 17, 2023, 6:19pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/1 "2023-02-17T18:19:37Z")

</div>

I'm trying to take a value of an OPC Integer Tag we will call A and write it to a new Memory Tag we will call B. Is this accomplished by using a Value Changed script so when the value of Tag A changes it will execute the script, writing the value of Tag A to B?

I dont think this is correct, but its a start. If im on the right path here, does anything need to be added? If not, how would I go about accomplishing this?

Test = system.tag.read('A').value  
system.tag.write('B', Test)

Thank you.

---

<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:** [February 17, 2023, 6:22pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/2 "2023-02-17T18:22:55Z")

</div>

A value changed script is one way to accomplish this, yes. There's no need to read A; the value changed script will have a `currentValue` parameter already supplied.

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [February 17, 2023, 6:31pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/3 "2023-02-17T18:31:15Z")

</div>

Makes sense, how does the syntax for currentValue() go?

If I want to write currentValue to Tag B?

---

<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:** [February 17, 2023, 6:44pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/4 "2023-02-17T18:44:32Z")

</div>

[https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts#TagEventScripts-ValueChanged](https://docs.inductiveautomation.com/display/DOC81/Tag+Event+Scripts#TagEventScripts-ValueChanged)

```auto
system.tag.writeBlocking(["path/to/B"], [currentValue.value])

```

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [February 20, 2023, 12:44pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/5 "2023-02-20T12:44:13Z")

</div>

Thank you. If i wanted to only write to the memory tag at a certain time, say whatever the value of the tag is at 6am, how would this be achieved? The tag value im writing to the memory tag is reset at a certain time daily and i dont want it to write 0 to the memory tag. I need it to write the maximum value achieved before reset.

---

<div class="post-metadata">

**Author:** ![Robert\_Hrynciw](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Robert\_Hrynciw](https://forum.inductiveautomation.com/u/Robert_Hrynciw)\
**Post date:** [February 20, 2023, 1:54pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/6 "2023-02-20T13:54:16Z")

</div>

Good morning Kaleb,

I recently set up some gateway scripts that do this exact thing, write to other tags every 15 minutes of the hour. You can create a gateway script under "Scheduled" that will trigger at exactly 6 am if that's what you're looking for. You can accomplish this with the following script on a gateway scheduled script set for 6 AM:

```auto
pathToTagA = (insert path here)
pathToTagB = (insert path here)
tagAValue = system.tag.readBlocking(pathToTagA)
system.tag.writeBlocking(pathToTagB, tagAValue)

```

---

<div class="post-metadata">

**Author:** ![kaleb.s](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kaleb.s](https://forum.inductiveautomation.com/u/kaleb.s)\
**Post date:** [February 20, 2023, 1:55pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/7 "2023-02-20T13:55:02Z")

</div>

Thank you sir. I did end up playing around until I figured it out. I appreciate your reply.

---

<div class="post-metadata">

**Author:** ![Robert\_Hrynciw](https://avatars.discourse-cdn.com/v4/letter/r/3bc359/32.png) [@Robert\_Hrynciw](https://forum.inductiveautomation.com/u/Robert_Hrynciw)\
**Post date:** [February 20, 2023, 1:55pm UTC](https://forum.inductiveautomation.com/t/write-tag-value-to-new-memory-tag/70020/8 "2023-02-20T13:55:20Z")

</div>

Glad you got it figured out!
