Problem using the method List->ToArray() [message #75971] |
Wed, 11 May 2011 08:02 |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Hi folks,
I have a list containing 2885 structures of the same type. When I want
to convert the list to an array I get the following error:
% LIST::TOARRAY: Unable to convert to type STRUCT: Element 260
LOL ! All the elements are the same type so I don't see what's going
on.. Anyone experienced this ?
Here is how I verify if all the elements in the list are the same:
;; GETTING THE TAG NAMES AND TAG TYPES OF THE FIRST STRUCTURE
str_ntags=N_TAGS(data[0])
str_names=TAG_NAMES(data[0])
str_types=INTARR(str_ntags)
FOR i=0l, str_ntags-1 DO str_types[i]=SIZE(data[0].(i),/TYPE)
;; THE CODE WILL STOP IF ONE ELEMENT IS NOT EQUAL TO THE FIRST ONE
FOR i=0l, N_ELEMENTS(data)-1 DO BEGIN
aux_names=TAG_NAMES(data[i])
IF N_ELEMENTS(aux_names) NE str_ntags THEN STOP
FOR j=0l, str_ntags-1 DO BEGIN
IF aux_names[j] NE str_names[j] THEN STOP
IF str_types[j] NE SIZE(data[i].(j),/TYPE) THEN STOP
ENDFOR
ENDFOR
Thank you,
nata
|
|
|