If statements using tags

Im really new so would like some help with if with this if statement that is incorrect but not sure how it’s supposed to look like.

if system.tag.read(“tag1”).value =Null:
system.tag.write(“tag2”).value = 1

They are both integers.

It would be like

if system.tag.readBlocking(["tag1"])[0].value is None:
    system.tag.writeBlocking(["tag2"], [1])

Read more here
and here

Highly recommend taking the Inductive University courses if you have not already.

I’m also unsure under what conditions a tag will return a None though I suppose it’s possible.

As noted above, in checking for Null Python uses is None, not unlike SQL. But if you are doing an actual equality check, make sure you are using ==, not =.

At least it doesn’t get you in as much trouble as C will if you use =, because Ignition will squiggly line it (so watch for that), C/C++ will just accept it as an assignment statement and let you tear your hair out until you notice it.