# Tag properties

**URL:** <https://forum.inductiveautomation.com/t/tag-properties/4418>\
**Category:** Ignition\
**Created:** [May 4, 2012, 7:57pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418 "2012-05-04T19:57:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 4, 2012, 7:57pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/1 "2012-05-04T19:57:43Z")

</div>

how do I reference a memory tag in a gateway script and can I create a user defined tag that will function as a display stack to keep track of my tag changes? I am trying to avoid using a database or historian function since resolution is important to me.  
I would like to know if using a list with a fixed length and appending my tag changes as strings will be a good idea for my application.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 4, 2012, 8:08pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/2 "2012-05-04T20:08:22Z")

</div>

You can store tag changes in a string tag. First you need to create a Gateway Tag Change script that listens on any tag you want to track changes on. The script would get the value and store it in the tag. You can read memory tags in gateway scripts like this:`value = system.tag.getTagValue("Path/To/MemoryTag")`You can write to memory tags in gateway scripts like this:`system.tag.writeToTag("Path/To/MemoryTag", "SomeValue")`Your tag change script will be something like:[code]value = newValue.value  
tagPath = str(event.tagPath)  
timestamp = newValue.timestamp

currentTrack = system.tag.getTagValue(“MemoryTagString”)  
currentTrack += “%s;%s;%s\n” % (tagPath, timestamp, value)  
system.tag.writeToTag(“MemoryTagString”, currentTrack)[/code]You may have to change it a bit but hopefully you see the idea.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 4, 2012, 8:13pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/3 "2012-05-04T20:13:23Z")

</div>

thanks. I will give this a try and see how things go.

---

<div class="post-metadata">

**Author:** ![mcarangelo](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@mcarangelo](https://forum.inductiveautomation.com/u/mcarangelo)\
**Post date:** [May 7, 2012, 1:36pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/4 "2012-05-07T13:36:55Z")

</div>

I did some looking around and I hope I am not missing something but could you give an example of what you mean by Path/to/Memorytag? When you create a memorytag there is no path. How do you determine a path when you reference it?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 7, 2012, 2:53pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/5 "2012-05-07T14:53:26Z")

</div>

This is my playground code:  
import app  
app.Winchester.Logger.post(‘oopsie’)

here is the function within my module:

def post(Message):  
import system, datetime  
now = datetime.datetime.now()  
timeStamp = str(now)  
nameDateFile = now.strftime("%Y%m%d")  
filename = “c://Users//AJ//%s.txt”%(nameDateFile)  
system.file.writeFile(filename, ‘\r\nIT’S %s %s’ %(timeStamp[0:23], str(Message)), 1)  
#tagPath = str(event.tagPath)  
#timestamp = newValue.timestamp   
currentTrack = system.tag.getTagValue(“MemoryTagString”)  
currentTrack += “;%s;%s\n” % (timeStamp[0:23], str(Message))  
system.tag.writeToTag(“MemoryTagString”, currentTrack)

The script prints 1 to my screen.  
I get an error saying:  
Error writing to tag.  
Gateway comm is not read/write.

I’ve created the tag “MemoryTagString” to be a memory type and string type.  
The value is 0 and it is READ/Write.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 7, 2012, 3:31pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/6 "2012-05-07T15:31:50Z")

</div>

That means that you are trying to run the script in the designer and the designer is in read-only mode. In the toolbar you will see three buttons where the middle one is selected right now. Select the third one labeled “Read/Write” and try the script again.

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 7, 2012, 4:01pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/7 "2012-05-07T16:01:11Z")

</div>

for i in range(4):  
Tag[i] = Tag[i+1]  
Tag[4] = Message  
system.tag.writeToTag("Tag…  
Can I do something like this to quickly modify the number of tags i keep track of…  
how can I adapt string arrays here? Is there a better way to do this?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [May 7, 2012, 5:52pm UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/8 "2012-05-07T17:52:29Z")

</div>

now I am struggling to understand if I will be able to use datasets as string arrays like so…  
def post(Message):  
import system, datetime  
now = datetime.datetime.now()  
timeStamp = str(now)  
nameDateFile = now.strftime("%Y%m%d")  
filename = “c://Users//AJ//%s.txt”%(nameDateFile)  
system.file.writeFile(filename, ‘\r\nIT’S %s %s’ %(timeStamp[0:23], str(Message)), 1)  
#tagPath = str(event.tagPath)  
#timestamp = newValue.timestamp   
currentTrack = system.tag.getTagValue(“MemoryTagString”)  
currentTrack += " %s %s" % (timeStamp[0:23], str(Message))  
system.tag.writeToTag(“MemoryTagString”, currentTrack)  
data = []  
data.append(currentTrack)  
newstringset= dataset.dataset(data)

What am I missing here?  
The documentation I’ve read on datasets does not seem to link the scripting to the datasets I see in the designer. I just need one column that can display string variables from most recent to 50 changes old with an easy way to scale the number that I store.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 8, 2012, 12:20am UTC](https://forum.inductiveautomation.com/t/tag-properties/4418/9 "2012-05-08T00:20:30Z")

</div>

In order to create a dataset do the following:`data = []
data.append([currentTrack])
newdataset = system.dataset.toDataSet(["Current Track"], data)`
