Python Scripting Question

Hello All:
I am trying to extract bits from integer by using simple python script as shown below:
vaule=currentValue>>(7&1)
system.tag.write(“PLC/SensorFailure”, currentValue)
This script works with Python IDE (2.7 and 3.x) both, but it is giving me error as shown in the attachment

Could you please let me know what is the problem
Thanks,
Shwetha.

currentValue is not a primitive value. It is a BasicTagValue. To get the actual value as a primitive, in this case, you need to go something like this, using your example:

vaule=currentValue.value>>(7&1)
1 Like

If you read the comment section at the top of the script you will notice that:

currentValue: This current value. This is a “qualified value”, so it has value, quality, and timestamp properties.

Try using currentValue.value.

EDIT: Kyle beat me to it. :wink:

1 Like

Thank you, Both. It works.

Shwetha

1 Like