Breaking a foreach loop
Pino Toscano
toscano.pino at tiscali.it
Wed Apr 19 16:36:55 CEST 2006
Alle 16:20, martedì 18 aprile 2006, Brad King ha scritto:
> Pino Toscano wrote:
> > Hello,
> >
> > imagine I'm iterating using a foreach() like this:
> > set(MY_OPTS "foo bar etc")
> > foreach(OPT ${MY_OPTS})
> > # do something ...
> > endforeach(OPT ${MY_OPTS})
> >
> > is there a way to break the iteration, just like a break in C?
> >
> > Whether it exist, does it break even nested foreach()?
>
> This is not possible, but you can simulate it yourself:
>
> SET(OPT_DONE 0)
> foreach(opt ${MY_OPTS})
> if(NOT OPT_DONE)
> #...code...
> if(..need to break..)
> set(OPT_DONE 1)
> endif(..need to break..)
> endif(NOT OPT_DONE)
> endforeach(opt)
That is not what I would like, as this would continue executing the loop. And
if the foreach loop is inside another foreach loop, having to execute all the
iterations is not my best plan...
Regards,
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-buildsystem/attachments/20060419/e1634f72/attachment.pgp
More information about the Kde-buildsystem
mailing list