IF Statement in Rapid

mark457bmark457b Denmark
edited June 4 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

  • mark457bmark457b Denmark
    Would i use jumplabel ?

  • lemster68lemster68 United States ✭✭✭
    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
  • mark457bmark457b Denmark
    Thanks lemster68 😊
    I will keep at it !
  • DenisFRDenisFR FRANCE ✭✭✭
    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.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!