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

Home » Public Forums » archive » Re: 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 #76179 is a reply to message #76178] Fri, 20 May 2011 09:54 Go to previous messageGo to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On May 19, 8:44 pm, Barry Lesht <ble...@gmail.com> wrote:
> 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.

Hi Barry,

If you have IDL 8.1, you can now use multiple indices with List and
Hash. The first index gets the actual list (or hash) element, while
the remaining indices are used to index into the returned array. So in
your case, you could simply do:
print, splitnames[27,3]
This would take the 28th element of the list and extract the 4th
string. You can also use the usual array ranges, *, etc.

Regarding your particular problem, I am curious about what is wrong
with element 798. I'm worried there is a bug either in the strsplit
list code, or in the List::ToArray code, and I'd like to fix it. Can
you try the ::ToArray again, and when it halts with the error, print
out some info about element 798? For example:
HELP, splitnames[798]
PRINT, splitnames[798]

Thanks!
-Chris
ITTVIS
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL Book Sale
Next Topic: Constant Size Array in Class Init

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

Current Time: Wed Oct 08 20:13:45 PDT 2025

Total time taken to generate the page: 0.66984 seconds