# Variable accessible in multitasking

**URL:** https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454
**Category:** RobotStudio
**Created:** [January 15, 2015, 10:50am UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454 "2015-01-15T10:50:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ko414du4](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@ko414du4](https://tech-community.robotics.abb.com/u/ko414du4)
#### Post date: [January 15, 2015, 10:50am UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454/1 "2015-01-15T10:50:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![graafderk](https://avatars.discourse-cdn.com/v4/letter/g/cab0a1/32.png) [@graafderk](https://tech-community.robotics.abb.com/u/graafderk)
#### Post date: [January 15, 2015, 12:39pm UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454/2 "2015-01-15T12:39:31Z")

</div>

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

task 1:

PERS bool testBool:=TRUE;

task 2:  
PERS bool testBool;

---

<div class="post-metadata">

### Author: ![ko414du4](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@ko414du4](https://tech-community.robotics.abb.com/u/ko414du4)
#### Post date: [January 16, 2015, 11:05am UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454/3 "2015-01-16T11:05:32Z")

</div>

> [@graafderk](#):
>
> You have to declare the variable in both tasks. For instance:
> 
> task 1:
> 
> PERS bool testBool:=TRUE;
> 
> task 2:  
> PERS bool testBool;

Thank you!

---

<div class="post-metadata">

### Author: ![J.C.M.Castillo](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/j.c.m.castillo/32/2752_2.png) [@J.C.M.Castillo](https://tech-community.robotics.abb.com/u/J.C.M.Castillo)
#### Post date: [February 27, 2016, 7:45am UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454/4 "2016-02-27T07:45:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![PerSvensson](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/persvensson/32/1040_2.png) [@PerSvensson](https://tech-community.robotics.abb.com/u/PerSvensson)
#### Post date: [February 27, 2016, 1:01pm UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454/5 "2016-02-27T13:01:05Z")

</div>

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

 ![image.jpg](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/1X/19ba4d36ba0ee515c991979feabe964929591448.jpeg)  
 ![image.jpg](https://europe1.discourse-cdn.com/flex005/uploads/robotics1/original/1X/19ba4d36ba0ee515c991979feabe964929591448.jpeg)

---

<div class="post-metadata">

### Author: ![J.C.M.Castillo](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/j.c.m.castillo/32/2752_2.png) [@J.C.M.Castillo](https://tech-community.robotics.abb.com/u/J.C.M.Castillo)
#### Post date: [February 27, 2016, 2:48pm UTC](https://tech-community.robotics.abb.com/t/variable-accessible-in-multitasking/6454/6 "2016-02-27T14:48:21Z")

</div>

Thank you.  
I am going to test it…
