Home› Programming
Discussion
Back to discussions page
PMonforte
Posts: 2 Recruit
If-statement in URScript not working |
54 views
|
Answered | |
/ Most recent by PMonforte
in Programming
|
3 comments |

in Programming
Greetings DoF community,
I am trying to write an if-statement in an URscript but I haven’t been successful.
Before the if-statement, I have this while loop:
while(get_standard_digital_in(0) == False):
sleep(0.01)
end
This loop works perfectly. I thought the same method would apply to the if-statement but after many tries, I am not able to run the code. This is what I have now:
if(get_standard_digital_in(0) == True):
var_1 = True
end
Before the while loop I have:
global var_1 = False
Unfortunately, this code does not run with the if-statement, even though it runs fine without it so the trouble is definitely in how I am writing it. Any help is much appreciated.
Best regards,
Pedro Monforte
while(get_standard_digital_in(0) == False):
sleep(0.01)
end
Can be written:
while not get_standard_digital_in(0) :
sleep(0.01)
end
Also you should be able to write:
If get_standard_digital_in(0):
var_1
end
The code looks correct to me. Maybe there are some details that can only be seen by looking at the complete script.
if(get_standard_digital_in(0) == True):
var_1 = True
end
However, if I do this,
if(get_standard_digital_in(0) == True):
var_1 = True
sleep(0.01)
end
it works perfectly.
Thank you very much for your replies