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

Home » Public Forums » archive » Hey! Pssst! Wanna see something wierd?
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
Hey! Pssst! Wanna see something wierd? [message #8012] Fri, 31 January 1997 00:00 Go to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Alright you IDL gurus. Explain this!

number = STRING(10)
FOR j=0, number DO PRINT, 'Cool...!'

Weird, huh. IDL reads my mind! :-)

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
Re: Hey! Pssst! Wanna see something wierd? [message #8089 is a reply to message #8012] Mon, 03 February 1997 00:00 Go to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
David Fanning wrote:
>
> Alright you IDL gurus. Explain this!
>
> number = STRING(10)
> FOR j=0, number DO PRINT, 'Cool...!'
>
> Weird, huh. IDL reads my mind! :-)
>


Seems easy to explain, the string value is simply converted
to integer type because 0 is of that type, to prove this, try
these three options...


FOR j=0, number DO Help, j

FOR j=0L, number DO Help, j

FOR j=0., number DO Help, j


--
Andrew F. Loughe |
afl@cdc.noaa.gov
University of Colorado, CIRES Box 449 |
http://cdc.noaa.gov/~afl
Boulder, CO 80309-0449 | phn:(303)492-0707
fax:(303)497-7013
------------------------------------------------------------ ---------------
"I do not feel obliged to believe that the same God who has endowed us
with
sense, reason, and intellect has intended us to forego their use."
-Galileo
Re: Hey! Pssst! Wanna see something wierd? [message #8091 is a reply to message #8012] Mon, 03 February 1997 00:00 Go to previous message
pit is currently offline  pit
Messages: 92
Registered: January 1996
Member
In article <davidf-ya023080003101971818290001@news.frii.com>,
davidf@dfanning.com (David Fanning) writes:
> Alright you IDL gurus. Explain this!
>
> number = STRING(10)
> FOR j=0, number DO PRINT, 'Cool...!'
>
> Weird, huh. IDL reads my mind! :-)

Sorry, I don't get the point. What's so strange about IDL
recognizing the string '10' as a number? It's doing it since long.
It is even "smart" enough to do:

IDL> print,fix('10asd')
10

Even cooler, eh?

Peter

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Peter "Pit" Suetterlin http://www.uni-sw.gwdg.de/~pit
Universitaets-Sternwarte Goettingen
Tel.: +49 551 39-5048 pit@uni-sw.gwdg.de
-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * --
Come and see the stars! http://www.kis.uni-freiburg.de/~ps/SFB
Sternfreunde Breisgau e.V. Tel.: +49 7641 3492
____________________________________________________________ ______________
Re: Hey! Pssst! Wanna see something wierd? [message #8094 is a reply to message #8012] Mon, 03 February 1997 00:00 Go to previous message
Joseph M Zawodny is currently offline  Joseph M Zawodny
Messages: 24
Registered: March 1996
Junior Member
David Fanning wrote:
>
> Alright you IDL gurus. Explain this!
>
> number = STRING(10)
> FOR j=0, number DO PRINT, 'Cool...!'
>
> Weird, huh. IDL reads my mind! :-)
>
> David

Well since the loop variable of a FOR loop has the type of the
first parameter (namely whatever follows the equal sign) and all
other parameters (end-value and step-value) converted to the
same type, I am not surprised too much. The conversion of properly
formatted string variables to byte, integer, float, ... is well
known (look at READS function). I know this since I have had the
misfortune of expecting the following to work.

for k=0,123456789L do ...

for k=0,5,0.1 do ...

Neither of them worked as I expected until rewritten as

for k=0L,123456789 do ...

for k=0.,5,0.1 do ...

Have fun!

--

Work: Dr. Joseph M. Zawodny Play: Joe Zawodny
NASA Langley Research Center KO4LW@amsat.org
E-mail: J.M.Zawodny@LaRC.NASA.gov zawodny@exis.net
(757) 864-2681 (757) 864-2671 FAX http://wwwp.exis.net/~zawodny
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: KILL_NOTIFY Programs
Next Topic: writing color images - revisited

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

Current Time: Wed Oct 08 17:33:01 PDT 2025

Total time taken to generate the page: 0.00967 seconds