Page 1 of 1

[Implemented] break and continue

Posted: Fri Jul 11, 2003 12:31 am
by matthew180
Greetings,

I'd love to have break and continue added to PB, after the new variable types of course! ;-)

Anyone else miss having break and continue?

Matthew

Posted: Fri Jul 11, 2003 3:22 am
by Karbon
*raises hand*

I do :-)

Re: break and continue

Posted: Fri Jul 11, 2003 11:27 am
by GPI
Have you see the "onError"-Library?

Or what do you mean

Look also for "callDebugger"

GPI

Posted: Fri Jul 11, 2003 12:09 pm
by Fenix
@GPI: I think he´s talking about select/case...



Fenix

Posted: Fri Jul 11, 2003 12:34 pm
by Kale
@GPI: I think he´s talking about select/case...
Yes, and in (for/while) loops :)

Posted: Fri Jul 11, 2003 3:46 pm
by matthew180
Yes, 'break' and 'continue' in reference to looping control structures, for example:

The 'break' statement terminates the execution of the nearest enclosing loop or conditional statement in which it appears. Control passes to the statement that follows the terminated statement, if any.

Code: Select all

  for i = 1 to 100
    if somecondition(i) = 1
      break
    endif
  next
In this example, lets say I want to know what the value that 'i' was when the condition became true, and at that point I also want to terminate the loop. Currently to achieve this you have to do something like this:

Code: Select all

  for i = 1 to 100
    if somecondition(i) = 1
      i_val = i
      i = 100
    endif
  next
The 'continue' statement passes control to the next iteration of the repeat, for, or while statement in which it appears, bypassing any remaining statements in the repeat, for, or while statement body. A typical use of the 'continue' statement is to return to the start of a loop from within a deeply nested loop.

Code: Select all

while i > 0
  i - 1
  x = f( i )
  if x = 1
    continue
  y + x * x
wend
Also, in other languages (C, PHP, etc.) each 'case' section of a 'select' (called 'switch' in other languages) statement has to include a 'break', otherwise, without a break statement, every statement from the matched case label to the end of the 'select', including the default, is executed.

PHP also extends the 'break' statement by allowing a number to follow the 'break' to indicate how many levels of control structures to break from. This is *very* nice to have.

Matthew

Posted: Wed Jul 16, 2003 2:41 pm
by geoff
mathew180 said:
Greetings,
I'd love to have break and continue added to PB, after the new variable types of course!
Break, continue, double variables and other things have been promised for later versions of PB.

Fred, please can you give us some idea when, so we can make plans.

Posted: Thu Jul 17, 2003 12:37 am
by Fred
I don't have a deadline for now, but probably before the end of the year.

Posted: Thu Jul 17, 2003 7:22 am
by Rings
Fred wrote:I don't have a deadline for now, but probably before the end of the year.
pressure, pressure, pressure :wink:

Posted: Thu Jul 17, 2003 2:18 pm
by geoff
Fred, thanks for your timescale, seems reasonable to me.

For your information this is my personal prioritised wish list:
1) Doubles
2) Set JPG save quality
3) Mod function
4) Break keyword in loops

Geoff

Posted: Wed Jul 23, 2003 9:28 pm
by kwag
geoff wrote:Fred, thanks for your timescale, seems reasonable to me.

For your information this is my personal prioritised wish list:
1) Doubles
2) Set JPG save quality
3) Mod function
4) Break keyword in loops

Geoff
Move that "4)" to the top, and also add "continue", together with "break" ;)
We need exit conditions badly :!:

-Karl