newbie KRL question - simple IF statement

  • Hey everyone. Matt here and I am new to programming KUKA robots.


    I am working on what I think should be a simple program. I am trying to edit a line of code. Here's the original line which works without errors:


    IF (B_at_Robot AND Program_call) then ...


    I need to change it to:


    IF (B_at_Robot AND Program_call AND ValidJobNumber) then ....


    When I change the line, I get an error "Block must not be modified KSS02008". Any ideas about what the problem is?


    thanks

    Building robotic welding systems.

  • That's most likely because you're trying to edit the code while the program is SELECTED rather than OPENED. IF statements cannot be edited while the program is running in the robot interpreter. Cancel the program. Open the file, rather than selecting it, and you should be able to edit as you wish.

  • For all the new KRL programmers out there, a simple mistake I found myself making was using = instead of == in an IF statement.


    When you use =, you're likely to get an error saying something like "block cannot be modified". If you run into this, consider trying ==.

    Building robotic welding systems.


  • For all the new KRL programmers out there, a simple mistake I found myself making was using = instead of == in an IF statement.


    When you use =, you're likely to get an error saying something like "block cannot be modified". If you run into this, consider trying ==.


    when you use = in IF statement it's like you want to put a value inside a variable (like in C++,C#,JAVA) and so on.....
    you must use the == when you want to compare two variables.


    the relational operators are:
    == equal to (int,real,char,enum,bool)
    <> not equal to (int,real,char,enum,bool)
    > greater then (int,real,char,enum)
    < less then ((int,real,char,enum)
    >= greater then or equal to (int,real,char,enum)
    <= less then or equal to (int,real,char,enum)


    not inversion
    and logic and
    or logic or
    exor exclusive or


    priority of operators
    1 high not
    2 * /
    3 + -
    4 and
    5 exor
    6 or
    7 low == <> > < >= <=


    hope that was helpful :icon_smile:

  • That's most likely because you're trying to edit the code while the program is SELECTED rather than OPENED. IF statements cannot be edited while the program is running in the robot interpreter. Cancel the program. Open the file, rather than selecting it, and you should be able to edit as you wish.

    Jeeeeeesus, i was looking for so long for the reason of that behavior.

    i really thank you very much !!!

    you saved all my future/upcoming progression :smiling_face:

  • well... you could have asked or read the manual.

    while you replied to a 8 year old thread it proves that older posts can be useful. :thumbs_up:


    The idea is that selected program is compiled immediately - so that any change can be tested right away. In other words when program is selected changes are to be done only using inline form instructions. Any other change should only be done when program is open rather than selected. Open program is edited like a text file - no compilation takes place until program is saved (if save was chosen while closing). This allows user to create changes that span multiple lines (loops or IF-THEN-ELSE).


    But... everyone makes occasional mistake and makes changes to selected program. And this is where KSS behavior is not always clear cut... Some edits (not talking about inline form edits) to selected program are retained, some are not. This can lead to a lot of frustration. I would really like option to edit code while program is selected... There are many reasons for it, including:

    You are already at correct line so no need to search for it after deselecting and opening program

    You may have run through much of code already and many steps are already done. repeating this is a waste of time - an inefficiency that KUKA has yet to address.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • panic,


    I totally agree to you :smiling_face:
    I also also got frustrated about this many times, thus reading this above was my personally "lifesaver" and i got a lot of endorphins yesterday =D

    Technically I am with the point "reading manuals", but those manuals I read before (hint/glance to "our" other thread, where you helped me) should make those essential information "jumping in your eye".

    So far, i didn't found such a well commented/explained hint like i now got here from you guys.

    ... probably because one doesn't know what phrases to look for until one found it :face_with_tongue: (if one is new and not familiar within in a new topic)

Advertising from our partners