URScript Troubleshoot

Hi,
I have the following script:
string script = “def program():”;
script += “\r\nglobal var = False”;
script += “\r\nif(get_digital_in(2) == True):”;
script += “var = True”;
script += “sleep(1)”;
script += “end”;
script += “\r\nhalt\r\nend\r\n”;
I’m writing this on C# but the URScript does not run. I think it is because of the var = True inside the if statement since if I remove it, the script does run
Am I doing something wrong? Any help is appreciated

Maybe the missing \r\n is the problem?

get_digital_in() has also been deprecated. Should use get_standard_digital_in(), as the manual says the get_digital_in() command may be removed.