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

Home » Public Forums » archive » Re: strpos
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: strpos [message #56731 is a reply to message #56730] Fri, 09 November 2007 05:01 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Nov 9, 5:24 am, greg.a...@googlemail.com wrote:
> I'm cutting up an array of filenames, starting something like this:
>
> p1=strpos(res,'\',/reverse_search)
> p2=strpos(res,'.',p1)
>
> ...and am surprised to get this message:
>
> STRPOS: Expression must be a scalar or 1 element array in this
> context: P1.
>
> I was half-expecting to have to transpose p1, but that it's not
> allowed at all seems an omission to me. Is there any reason for that?
>

Hi,

It seems you'll have to treat the position argument as a scalar. That
means you'll need to loop through to get p2

p2 = STRARR(N_ELEMENTS(res))
for i= 0L, nRes-1 do p2[i] = STRPOS(res[i], '.', p1[i])

Bummer, eh? It seems like such a natural for the use of an array to
manage the position argument. It is either for a very good reason
(which is my bet since string handling is tricky business underneath
the hood) or it is because nobody ever thought of it. In either case,
the documentation doesn't explicitly state that position should be a
scalar, and since the expression can be it is a little misleading.

Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to use customized Hershey fonts?
Next Topic: IDL on windows server 2003

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

Current Time: Sat Oct 11 12:30:45 PDT 2025

Total time taken to generate the page: 0.95976 seconds