# Trap Routines

**URL:** <https://tech-community.robotics.abb.com/t/trap-routines/5834>\
**Category:** RobotStudio\
**Tags:** trap, routines\
**Created:** [November 28, 2013, 2:30pm UTC](https://tech-community.robotics.abb.com/t/trap-routines/5834 "2013-11-28T14:30:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ercan](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/ercan/32/1220_2.png) [@Ercan](https://tech-community.robotics.abb.com/u/Ercan)\
**Post date:** [November 28, 2013, 2:30pm UTC](https://tech-community.robotics.abb.com/t/trap-routines/5834/1 "2013-11-28T14:30:17Z")

</div>

Hello everyone,

I have some questions for you. I want to learn somethng about trap routines. For exaple Why I must use trap routiens? or How can I use that? I need basic samples about this. I found a module aboot Trap routines. But I didnt understand well. I hope you cam help me. Thanks for all

```auto
MODULE Warning
  VAR intnum nTimeInt_1;
  VAR intnum nTimeInt_2;
  PERS bool sim_test:=FALSE;
  PERS bool OpStart:=TRUE;

  PROC main()
    !===============================================================
    !TIME TRAP 1 CONNECTION
    !===============================================================
    IDelete nTimeInt_1;
    CONNECT nTimeInt_1 WITH TimeTrap1;
    ITimer 1,nTimeInt_1;
    !===============================================================
    !TIME TRAP 2 CONNECTION
    !===============================================================
    IDelete nTimeInt_2;
    CONNECT nTimeInt_2 WITH TimeTrap2;
    ITimer 0.5,nTimeInt_2;
    WHILE TRUE DO
      CheckErrorStatus;
      SystemStatus;
      IF OpStart=FALSE THEN
        IF DOutput(bFlash_1)=1 THEN
          Set doStReadyLamp;
        ELSE
          Reset doStReadyLamp;
        ENDIF
      ELSE
        Set doStReadyLamp;
      ENDIF
      WaitTime 0.3;
    ENDWHILE
  ENDPROC

```

---

<div class="post-metadata">

**Author:** ![Henrik\_Berlin](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/henrik_berlin/32/1011_2.png) [@Henrik\_Berlin](https://tech-community.robotics.abb.com/u/Henrik_Berlin)\
**Post date:** [December 2, 2013, 6:03pm UTC](https://tech-community.robotics.abb.com/t/trap-routines/5834/2 "2013-12-02T18:03:17Z")

</div>

The manual **RAPID Overview** that is available in RobotStudio provides a good starting point.

TRAP routines are convenient when you want to interrupt the program flow to act on some external event.

/Henrik

---

<div class="post-metadata">

**Author:** ![Ercan](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/ercan/32/1220_2.png) [@Ercan](https://tech-community.robotics.abb.com/u/Ercan)\
**Post date:** [December 3, 2013, 7:58am UTC](https://tech-community.robotics.abb.com/t/trap-routines/5834/3 "2013-12-03T07:58:37Z")

</div>

Thanks Henrik for your informations
