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 #4386 is a reply to message #4370] Wed, 24 May 1995 00:00 Go to previous messageGo to previous message
afl is currently offline  afl
Messages: 51
Registered: December 1994
Member
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.

--

Andrew F. Loughe email: afl@cdc.noaa.gov
University of Colorado, CIRES voice: (303) 492-0707
Campus Box 449 fax: (303) 497-7013
Boulder, CO 80309-0449 USA
[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: Thu Oct 09 07:02:39 PDT 2025

Total time taken to generate the page: 0.80231 seconds