# Task Variables

**URL:** <https://tech-community.robotics.abb.com/t/task-variables/4699>\
**Category:** Robot Controller\
**Created:** [February 23, 2012, 12:34pm UTC](https://tech-community.robotics.abb.com/t/task-variables/4699 "2012-02-23T12:34:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RicardoPimenta](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/ricardopimenta/32/4333_2.png) [@RicardoPimenta](https://tech-community.robotics.abb.com/u/RicardoPimenta)\
**Post date:** [February 23, 2012, 12:34pm UTC](https://tech-community.robotics.abb.com/t/task-variables/4699/1 "2012-02-23T12:34:32Z")

</div>

It is possible to use the same variables in more than one task, by that i mean creat the variable in one task and the the value on other one??

Thanks

---

<div class="post-metadata">

**Author:** ![charon](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/charon/32/87_2.png) [@charon](https://tech-community.robotics.abb.com/u/charon)\
**Post date:** [February 23, 2012, 3:46pm UTC](https://tech-community.robotics.abb.com/t/task-variables/4699/2 "2012-02-23T15:46:01Z")

</div>

Hi Ricardo,

You need to define that variable as **Persistent** in both tasks.

e.g

PERS num nVar:=1;

BR.

---

<div class="post-metadata">

**Author:** ![mattdavis](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mattdavis](https://tech-community.robotics.abb.com/u/mattdavis)\
**Post date:** [February 24, 2012, 3:20am UTC](https://tech-community.robotics.abb.com/t/task-variables/4699/3 "2012-02-24T03:20:38Z")

</div>

I have tried to avoid this because I was unsure how it would work.

if task 1 has it defined as =1 and task 2 has it defined as =2.

What will it equal, will it have different values for each task or take whatever value it was assigned last?

---

<div class="post-metadata">

**Author:** ![RicardoPimenta](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/ricardopimenta/32/4333_2.png) [@RicardoPimenta](https://tech-community.robotics.abb.com/u/RicardoPimenta)\
**Post date:** [February 24, 2012, 3:20pm UTC](https://tech-community.robotics.abb.com/t/task-variables/4699/4 "2012-02-24T15:20:37Z")

</div>

Thanks it works fine! :stuck\_out\_tongue\_winking\_eye:

---

<div class="post-metadata">

**Author:** ![jonathan2340](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@jonathan2340](https://tech-community.robotics.abb.com/u/jonathan2340)\
**Post date:** [March 12, 2012, 12:02pm UTC](https://tech-community.robotics.abb.com/t/task-variables/4699/5 "2012-03-12T12:02:54Z")

</div>

I just want to say that this is a quiet interesting post that you have mentioned here. keep it up.

---

<div class="post-metadata">

**Author:** ![leonardolt](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/leonardolt/32/880_2.png) [@leonardolt](https://tech-community.robotics.abb.com/u/leonardolt)\
**Post date:** [March 12, 2012, 4:23pm UTC](https://tech-community.robotics.abb.com/t/task-variables/4699/6 "2012-03-12T16:23:22Z")

</div>

mattdavis,  
As I could notice here, the variable keeps the las assigned value, it does not matter if it was done in Task1 or Task2. But there is something you must keep on mind: you can only initialize a shared persistent in one task. It means the declaration PERS num nVar:=1; should appear only in Task1 or in Task2, never in both.
