Variable accessible in multitasking

Hello,

I am using multitasking and there are currently 2 tasks in my RAPID code. How can I share a variable declared in 1 task and use it in another? I thought PERS var declared in a module is global but I got Reference Error when I applied the change. Can anyone help please?

Thank you.

You have to declare the variable in both tasks. For instance:

task 1:

PERS bool testBool:=TRUE;

task 2:
PERS bool testBool;

Thank you!

I had the same problem. Thanks for de solution.

But I have other problem about global variables.
I can’t share a variable type SPEEDDATA in two tasks.
I always get a Rapid error.
I have used this code:

Example 1:

task 1:

PERS speeddata speed:=V1000;

task 2:
PERS speeddata speed;

Does someone help me?
Is possible to do that?

Thanks a lot

Hi V1000 is a constant variable declared in the system so you need to
either declare your variable with values or assing them later in the program


Thank you.
I am going to test it…