Difference between GOTO and LOOP

  • Hello guys,


    I have a question related to the endless loop concept:


    What is the difference between a GOTO instruction used in that manner and the LOOP-ENDLOOP statement:


    Code
    LOOPLABEL:
    ;somecode
    
    GOTO LOOPLABEL

    Thank you.

  • LOOP/ENDLOOP is a rigid construct. it is a 1:1 matching pair of instructions that are at the same level.


    GOTO/LABEL is a loose construct with possibility of 1:many relationship where instructions are not necessarily at the same level. this makes it possible to jump out of the loops for example, jump to earlier program line etc. this loose relationship makes it possible for some interesting and also usually very sketchy uses. these abuses are normally reason for most people frowning at GOTO instructions.

    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

  • this is very basic and well documented feature. also an example of GOT and label is shown at the top of the thread - in the very first post.

    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

Advertising from our partners