An if cycle with a boolean

Please, I need help with scripting. My objective is to change manually a boolean variable, then when this variable changes, another tag has to assume a fixed value, 40 if the boolean is set to true, false when it is set to 0. What I have to do ? I have tryed this

if “verofalso” == 1:
else: system.tag.write(‘verofalso1’,0)

Thank you in advance for your answers.

Hi! Welcome to the forums!
If this is a tag change script, you also need to specify the tag provider, even if it is the default one:

if "verofalso" == 1: system.tag.write('[default]verofalso1',40) else: system.tag.write('[default]verofalso1',0)

A side note: if you wrap your code within the Code Tags using the button above the editor, it makes your code easier to read… :slight_smile:

if "verofalso" == 1:

You are also comparing the string “verofalso” to the integer 1 which will always be false.

So if I understand this correctly, what you want to do would look something like this:

value ='[default]verofalso').value

if value == 1:
    system.tag.write('[default]verofalso1', 40)
    system.tag.write('[default]verofalso1', 0)

Thank you a lot guys :smiley: