I am trying to use a script that will pick out parts of a string entered and send those parts to another tag. I was able to get this script working on our Dev server:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value != '':
data = str(currentValue)
import re
m = re.search('.*PN: (.+)BN:\\s*([0-9]{7}).*', data)
###system.tag.writeBlocking("[.]JobScan",m.group(0))
system.tag.writeBlocking("[.]PartNumber",m.group(1))
system.tag.writeBlocking("[.]BatchNumber",m.group(2))
else:
system.tag.writeBlocking("[.]PartNumber",'')
system.tag.writeBlocking("[.]BatchNumber",'')
but then I transferred it to our production server and it doesn't seem to work now. I tried to switch the tag paths to point to the new tag paths and it still doesn't work:
def valueChanged(tag, tagPath, previousValue, currentValue,
if currentValue.value != '':
data = str(currentValue.value)
import re
m = re.search('.*PN: (.+)BN:\\s*([0-9]{7}).*', data)
###system.tag.writeBlocking("[.]JobScan",m.group(0))
system.tag.writeBlocking(["[default]E398/E398/JobScanInfo/PartNumber.value"],[m.group(1)])
system.tag.writeBlocking(["[default]E398/E398/JobScanInfo/BatchNumber.value"],[m.group(2)])
else:
system.tag.writeBlocking(["[default]E398/E398/JobScanInfo/PartNumber.value"],[''])
system.tag.writeBlocking(["[default]E398/E398/JobScanInfo/BatchNumber.value"],[''])
Am I missing something?
EDIT:
I tried to copy a working value change script from another tag to this one, and it doesn't work. It works perfectly fine for the tag I copied it from, but when I past it into this tags value changed script, it won't write to the other tag. Here is the script that works for one tag but not the other:
if currentValue.value != '':
system.tag.writeBlocking('[default]{ENumber}/{ENumber}/JobScanInfo/PartNumberMem.value', currentValue.value)