# Add tag value and text to a text box + cut/round(real) value

**URL:** <https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101>\
**Category:** Ignition\
**Created:** [October 19, 2021, 10:24am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101 "2021-10-19T10:24:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [October 19, 2021, 10:24am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/1 "2021-10-19T10:24:42Z")

</div>

Hi.  
I have this real value that has 15 decimals (unfortanely).  
I wish to update a textbox with this real value, but round it down to 2-3 decimals and att “mbar” in the end.

I have tried the propertyChange with:

```auto
event.source.text = system.tag.readBlocking(["[default]zB1ADFilter/MovAvg.value)"]) + " mbar"

```

But this does not seem to work, adding round to the tag causes an error that round is not defined etc.

Perhaps there is a better way to do this other than propertyChange on the textbox?

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 19, 2021, 10:40am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/2 "2021-10-19T10:40:28Z")

</div>

Use an expression and use `numberFormat({value}, '0.000') + ' mBar'`

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [October 19, 2021, 11:22am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/3 "2021-10-19T11:22:01Z")

</div>

I tried this:  
event.source.text = numberFormat(system.tag.readBlocking(["[default]zB1ADFilter/MovAvg.value)"]), ‘0.000’) + " mbar"

But the error i get is numberFormat is undefined:

```auto
Traceback (most recent call last):
  File "<event:propertyChange>", line 1, in <module>
NameError: name 'numberFormat' is not defined

Ignition v8.1.10 (b2021090812)
Java: Azul Systems, Inc. 11.0.11

```

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [October 19, 2021, 11:37am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/4 "2021-10-19T11:37:13Z")

</div>

[Expression Functions](https://docs.inductiveautomation.com/display/DOC81/Expression+Functions?src=sidebar) and \* [  
System Functions](https://docs.inductiveautomation.com/display/DOC81/System+Functions?src=sidebar)  
are different part, try this.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/c/4ce05f61a732a7bf39e38547b01c07d7031882f4.png)

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [October 19, 2021, 11:40am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/5 "2021-10-19T11:40:32Z")

</div>

And , the return object of system.tag.readBlocking is a list, try:

> event.source.text = str(round(system.tag.readBlocking(["[default]zB1ADFilter/MovAvg.value)"])[0].value,2)) + " mbar"

---

<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:** [October 19, 2021, 11:47am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/6 "2021-10-19T11:47:26Z")

</div>

@SKA, just as an aside, when you start a thread, it’s good to know what version of Ignition you’re using, and whether it’s vision or perspective, as the answers so far have already gone into the weeds with both. 😉

Bind the text property to an expression, using the one @nminchin supplied.

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [October 19, 2021, 11:51am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/7 "2021-10-19T11:51:47Z")

</div>

I use V8.1.10 + Vision module, not perspective.

My text field does not have expression what i can see, only scripting and does not look anything like the image @nideyijuyidong posted.

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [October 19, 2021, 11:52am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/8 "2021-10-19T11:52:55Z")

</div>

Sorry, I never used Vision… 🤣

---

<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:** [October 19, 2021, 11:59am UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/9 "2021-10-19T11:59:55Z")

</div>

This is why it’s useful to state. 🙂

Click on the ‘chain link’ at the Text property.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f9e99c6a3b9834520b8f3df4334b5d8958801854.png)

Choose expression on left side of the dialog box. Expression in your case:

`numberFormat({[default]zB1ADFilter/MovAvg}, '0.000') + ' mBar'`

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd49965dd0cf7b8ef0cf969dedd62a99288e1e76.png)

---

<div class="post-metadata">

**Author:** ![SKA](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ska/32/29528_2.png) [@SKA](https://forum.inductiveautomation.com/u/SKA)\
**Post date:** [October 19, 2021, 12:08pm UTC](https://forum.inductiveautomation.com/t/add-tag-value-and-text-to-a-text-box-cut-round-real-value/52101/10 "2021-10-19T12:08:13Z")

</div>

Thanks.  
After some debugging here and there (compared to example above)  
I now got it to show as i wished

![press](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/83885f11ae601819c0781ceb8dbc1072d19f8d85.png)
