Re: for loop isn't working [message #71743] |
Thu, 15 July 2010 14:04 |
Snow53
Messages: 32 Registered: July 2010
|
Member |
|
|
On Jul 15, 2:06 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> Snow53 wrote:
>> Hi, you all are so wonderful to help me with my silly questions. Many
>> thanks!
>
>> I have this program that converts files to EASE grid within a folder
>> and outputs them as a different file. It works fine, but the problem I
>> have is that it doesn't loop through all the files in the folder. It
>> stops after the first. I can change the file output by changing i
>> (example: changing to i=2 gives me output for the second file in the
>> list resulting from the search function), but still I only get one
>> file output.
>
>> It must be something obvious, but I'm not seeing it.
>
>> Thanks again. :)
>
>> ; loops through and extracts pixel data based on the above-determined
>> pixel location.
>> for i=1, num_file-1 do begin
>
> you have a nested loop with the same index, and
>
>> for i=0l, 209087-1 do begin
>
>> grid[globland_cols[i]-1,globland_rows[i]-1] = vector[i]
>> endfor
>
> you return before the end of the outer loop.
>
>> return
>
>> endfor
>
>> end
>
> cheers,
>
> paulv- Hide quoted text -
>
> - Show quoted text -
Wow! That was an easy fix. I changed the i in the nested loop to f,
and moved the return until after the second endfor. Thanks for the
extra set of eyes.
|
|
|
Re: for loop isn't working [message #71744 is a reply to message #71743] |
Thu, 15 July 2010 13:06  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Snow53 wrote:
> Hi, you all are so wonderful to help me with my silly questions. Many
> thanks!
>
> I have this program that converts files to EASE grid within a folder
> and outputs them as a different file. It works fine, but the problem I
> have is that it doesn't loop through all the files in the folder. It
> stops after the first. I can change the file output by changing i
> (example: changing to i=2 gives me output for the second file in the
> list resulting from the search function), but still I only get one
> file output.
>
> It must be something obvious, but I'm not seeing it.
>
> Thanks again. :)
>
> ; loops through and extracts pixel data based on the above-determined
> pixel location.
> for i=1, num_file-1 do begin
you have a nested loop with the same index, and
> for i=0l, 209087-1 do begin
>
> grid[globland_cols[i]-1,globland_rows[i]-1] = vector[i]
> endfor
you return before the end of the outer loop.
> return
>
>
> endfor
>
> end
cheers,
paulv
|
|
|