Read-only archive of the All About Symbian forum (2001–2013) · About this archive

BREAK or CONTINUE out of IF THEN / ENDIF-Loops

3 replies · 2,346 views · Started 24 April 2003

Hi!

It is possible to end DO ... UNTIL and WHILE ... ENDWH-Loops
by the use of BREAK or CONTINUE.

BREAK or CONTINUE are NOT working within a simple
IF THEN / ENDIF-Structure.

How can I jump out of and IF THEN ... ENDIF-Structure ?

Or isn�t that possible ...

(good old ZX Spectrum BASIC have IF THEN without ENDIF needed .. 😉 )

Luzie

this will work:

if (blah) / while (blah)
.....
GOTO throwout::
.....
endif / endwh
throwout::

greets

Depends if you want to run the command AFTER the IF.ENDIF or if you want to leave the Procedure.

If you're just breaking out the IF.ENDIF then hile the GOTO dazler shows above does work, it would be mch more elegant to re-construct the IF statement so you don't need the GOTO if at all possible.

If you want to leave the procedure and return to wherever you called the procedure, you can use the RETURN command.

Personnaly I try to avoid the GOTO except for Error Trapping, so I'd go for a rethink on the IF statement.

Indeed, you will never need any break or goto.
In vb and opl I 2 only use them for error handling.