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 #76171 is a reply to message #76170] Fri, 20 May 2011 13:45 Go to previous messageGo to previous message
BLesht is currently offline  BLesht
Messages: 89
Registered: March 2007
Member
On May 20, 11:54 am, Chris Torrence <gorth...@gmail.com> wrote:
> 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

Hi Chris - Thanks! I'm using 8.0.1 but will update shortly. Maybe
that will fix the problem. Here is the output corresponding to your
suggestion:

IDL> help, splitname[798]
<Expression> STRING = Array[7]
IDL> print, splitname[798]
Volumes 2TBDrive SeaWiFS L2standard62 Superior 2009
S2009238193838.L2.x.hdf
IDL>

Also, look at this:

IDL> print, splitname[796:798]
Volumes 2TBDrive SeaWiFS L2standard62 Superior 2008
S2008239191527.L2.x.hdf
Volumes 2TBDrive SeaWiFS L2standard62 Superior 2008
S2008239191527.L2.x.hdf
Volumes 2TBDrive SeaWiFS L2standard62 Superior 2009
S2009238193838.L2.x.hdf
IDL>

and this:

IDL> newnames = splitname[0:796]
IDL> tryarray = newnames.ToArray()
% LIST::TOARRAY: Unable to convert to type STRING: Element 791
% Error occurred at: LIST::TOARRAY
% $MAIN$
% Execution halted at: $MAIN$

Barry
[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 17:43:23 PDT 2025

Total time taken to generate the page: 0.00563 seconds