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

Home » Public Forums » archive » Re: FOR loop ends one above where it's supposed to
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: FOR loop ends one above where it's supposed to [message #71134 is a reply to message #71125] Tue, 01 June 2010 22:36 Go to previous messageGo to previous message
cameron bowles is currently offline  cameron bowles
Messages: 5
Registered: May 2010
Junior Member
On Jun 2, 2:34 pm, cameron bowles <cameronbowle...@gmail.com> wrote:
> IDL is a little different to other languages in this regard and it
> handles for loops in this manner;
>
> 1. generates the index variable (first value, in your case i=0)
> 2. generates limit value (last value, in your case 5, stored as a
> temporary variable)
> 3. generates step value (in your case 1, stored as a temporary
> variable)
> 4. checks if limit is greater than index (for positive step values, or
> less than for negative increments), if so then FOR loop finishes.
> 5. the block of statements following the DO is executed.
> 6. the step value is added to the index
> 7. repeat steps 4->6 until step 4 fails.
>
> the difference here is IDL only uses an index variable, a lot of other
> languages uses a secondary temporary value to do the FOR conditional
> check and then updates the index only if the FOR condition is
> satisfied.
>
> hope that helps,
> Cam

I meant step 4 to read;
4. checks if index is greater than limit (for positive step values, or
less than for negative increments), if so then FOR loop finishes.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL for planetary photometry
Next Topic: Re: dealing with arguments

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

Current Time: Wed Oct 08 17:19:03 PDT 2025

Total time taken to generate the page: 0.00436 seconds