Re: isn't this a bug in RSTRPOS? [message #10621] |
Mon, 05 January 1998 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Russ Welti (rwelti@mapper.mbt.washington.edu) writes:
> IDL> s=["hi","hit","hitter","h"]
> IDL> print,strpos(s,"t")
> -1 2 2 -1
> IDL> print,rstrpos(s,"t")
> % Compiled module: RSTRPOS.
> % Compiled module: REVERSE.
> % Expression must be a scalar in this context: <BYTE Array(4)>.
>
> What gives?
Whoops! My friend, Josh Goldstein, wrote this code a long
time ago. Josh was (probably is, although I haven't seen him
in a long time) one of the best IDL programmers I have ever
seen. He could write IDL code (and always GREAT code) as
fast as I could talk. He wasn't big on testing things, as I
remember. Figuring--I think correctly--that if he wrote it, it
must be right. I was, frankly, in awe of his coding prowess.
But I think he made a mistake here. This code is barfing
on an IF statement. The test condition in an IF statement
must always evaluate to a scalar. This test case cannot
do that. I guess it could be fixed with a FOR loop, but
I can just hear what Josh would have to say about *that*,
so I'm not touching it. :-)
The RSTRPOS source code is in the library.
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|