Im assuming that you cant use the useBounds of the numeric text box.
So it depends on how often you need to do it. If it is just a few times then you can take care of this in the propertyChange script of the components. Much more then that and you’ll need a more centralized method.
I would create a shared/project script utility to enforce your limits, something like the following:
def commitTagWrite(self, tagPath, newValue, oldValue, lowLimit, highLimit):
if newValue:
if newValue != oldValue and newValue >= lowLimit and newValue <= highLimit:
system.tag.write(tagPath,newValue)
return True
return False
On the component, do not bind directly to the tag. Instead, in the scripting do something like this:
if event.propertyName == 'value':
if not project.scriptName.commitTagWrite('your tag path',event.newValue, event.oldValue, 0,100):
event.value = oldValue
It may be worth adding a custom property to the component/template to hold the tagPath so it isn’t hard coded, but again that is dependent on how many times you need to do this.
This would write the new value if it was between 0 - 100, the oldValue if it was outside those limits, and do nothing if the newValue is None.
You can also wrap all of this in a Try/Except block and use a Logger for various things. Probably not a bad idea especially if you have several of these to do.
Of course there may be a better way of accomplishing the task that I am not aware of.