# Does this line of logic work

**URL:** <https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419>\
**Category:** RAPID Programming\
**Tags:** rapid-code\
**Created:** [April 29, 2024, 2:09pm UTC](https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419 "2024-04-29T14:09:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ollitap](https://avatars.discourse-cdn.com/v4/letter/o/71c47a/32.png) [@ollitap](https://tech-community.robotics.abb.com/u/ollitap)\
**Post date:** [April 29, 2024, 2:09pm UTC](https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419/1 "2024-04-29T14:09:23Z")

</div>

I want to give a person 30 seconds to make a decision. Push the button and the robot will go Home, do not push the button and after 30 seconds the robot will continue its program.  
I wrote this logic. Does it work? I have not tested it. Does anyone have a better way?  
---- WaitUntil GreenButton=1 or TimeFlag and Maxtime\>0;  
I did time flag as VAR Bool Timeflag:=False ----- VAR num MaxTime:=30

I am not sure this will start timing??

---

<div class="post-metadata">

**Author:** ![DenisFR](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@DenisFR](https://tech-community.robotics.abb.com/u/DenisFR)\
**Post date:** [April 29, 2024, 4:11pm UTC](https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419/2 "2024-04-29T16:11:38Z")

</div>

Hello,  
You can use this code:

```auto
VAR bool bTimeFlag;
VAR num nMaxTime:=30;
...
WaitDI GreenButton, 1, \MaxTime:=nMaxTime \TimeFlag:=bTimeFlag \Visualize 
\Header:="Waiting for signal" \MsgArray:=["Movement will not start until", "the 
condition below is TRUE"] \Icon:=iconError;

```

---

<div class="post-metadata">

**Author:** ![ollitap](https://avatars.discourse-cdn.com/v4/letter/o/71c47a/32.png) [@ollitap](https://tech-community.robotics.abb.com/u/ollitap)\
**Post date:** [April 29, 2024, 4:47pm UTC](https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419/3 "2024-04-29T16:47:35Z")

</div>

Here is what I have. The person has 30 seconds to decide to push the button or the robot will goto a label and continue to run.  
I figured this out reading the manuals however, I am not sure how “TimeFlag” works and if I used it correctly?

VAR num MaxTime:=30;!This is the max time the robot will wait for a decision to ACCEPT the cut  
VAR bool TimeFlag := FALSE;

WaitUntil Green\_PB = 1 OR TimeFlag AND MaxTime \>0;  
IF Green\_PB = 1 THEN  
GOTO CutHeightNotAccepted2;  
ELSE  
GOTO ACCEPTED2;  
ENDIF

---

<div class="post-metadata">

**Author:** ![ollitap](https://avatars.discourse-cdn.com/v4/letter/o/71c47a/32.png) [@ollitap](https://tech-community.robotics.abb.com/u/ollitap)\
**Post date:** [April 29, 2024, 4:50pm UTC](https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419/4 "2024-04-29T16:50:59Z")

</div>

a little more explanation. If a person hits the green button, the robot will go to a label that ends the routine and go home and end the program. If the button is not hit after 30 seconds, the robot will goto another label and continue to process.

---

<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:** [April 29, 2024, 7:47pm UTC](https://tech-community.robotics.abb.com/t/does-this-line-of-logic-work/11419/5 "2024-04-29T19:47:26Z")

</div>

Hi

Using the code Denis posted with the if statement and you should probably have a separate routine for each of the options so it become a procedure call not a GoTo:

```auto
VAR bool bTimeFlag;
VAR num nMaxTime:=30;
...
WaitDI GreenButton, 1, \MaxTime:=nMaxTime \TimeFlag:=bTimeFlag \Visualize 
\Header:="Waiting for signal" \MsgArray:=["Movement will not start until", "the 
condition below is TRUE"] \Icon:=iconError;
IF bTimeFlag=True Then
   rAccepted;
ELSE
   rNotAccepted;
ENDIF

```
