comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: repeat vs. while
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: repeat vs. while [message #82154] Wed, 21 November 2012 14:37
Mark Piper is currently offline  Mark Piper
Messages: 198
Registered: December 2009
Senior Member
On Wednesday, November 21, 2012 2:16:05 PM UTC-7, David Fanning wrote:
> rr...@stsci.edu writes:
>
>
>
>> Can anyone explain the difference between repeat and while? Is there any reason to use one vs. the other?
>
>
>
> REPEAT will check the loop condition at the bottom of the loop.
>
> WHILE will check the loop condition at the top of the loop.
>
>
>
> You use one or the other depending on when you want to
>
> stop executing the loop.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Another way of thinking of this is that REPEAT is guaranteed to execute at least once, whereas WHILE may execute zero times.

mp
Re: repeat vs. while [message #82155 is a reply to message #82154] Wed, 21 November 2012 13:16 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rryan@stsci.edu writes:

> Can anyone explain the difference between repeat and while? Is there any reason to use one vs. the other?

REPEAT will check the loop condition at the bottom of the loop.
WHILE will check the loop condition at the top of the loop.

You use one or the other depending on when you want to
stop executing the loop.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: picking an option with radio buttons
Next Topic: Unicode in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:53:33 PDT 2025

Total time taken to generate the page: 0.00645 seconds