I am trying to script an MOA tag in Ignition but it keeps giving me the same error. Syntax Error on Token: ‘BOUND CONST’ (Line 1 , Char 31). Here is the code itself attached to the Multi-State Switch and the MOA tag.
if {[.]../digital/cr_minus_bit} == 0:
{[.]../bypass/cr_minus_bypass} = True
{[.]../bypass/cr_minus_bypass_off} = False
if {[.]../digital/cr_minus_bit} == 1:
{[.]../bypass/cr_minus_bypass} = False
{[.]../bypass/cr_minus_bypass_off} = False
if {[.]../digital/cr_minus_bit} == 2:
{[.]../bypass/cr_minus_bypass} = False
{[.]../bypass/cr_minus_bypass_off} = True
Additionally in the expression language you use a single = for comparison. You would also need parentheses around your if( {[.]…/digital/cr_minus_bit}=0, 'someTrueValue', 'someFalseValue') statement. Check out the documentation here - https://docs.inductiveautomation.com/display/DOC80/if
You’ve tagged your post with python, and your script looks kinda like python, but you’re using the expression style {tag}. Which are you using, python or expression ?
For expression, see posts above.
For python, you can’t access tags like this, you need to use system.tag.readBlocking/readAsync and system.tag.writeBlocking/writeAsync functions.
Also, if you’re using python, I’d suggest reducing the number of if statements:
Brandon, please use the </> code formatting button when posting code. It will indent properly (important for Python) and give syntax highlighting. You can use the 🖉 edit link to fix your post.
I have tried using every tool I was given on here and still not working. Is it actually possible to write out an expression or scripting for a Manual Off Auto switch that Ignition will accept besides making a tag in the PLC?
So I’m trying the custom properties fix, it works partially. it still will not change the values of the tags associated with the properties. They are OPC tags inside of a UDT instance.
Yes, I followed what @JordanCClark had above to the letter, barring changing some things to fit the tag names, and it seems as if Ignition refuses to accept it.