Shop OBEX P1 Docs P2 Docs Learn Events
how to repeat while one of n statements is true — Parallax Forums

how to repeat while one of n statements is true

youngdaveyoungdave Posts: 70
edited 2009-09-04 23:16 in Propeller 1
Dear All

Is the following type of thing possible in Spin?

repeat while diff_x > previous_diff_x
or
repeat while diff_y > previous_diff_y

or maybe

repeat while diff_x > previous_diff_x or diff_y > previous_diff_y

TIA David Young

Comments

  • JonnyMacJonnyMac Posts: 9,198
    edited 2009-09-04 23:06
    Had you typed that code into the Propeller Tool instead of the forums, you could have pressed F8 and found the answer to be "Yes." tongue.gif

    Of course, withing the repeat while structure you need to update the variables being used in the condition so that you can break free of the loop. You may want to add parenthesis to make your intentions absolutely clear:

    repeat while (x > lastx) or (y > lasty)
      ...
    

    Post Edited (JonnyMac) : 9/4/2009 11:16:26 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-04 23:16
    repeat while diff_x > previous_diff_x or diff_y > previous_diff_y

    is perfectly acceptable
Sign In or Register to comment.