# \-1 shows up on a numeric text field bound to PLC/OPC tag

**URL:** <https://forum.inductiveautomation.com/t/1-shows-up-on-a-numeric-text-field-bound-to-plc-opc-tag/9475>\
**Category:** General Discussion\
**Created:** [December 22, 2014, 1:52pm UTC](https://forum.inductiveautomation.com/t/1-shows-up-on-a-numeric-text-field-bound-to-plc-opc-tag/9475 "2014-12-22T13:52:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pstojakovic](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@pstojakovic](https://forum.inductiveautomation.com/u/pstojakovic)\
**Post date:** [December 22, 2014, 1:52pm UTC](https://forum.inductiveautomation.com/t/1-shows-up-on-a-numeric-text-field-bound-to-plc-opc-tag/9475/1 "2014-12-22T13:52:20Z")

</div>

I have a numeric text field which has its integer value bound to the PLC tag, but also I scripted it to write to the tag as well. User can type in a number - press Enter - value writes to the tag. The problem is that every once in a while - 1 shows up in the field and messes up the tag. I have the tag set up to accept only the range of 0 to 200 and nothing else. What causes -1 to show up in the field? —Is it the OPC problem? How to prevent it from showing and writing to the PLC tag? So, I want the number that is entered to stay in the text field unless someone changes it.

Thanks.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 14, 2015, 11:57am UTC](https://forum.inductiveautomation.com/t/1-shows-up-on-a-numeric-text-field-bound-to-plc-opc-tag/9475/2 "2015-05-14T11:57:47Z")

</div>

[quote=“pstojakovic”]I have a numeric text field which has its integer value bound to the PLC tag, but also I scripted it to write to the tag as well. User can type in a number - press Enter - value writes to the tag. The problem is that every once in a while - 1 shows up in the field and messes up the tag. I have the tag set up to accept only the range of 0 to 200 and nothing else. What causes -1 to show up in the field? —Is it the OPC problem? How to prevent it from showing and writing to the PLC tag? So, I want the number that is entered to stay in the text field unless someone changes it.

Thanks.[/quote]  
Same is happening by me also… Nobody?

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [May 18, 2015, 11:11pm UTC](https://forum.inductiveautomation.com/t/1-shows-up-on-a-numeric-text-field-bound-to-plc-opc-tag/9475/3 "2015-05-18T23:11:45Z")

</div>

What kind of script are you using to write the value to the tag? Is it a propertyChange script?

Why are you writing the value to the tag with a script? A bidirectional binding on the component would allow you to write a value back to the tag and you would not need to script the write.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [May 19, 2015, 6:04am UTC](https://forum.inductiveautomation.com/t/1-shows-up-on-a-numeric-text-field-bound-to-plc-opc-tag/9475/4 "2015-05-19T06:04:44Z")

</div>

[quote=“Greg.Simpson”]What kind of script are you using to write the value to the tag? Is it a propertyChange script?

Why are you writing the value to the tag with a script? A bidirectional binding on the component would allow you to write a value back to the tag and you would not need to script the write.[/quote]  
If it would be that simple… 🙂  
I’m using numeric text field in the template for converting the integer (milliseconds) to Siemens Simatic PLC timer format (S5Time). And that requires some custom tag types and ‘some’ scripting…
