# Memory tag's previous and current values

**URL:** <https://forum.inductiveautomation.com/t/memory-tags-previous-and-current-values/99432>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [December 4, 2024, 4:53pm UTC](https://forum.inductiveautomation.com/t/memory-tags-previous-and-current-values/99432 "2024-12-04T16:53:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Lin](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@Andrew\_Lin](https://forum.inductiveautomation.com/u/Andrew_Lin)\
**Post date:** [December 4, 2024, 4:53pm UTC](https://forum.inductiveautomation.com/t/memory-tags-previous-and-current-values/99432/1 "2024-12-04T16:53:02Z")

</div>

I know that memory tags value or quality change scripts has access to previous and current values and also gateway event scripts as well.

I want to know if project library scripts has access to previous and current values. My script runs 24/7 and every run, it set  
`variable_x = tag value`  
at the very beginning.  
At the very end of my script before it goes back to beginning, it will set  
`prev_variable_x = variable_x`.  
This is just 1 example, but in general my script looks at hundreds of tags.

Does these scripts have a way to do something like tag.getPreviousValue() and tag.getCurrentValue() or something like that?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 4, 2024, 5:53pm UTC](https://forum.inductiveautomation.com/t/memory-tags-previous-and-current-values/99432/2 "2024-12-04T17:53:49Z")

</div>

> [@Andrew\_Lin](#):
>
> before it goes back to beginning

Sounds like an infinite loop in your script. That, by itself, is very bad for event driven systems like Ignition.

A project library script's top-level variables are persistent from one function call to the next, so a top level dictionary is a good place to cache previous values.
