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

Home » Public Forums » archive » a BUG or not a BUG in IDL ?
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
a BUG or not a BUG in IDL ? [message #6644] Thu, 18 July 1996 00:00 Go to next message
Luis E. Liziola is currently offline  Luis E. Liziola
Messages: 2
Registered: May 1996
Junior Member
I have a "warning in loops" for you guys...
Check this "stupid" routine:

;---------------------------------------
print,'Integers'
J = 0
for I = 1,10 do begin
print,I
I = I + J
endfor

print,'Float'
J = 0.0
for I = 1,10 do begin
print,I
I = I + J ; Here I am changing the Type of "I"
endfor

print,'Long'
J = 0L
for I = 1,10 do begin
print,I
I = I + J ; Here I am also changing the type of "I"
;if i gt 20 then stop
endfor
end
;----------------------------------

The first loop if OK, the second loop stops after the first
iteration, but the last loop, just keeps going forever...

Any comments ?
At least should be a "WARNING" in the manual...

Luis
University of Colorado
Re: a BUG or not a BUG in IDL ? [message #6696 is a reply to message #6644] Fri, 26 July 1996 00:00 Go to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <4so62p$42j@reznor.larc.nasa.gov>, g.d.nowicki@larc.nasa.gov (Gregory D. Nowicki) writes:
|>
|> HOLD IT!!!
|>
|> You all seem to be missing the point. There is no language I know of that
|> recommends you modify a control variable within a FOR/DO loop. Results are
|> unpredictable. If fact, there are a fair number of compilers out there
|> that will produce an error if you mess with the control variable, not just a
|> warning.
|>
|> As with any language, there are ways to shoot yourself in the foot. IDL
|> just allows you to do it differently.
|>

As for comments to the original article, I definitely agree with the above.
If you want to mess with a FOR loop variable, make the whole thing into
a WHILE loop (or use GOTOs, I don't care as long as I don't have to maintain
the software). They might have mentioned it in the manual, but who would
read it before finding the problem first?

Stein Vidar Haugan
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: screwy system variables !? [2]
Next Topic: Problem with X display

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

Current Time: Wed Oct 08 13:43:25 PDT 2025

Total time taken to generate the page: 0.00542 seconds