# Rapid code is not working.

**URL:** <https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294>\
**Category:** Developer Tools\
**Tags:** pc-sdk, robotstudio, virtual-irc5, rapid\
**Created:** [June 8, 2018, 8:57pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294 "2018-06-08T20:57:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EugeneB](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@EugeneB](https://tech-community.robotics.abb.com/u/EugeneB)\
**Post date:** [June 8, 2018, 8:57pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294/1 "2018-06-08T20:57:52Z")

</div>

Trying to add value to the variable - ‘number’, and if ‘number’ == 5 then do message box. Not working. My variable remains in 0.  
My PROC:

PROC user\_selection()  
VAR num answer;  
VAR num number;

VAR btnres answer2;

!Testing TPReadFK and IF, IFELSE statements.  
!PulseDO\PLength:=1.5, doFeedBkwd\_W1\_R1;

!can be up to 5 uptions. If less then 5 write - stEmpty  
TPReadFK answer,“Select which way to go”,“Left”,“Right”,“Center”,“CheckLoop”,“Dispose Mudule”;

IF answer=1 THEN  
Pth\_2\_left;  
number := number + 1;  
ELSEIF answer=2 THEN  
Pth\_3\_right;  
number := number + 1;  
ELSEIF answer=4 THEN  
t\_LogicLoopStop;  
number := number + 1;  
ELSEIF answer=5 THEN  
disposeModule;  
number := number + 1;  
ELSE  
Pth\_1\_center;  
number := number + 1;  
ENDIF

IF number = 5 THEN  
UIMsgBox\Header:=“UIMsgBox Header”,“Number is 5”\MsgLine2:=“”\MsgLine3:=“”\MsgLine4:=“”\MsgLine5:=" "\Buttons:=btnOKCancel\Icon:=iconInfo\Result:=answer2;  
IF answer = resOK disposeModule;  
ENDIF  
!  
ENDPROC

What I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![soup](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/soup/32/1592_2.png) [@soup](https://tech-community.robotics.abb.com/u/soup)\
**Post date:** [June 8, 2018, 9:19pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294/2 "2018-06-08T21:19:05Z")

</div>

Do you get an error message?

---

<div class="post-metadata">

**Author:** ![soup](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/soup/32/1592_2.png) [@soup](https://tech-community.robotics.abb.com/u/soup)\
**Post date:** [June 8, 2018, 9:26pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294/3 "2018-06-08T21:26:20Z")

</div>

Try putting:

TPWrite NumToStr(number, 0);  
Stop;

at different places to see what the value is before and after you do number+1.

Also, then put the VAR as a Global variable by putting it at the top of the module, outside a proc, and see if that changes the way it counts.

---

<div class="post-metadata">

**Author:** ![EugeneB](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@EugeneB](https://tech-community.robotics.abb.com/u/EugeneB)\
**Post date:** [June 8, 2018, 9:56pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294/4 "2018-06-08T21:56:42Z")

</div>

Nothing. Variable = 0;  
No error messages.

---

<div class="post-metadata">

**Author:** ![EugeneB](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@EugeneB](https://tech-community.robotics.abb.com/u/EugeneB)\
**Post date:** [June 8, 2018, 10:10pm UTC](https://tech-community.robotics.abb.com/t/rapid-code-is-not-working/8294/5 "2018-06-08T22:10:35Z")

</div>

I move my variable outside of my proc and it worked. Thanks.
