Copy to another Tag on Value Change

Hello everyone,

I am trying to copy the resulting data of a script from the value change to a memory tag called “orderno”.
I know that this action is possible based on the manual shown below.

However, I tried different scripts including what has been shown in the picture below but non of them worked.

for the reference this is what values[0] is

It is fixed now! I had to make sure the datatype for both tags is “Long” since I am working with 16 digits number as an input.

make sure your tag path is correct.

In your post you say the tag name is orderno however in your script your tag path is [default]ordno.

Also, make sure that your indentation is correct, the script you have shown will throw an error when it runs outside of a value change, say if the quality changes. Otherwise the script should work.

I’ve made changes as since you are using Ignition 8 you should start using the write and read blocking functions instead of the deprecated read and write.

if previousValue.value != currentValue.value:
    numIn = currentValue.value
    textIn = str(numIn)
    slices = [0,7,10,12,len(textIn)]
    values = []
    for i, j in zip(slices,slices[1:]):
        val = int(textIn[i:j])
1 Like

Thank you very much! I appreciate your response to this.

Although I am getting correct values on each of my tags, still I am getting this error every time I hit enter:
"value *** can not be coeraced to integer due to overflow. I changed all tags to be Long and also changed their high limit to 17 digits even though 4 of them are integer.

What kind of component is the barcode going into?

1 Like

Currently I am using a memory tag and I do not have any problem but if I want to bind this memory tag to a numeric entry box then I get these errors, and later on when I have the barcode scanner I have to use a numeric entry box I guess…

I feel like instead of a memory tag I have to use a derived tag and bind that to a numeric entry box.

The numeric entry component has a DataType property that defaults to Integer. Try changing it to Long and that error message should stop popping up.

1 Like

Thank you! Appreciate it.
I remember I changed it to Long but now that I checked again I actually just bind it to Long without changing the data type.