Jump to content




Breaking Out Of One Loop Without Breaking Out Of Them All


  • You cannot reply to this topic
3 replies to this topic

#1 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 23 September 2013 - 12:07 AM

I'm writing a code that requires a while true do statement inside a repeat statement. I'm using the while true do to wait for a button press for an option posed on the screen, while the repeat is there to let it repeat with a different option. I want to know if I can get out of the while true statement, but STAY in the repeat statement.

Code:
Spoiler

The forums doesn't like that i use tab to organize my code...

#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 23 September 2013 - 08:39 AM

As far as I know, break breaks only one loop (the one on top of the stack). Yep, I was right.

#3 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 23 September 2013 - 12:40 PM

Since LBPHacker already answered the question, and there is nothing more to be added to it, I'm going to answer this statement :P

View PostDragon53535, on 23 September 2013 - 12:07 AM, said:

The forums doesn't like that i use tab to organize my code...
Set your text editor to use 2 spaces instead of a tab, the forums likes that better.

#4 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 23 September 2013 - 01:06 PM

Okay so i'm a moron, the entire reason my code wasn't working wasn't the breaks. I thought it was but the entire reason was at the bottom of the code segment:
tag = bob.readline()
until line == nil
So my code was trying to search for a nil in the first place like line instead of the variable tag which was what was supposed to be there
Though thanks for answering my question, i think i will remember it just in case i think it's the problem at some point in the future.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users