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 #4379 is a reply to message #4370] Thu, 25 May 1995 00:00 Go to previous messageGo to previous message
bertin is currently offline  bertin
Messages: 4
Registered: October 1994
Junior Member
Andy Loughe (afl@cdc.noaa.gov) wrote:
> 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!!!
> |> --
>
>
> How about this?
>
> i = WHERE( x GT 0.0, count)
> IF ( count gt 0 ) then 'do something with the x's
>
> The count is very handy indeed. You could also build a
> loop from 0, count-1 if you needed to.
>
> --

or this

IF i(0) EQ -1 THEN ...

Works for vector and scalar i's

Scott J. Bertin
bertin@euler.cpi.com
[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: Sat Oct 11 05:38:27 PDT 2025

Total time taken to generate the page: 0.95553 seconds