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

Home » Public Forums » archive » Re: Clever Where() test
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: Clever Where() test [message #4436 is a reply to message #4386] Tue, 30 May 1995 00:00 Go to previous messageGo to previous message
offenbrg is currently offline  offenbrg
Messages: 31
Registered: August 1993
Member
afl@cdc.noaa.gov (Andy Loughe) writes:

> In article <moleD93CEG.79n@netcom.com>, mole@netcom.com (Aaron Birenboim) writes:
> |> Is there a clever way to test for null return (-1) from WHERE???
> |>
> |> I'm doing stuff like :
> |>
> |> i = WHERE(x GT 0.0)
> |> s = SIZE(i)
> |> IF s(0) EQ 0 THEN BEGIN
> |> IF i GE 0 THEN BEGIN
> |> ; do something with x(i)
> |> ENDIF
> |> ENDIF ELSE BEGIN
> |> ; do something with the multiple elements x(i)
> |> ENDIF
> |>
> |> Is there a more clever way to handle this? Especially since the
> |> "do something...." code is often the same weather i is scalar or vector.
> |>
> |> I wish that "IF i eq -1 THEN..." wouldnt crash for vector i's!!!
> |> --

There's another cute way:

i = WHERE(x GT 0.0)
IF (i(0) ge 0) THEN BEGIN
blah blah
endIF

If "I" is a scalar, "I(0)" will still equal "I".

Joel

--
"...And I am unanimous in this." - Mrs. Slocumbe
Joel D. Offenberg | offenbrg@fondue.gsfc.nasa.gov
Hughes STX, NASA/GSFC/LASP | (301)-286-5801
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: V4.0 Exclusive Button Groups
Next Topic: Different FFT-results on vector and array?!

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

Current Time: Fri Oct 10 06:31:13 PDT 2025

Total time taken to generate the page: 0.53379 seconds