# Previousvalue and CurrentValue facing issue

**URL:** <https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [October 11, 2023, 10:20am UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323 "2023-10-11T10:20:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [October 11, 2023, 10:20am UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323/1 "2023-10-11T10:20:41Z")

</div>

Hi,  
I am trying to implement a logic when current alarm count is greater than previous alarm count audio should play.

**I have written change script on a numeric input field value for testing purpose and manually updating the numeric field and in both condition either the alarm count is greater or lesser than previous count audio is playing.**

```python
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	system.perspective.print(("Previous Value :", previousValue))
	system.perspective.print(("current Value :", currentValue))
	
	if currentValue > previousValue :
		self.getSibling("Audio").props.play = True
	else:
		self.getSibling("Audio").props.play = False
		
	system.perspective.print("--------------------------------------------------------")

```

and in console I am getting below output. (change the value from 7 to 10 in numeric field)

## ('Previous Value :', [7, Good, Wed Oct 11 15:46:01 IST 2023 (1697019361552)]) ('current Value :', [10, Good\_Unspecified, Wed Oct 11 15:46:06 IST 2023 (1697019366321)])

## ('Previous Value :', [10, Good\_Unspecified, Wed Oct 11 15:46:06 IST 2023 (1697019366321)]) ('current Value :', [10, Good, Wed Oct 11 15:46:06 IST 2023 (1697019366328)])

I don't understand why 2 times print statement executing and why audio is playing in both condition.

Any suggestions, thanks

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 11, 2023, 10:37am UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323/2 "2023-10-11T10:37:27Z")

</div>

It's printing twice because the tag quality changes and triggers the valueChanged script again. Also, I normally see a `.value` on the end of these comparison variables, so the entire list is not being compared.

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [October 11, 2023, 10:42am UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323/3 "2023-10-11T10:42:21Z")

</div>

Its working only when count is greater than previousvalue.

After putting `.value` in print statement I am getting below output.

Do you have any idea what **L** means?

```auto

--------------------------------------------------------
PerspectiveClient.3a86a04588cd08dbba6d.js:2 ('Previous Value :', 15)
PerspectiveClient.3a86a04588cd08dbba6d.js:2 ('current Value :', 21L)
PerspectiveClient.3a86a04588cd08dbba6d.js:2 --------------------------------------------------------
PerspectiveClient.3a86a04588cd08dbba6d.js:2 ('Previous Value :', 21L)
PerspectiveClient.3a86a04588cd08dbba6d.js:2 ('current Value :', 21)
PerspectiveClient.3a86a04588cd08dbba6d.js:2 --------------------------------------------------------

```

thanks for guidance.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 11, 2023, 11:21am UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323/4 "2023-10-11T11:21:20Z")

</div>

It's just an indicator for the print console that the value is seen as a long integer.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 11, 2023, 2:15pm UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323/5 "2023-10-11T14:15:47Z")

</div>

There are some considerations to be made as to what should happen if previousValue doesn't have a value, but you can simplify your script a bit with something like this:

```auto
if currentValue and previousValue:
    self.getSibling("Audio").props.play = currentValue.value > previousValue.value

```

---

<div class="post-metadata">

**Author:** ![Learner\_Ignition](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@Learner\_Ignition](https://forum.inductiveautomation.com/u/Learner_Ignition)\
**Post date:** [October 12, 2023, 3:24am UTC](https://forum.inductiveautomation.com/t/previousvalue-and-currentvalue-facing-issue/80323/6 "2023-10-12T03:24:23Z")

</div>

Noted, Thanks
