Hey everybody,
I am trying to get the value of a string that I pass into a client event script.
path = '[default]LastCurrentModule'
currentModule = system.tag.readBlocking([path])
print currentModule.value
However, when I use this code it returns an error:
“AttributeError: ‘java.util.ArrayList’ object has no attribute ‘value’”
Though when I print just currentModule I get this:
[[Module 1000, Good, Tue Mar 08 09:31:39 CST 2022 (1646753499795)]]
How do I pull out Module 1000?
Thanks in advance!
readBlocking
takes a list of paths to read and returns a list of values. Therefore, to read the value of the tag you read…
path = '[default]LastCurrentModule'
currentModule = system.tag.readBlocking([path])
print currentModule[0].value
1 Like
system.tag.readBlocking returns a list of QualifiedValues, so you first need to get an element of the list before accessing the value. There’s an example of how to do this in the docs.
1 Like
I tried currentModule[0] and currentModule.value but not currentModule[0].value.
Thank you for both of your responses.
1 Like
[[Module 1000, Good, Tue Mar 08 09:31:39 CST 2022 (1646753499795)]]
If you look closely, you’ll see that the returned data is a list of lists, so [0]
gets the first member of the returned list, then .value
gets the value from the fully-qualified tag data list.