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

Home » Public Forums » archive » Dealing with list created by STRSPLIT?
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: Dealing with list created by STRSPLIT? [message #81009 is a reply to message #76194] Sat, 04 August 2012 01:52 Go to previous message
zhyf87 is currently offline  zhyf87
Messages: 1
Registered: August 2012
Junior Member
在 2011年5月20日星期五UTC+8上午10时44分42秒,Barry Lesht写道:
> I have an array of full-path filenames from which I need to extract
> some substrings. The array consists of a large number of strings of
> the form
>
> diskname/maindir/subdir1/subdir2/subdir3/filename
> diskname/maindir/subidr1/subdir2/subdir3/filename etc.
>
> The lengths of the subdirXs can be different. What I wanted to do was
> create some arrays the elements of which would be the subdirXs. I
> thought this would be simple now that STRSPLIT allows arrays as
> input. I had the array of n filenames in a string array and I used
>
> splitnames = STRSPLIT(filenames, '/', /EXTRACT).
>
> The result 'splitnames' is a list with n elements and each element is
> of the form
>
> diskname maindir subdir1 subdir2 subdir3 filename as it should be.
> Each element is a string array.
>
> What I can't seem to figure out is how to now extract one of these
> terms from the list element. That is, I'd like to end up with arrays
> that have the n subdir2s (for example). I've tried using the
> LIST::TOARRAY () feature but this fails for some mysterious reason
> with the message
>
> IDL> namearray=splitnames.ToArray()
> % LIST::TOARRAY: Unable to convert to type STRING: Element 798
> % Error occurred at: LIST::TOARRAY
> % $MAIN$
> % Execution halted at: $MAIN$
>
> Element 798 is no different from any of the elements in the list, by
> the way, but this is not the real problem (at least I don't think it
> is)
>
> There must be an easy way to do this; I'm not seeing it. Any help
> would be much appreciated.

same problem here with 8.0
first indice must be a scalar while exacting elements, and LIST.ToArray doesn't work. for loop solves this :)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: solving non linear equation
Next Topic: FINDGEN function - Question

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

Current Time: Wed Oct 08 13:59:44 PDT 2025

Total time taken to generate the page: 0.00431 seconds