RobotStudio event

IF Statement in Rapid

mark457b
mark457b
edited June 2020 in RobotStudio
Hello im thinking of inserting an if statement so if the criteria is fulfilled it jumps to a certain place in the Rapid Program.

If i wanna do this in the program i have attached as a picture here.

I know in other programming tools you could say if diAkselInPos,1 jump to line 41.

How would i go about doing that in RobotStudio?

Comments

  • Would i use jumplabel ?

  • lemster68
    lemster68 ✭✭✭
    The statement is GOTO in Rapid.  Some purists really dislike those.  There are many ways in Rapid to accomplish the same result.  Some clean and tidy, some not so much.  You could call a subroutine if this condition is met and then return to where you leave off in this routine.  Many, many ways to go about it.  The only limit is your knowledge and creativity.  The knowledge will come, keep at it.
    Lee Justice
  • Thanks lemster68 😊
    I will keep at it !
  • DenisFR
    DenisFR ✭✭✭
    Hello,
    RAPID is more like python or other evolute language.
    You have to insert inside the IF statement what you have to do like in C.
    So for your example, Add "IF yourcondition THEN" at line 40-41 and "ENDIF" at line 80-81.
    Here an example from RAPID help:

    IF reg1 > 5 THEN
      Set do1;
      Set do2;
    ELSE
      Reset do1;
      Reset do2;
    ENDIF

    Like lemster68 said avoid a max GOTO as this get your code unreadable and may cause bug.