URScript with program with thread

Greetings URCommunity
I’m having some issues writing a script with a thread in it. I am sending the script via TCP/IP through port 30003
Here is the program:
def Prog():
global var = False
set_standard_digital_out(4, True)
set_standard_digital_out(5, True)
sleep(1)
movep(…)
movep(…)
var = True
movep(…)
movep(…)
halt
end

Here is the thread:
thread myThread():
while (var == False):
sleep(0.01)
end
set_standard_digital_out(7, True)
while(get_standard_digital_in(1) == False):
sleep(0.01)
end
end

I think the reason why I need the thread is evident. If I place a while loop between waypoints, the robot is going to stop in between and I want it to keep moving. Thus, the thread is vital.
I have typed this on the teach pendant and had no problem. I haven’t managed to get it to work via URscript
Any help is much appreciated,
Best regards,
Pedro Monforte

Continuing the discussion from URScript with program with thread:

Hi Pedro,
If you’ve write your code in the teach pendant and it works, you can open the .script generated and see what is doing that you are missing.

I think that you need to initialize you thread with a command like this
thread01 = run myThread()

that line must be outside the thread. It is posible to halt threads or kill, you can find this information in the scriptmanual