Shop OBEX P1 Docs P2 Docs Learn Events
Loop with DO or with GOTO Main? — Parallax Forums

Loop with DO or with GOTO Main?

John KauffmanJohn Kauffman Posts: 653
edited 2006-10-13 05:03 in General Discussion
In the situation where an entire program runs continuosly, I have seen two options in the literature:
1 - Put the whole program in a DO ... LOOP inside Main:
2 - Use the Main: ... GoTo Main commands in the template
Both work.

Is there any difference (practical or theoretical) between the two practices?
Thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-13 05:03
    There's no practical difference between the two practices. Both result in essentially a jump instruction

    Theoretically, the DO ... LOOP structure is better in that
    1) there's no label needed that may be purely arbitrary (a placeholder only)
    2) the structure explains what is intended. Using a label and a GOTO may be part of some more
    complex program flow or it just might be a way to implement a DO ... LOOP. You can't tell
    without examining the whole program (for another GOTO Main).
Sign In or Register to comment.