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

Home » Public Forums » archive » Re: Interesting WHERE function gotcha
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: Interesting WHERE function gotcha [message #33935 is a reply to message #33934] Thu, 06 February 2003 18:35 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
David Fanning <david@dfanning.com> writes:
>
> How about this:
>
> Help, veggie_letter, letter
> VEGGIE_LETTER BYTE = Array[4]
> LETTER BYTE = Array[1]
>
> "LETTER, a byte *array*!? You don't suppose..." Try this:
>
> index = WHERE( (Byte(array))[0,*] EQ (Byte('a'))[0], count)
> Print, count
> 2
>
> Hummm. V-e-r-y interesting...
>
> Now I know how to fix the problem, but I don't know exactly
> what the problem is. (Although this is not so different
> from most computer problems, when you come to think of it.)
> Is the problem that the BYTE function always makes a byte
> *array* when extracting string arguments? Or is it that
> the WHERE function acts in a, uh, non-intuitive way when
> there are two vectors in a boolean expression?

Hi David!

You are being bitten by the "feature" that I love so much. Namely
that in IDL, when you do "X OPERATION Y", and X and Y are both arrays,
then the expression is trimmed to the smaller of the two arrays.

So it's not anything special regarding WHERE, or boolean expressions,
but rather that VEGGIE_LETTER EQ LETTER evaluates to a 1-element
array. One element, because LETTER only has one element:

IDL> help, veggie_letter EQ letter
<Expression> BYTE = Array[1]

There are many times that I wish that IDL has an easier way to get the
ASCII value of a character.

By the way, why not do this instead?

index = where( strmid(array,0,1) EQ 'a')

This avoids the whole issue of converting to a different
representation, and it just looks less gobbledygooky.

Happy guacamole,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: p_correlate
Next Topic: Re: SQL access without Dataminer (perl off topic)

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

Current Time: Fri Oct 10 17:10:45 PDT 2025

Total time taken to generate the page: 0.80011 seconds