# Query

**URL:** <https://tech-community.robotics.abb.com/t/query/2699>\
**Category:** RobotStudio\
**Created:** [April 21, 2009, 12:36am UTC](https://tech-community.robotics.abb.com/t/query/2699 "2009-04-21T00:36:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stud.bs](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@stud.bs](https://tech-community.robotics.abb.com/u/stud.bs)\
**Post date:** [April 21, 2009, 12:36am UTC](https://tech-community.robotics.abb.com/t/query/2699/1 "2009-04-21T00:36:05Z")

</div>

Hi everyone,  
I am new to thr roboyt studio. I have robot cutting application to build that should diplay 3 model options on the touchpendent. The user then selects one out of three options and under this Model selected he gets 3 tasks to perform. The user can choose any one of them. Once that is done, the user press a push button on the machine which would start the robot cutting operation. SO I have tried different wayd to do this task. It would be great if some one could guide me on how can I make the program wait for the start button to be pressed before calling the particular routine.

\*\* but if the user has to perform the same task again he wouldnt have to select the whole model and task again, he just have to press the start button and the same routine that was called previously will be called again.

I could send the program that I have written for the robot and then Some body could give a feedback on it or wat has to be changed.

\*\*\*\*I have multitasking on this robot and I planned to run the Main menu as a seperate Task and all the robots routines and actions will be set up in another Task.  
I tried to save the name of the model selected in a string variable **PERS str strproduct.**

_I tried to call the same string strproduct in another task but for some reason it says that the str is not unknown in that Task._  
_How can we declare a variable as global so that it can be called in any other Task in Multitasking._

_ **please let me know the I can send the code to you.** _

---

<div class="post-metadata">

**Author:** ![RonN](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@RonN](https://tech-community.robotics.abb.com/u/RonN)\
**Post date:** [April 22, 2009, 3:39pm UTC](https://tech-community.robotics.abb.com/t/query/2699/2 "2009-04-22T15:39:58Z")

</div>

Hi,

The exmple below should get you started

MODULE MainModule  
PERS num ProductCode:=0;

PROC main()  
!  
! Initialise the productcode  
ProductCode:=0;  
!  
WHILE TRUE DO  
!  
! Show product selection UI. Usinf DIBreak will abort the menu if the start button is pressed  
ProductCode:=UINumEntry(Header:="Product selection"Message:="Enter the code of the product you want cut"Icon:=IconInfoMinValue:=1MaxValue:=3AsIntegerDIBreak:=diStartCut);  
WaitDI diStartCut,1;  
!  
TEST ProductCode  
CASE 1:  
!  
! Add code here to cut product 1

CASE 2:  
!  
! Add code here to cut product 2

CASE 3:  
!  
! Add code here to cut product 3

DEFAULT:  
UIMsgBox Header:=“Code error”,"Please select a valid code before pressing the start button"Buttons:=btnOKIcon:=iconError;  
ENDTEST  
ENDWHILE  
ENDPROC

ENDMODULE

Sharing variables between tasks is done by declaring the variable in each task. The variable must be a PERS. In you’re declaration of “PERS str strproduct” “str” is not recognized it should say “string”

Br  
Ron nakken

---

<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:** [March 18, 2016, 10:03am UTC](https://tech-community.robotics.abb.com/t/query/2699/3 "2016-03-18T10:03:49Z")

</div>

> [@RonN](#):
>
> The variable must be a PERS.

Is this always the case? Can I use VAR for variable sharing? I asked this because when I was using instruction **WaitSyncTask** on multitask & multimove system with 2 robots, the documentation on **WaitSyncTask** is using **VAR** declaration for **syncident** type variables.

---

<div class="post-metadata">

**Author:** ![graemepaulin](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@graemepaulin](https://tech-community.robotics.abb.com/u/graemepaulin)\
**Post date:** [March 20, 2016, 7:22pm UTC](https://tech-community.robotics.abb.com/t/query/2699/4 "2016-03-20T19:22:47Z")

</div>

From the Multitasking manual:

_To share data between tasks, use persistent variables._

_A persistent variable is global in all tasks where it is declared. The persistent_

_variable must be declared as the same type and size (array dimension) in all tasks._

_Otherwise a runtime error will occur._

_It is sufficient to specify an initial value for the persistent variable in one task. If_

_initial values are specified in several tasks, only the initial value of the first module_

_to load will be used._

 

_Tip_

_When a program is saved, the current value of a persistent variable will be used_

_as initial value in the future. If this is not desired, reset the persistent variable_

_directly after the communication._
