Shop OBEX P1 Docs P2 Docs Learn Events
Getting out of a conditional loop — Parallax Forums

Getting out of a conditional loop

RME2000RME2000 Posts: 12
edited 2012-12-15 11:05 in Propeller 1
I have been working on some code that runs a conditional continuous loop. When the conditional "while constant < value" is no longer met an object call is made, and the object runs. It all works fine, but I can not figure out how to reset the code to get me back to the original code. Right now everything works as I need it to, but I have to manually hit the reset before re-running the system.

I read that "reboot" can do this from the code, but so far I must not be coding it right. Will someone please show me an example, or give me some information on how to do this?


Thanks

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-14 14:27
    It might to easier to show you how to do it with your code.

    The normal way is to have the conditional loop run inside of a larger loop.
  • JonnyMacJonnyMac Posts: 9,108
    edited 2012-12-14 16:39
    Here's a framework that may help you -- as Duane pointed out you use two loops
    pub main
      repeat
        ' setup code
        repeat
          ' conditional loop code
          if (condition)
            quit
    
  • T ChapT Chap Posts: 4,223
    edited 2012-12-15 06:16
    Another option is to Abort or Abort using a trap to get back to a specific loop
  • MagIO2MagIO2 Posts: 2,243
    edited 2012-12-15 11:05
    I'd never use abort for normal program flow! Abort is meant to be used in exceptional cases, meaning when a real low level function detects a failure and does not know what to do next. And aborts need to be clearly documented!
Sign In or Register to comment.