Shop OBEX P1 Docs P2 Docs Learn Events
Nested repeats — Parallax Forums

Nested repeats

davrandavran Posts: 12
edited 2010-02-14 23:49 in Propeller 1
·Dear propeller mates how can i left two or more repeat loops at the same time ?

·i wrote a pseudo code and attached its image.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"Give a lie twenty-four hours start, and it will take a hundred years to overtake it.
" (C.F. Dixon-Johnson, British author of the 1916 book, "The Armenians," appalled over the deceitful practices of his book's subject.)

www.tallarmeniantale.com/

Post Edited (davran) : 2/14/2010 11:16:15 PM GMT

Comments

  • davrandavran Posts: 12
    edited 2010-02-14 23:22
    let me share my propeller system:

    a small tv, ir receiver and rtc on breadboard and·16f887 on left breadboard...




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Give a lie twenty-four hours start, and it will take a hundred years to overtake it.
    " (C.F. Dixon-Johnson, British author of the 1916 book, "The Armenians," appalled over the deceitful practices of his book's subject.)

    www.tallarmeniantale.com/
    320 x 240 - 22K
    320 x 240 - 29K
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-02-14 23:25
    You may want to reconsider your logic. If not, you could create a "breakout" variable that would get set in the deepest loop (just before quit) and propagate upward until you get back to the top. Again, this is a band-aid solution, and I think you might reconsider your program architecture and the use of nested repeats.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon McPhalen
    Hollywood, CA
  • KyeKye Posts: 2,200
    edited 2010-02-14 23:38
    Use quit to break out of inner loop. And quit again to break out of the outer loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-14 23:41
    Ditto on Jon's advice. Generally if you want to be able to exit from an inner loop to one several levels higher, you need to plan for it and generally add exit condition variables. Sometimes it helps to encapsulate each repeat level in a procedure (method).
    PRI overallMethod ' level 0
    REPEAT '1
      level1Method
    
    PRI level1Method ' level 1
      REPEAT '2
        CASE expression
          0: 'stuff
          1: if level2Method
                return
    
    PRI level2Method ' level 2
      REPEAT '3
        CASE expression
          0: 'stuff
          1: return true ' indicates that level 1 should exit
      return false ' indicates normal exit.  level 1 should repeat
    
  • davrandavran Posts: 12
    edited 2010-02-14 23:49
    in fact subconsciously·, ·need for a "goto" instruction blocked my mind, (assembly habits ...)

    ·thank you all . exit condition variables fixed the problem· tongue.gif


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Give a lie twenty-four hours start, and it will take a hundred years to overtake it.
    " (C.F. Dixon-Johnson, British author of the 1916 book, "The Armenians," appalled over the deceitful practices of his book's subject.)

    www.tallarmeniantale.com/
Sign In or Register to comment.