Re: IDL FOR Loop variable increments [message #62613 is a reply to message #62612] |
Thu, 18 September 2008 13:03   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Raghu writes:
> In the code above, i want b ( the number of bands) to be incremented
> by the value (b+k) instead of standard consistent increments of 1 or
> 2.. So, instead of b progressing from 0 to 8 as 0,1,2,3 etc..i want it
> to iterate based on the value of (b+k) derived out of the inner FOR
> loop (for k=1, j). My results run correctly but those pixels for which
> 'b' needs a (b+k) increment are not recogized by the line "if b gt 0
> and b ne (c) then continue" and so it keeps skipping all 'b'
> iterations. 'c' here is just a variable assigned to the value of b+k.
>
> Where am i going wrong ?
I think you have clearly chosen the wrong program
construction. You should NEVER be changing a loop
variable inside the loop programmatically. (I don't
think IDL 7 even allows it, since I was inadvertently
doing it the other day and got my hand slapped.) Maybe
you want a WHILE loop.
Cheers,
David
--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|