Hi Ignition Forum,
I have a string coming in over TCP from an RFID reader that I’m looking to parse into an array. I’m testing some code in the Script Console and running into a problem I wouldn’t expect. Here is my code:
from string import split
# Read in the TCP tag.
reader1 = system.tag.read("[default]JBS Truck Tracking/14150/Message")
print(reader1)
# Convert the string into a StringArray.
string_array = reader1.split(',')
# Write the array to Reader1Array
system.tag.write('[default]JBS Truck Tracking/Reader1Array', string_array)
The import works fine, no error. The system.tag.read()
works fine, no error. The print works fine, no error. When I try to use the .split() function, I get:
Traceback (most recent call last):
File "<buffer>", line 8, in <module>
AttributeError: 'com.inductiveautomation.ignition.common.sqltags.Ba' object has no attribute 'split'
I’ve tried various implementations of the split function because I’m not 100% sure which one to use, every time I receive the AttributeError though. Here are some other formats I’ve tried:
string_array = reader1.split(reader1, ',')
string_array = string.split(reader1, ',')
reader1.split(',')
All ideas are good ideas! Thank you in advace!