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

Home » Public Forums » archive » index arrays of structures
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: index arrays of structures [message #59296 is a reply to message #59229] Mon, 17 March 2008 10:57 Go to previous messageGo to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Raghu" <raghuram.narasimhan@gmail.com> wrote in message
news:3db3001e-8c15-45a8-814c-9ffc92f43df8@e10g2000prf.google groups.com...
> Hi,
>
> With reference to my recent posting (IDL batch indexing), i understood
> that i could structures. However, i haven't been able to figure out
> one step.
>
> Here is my code as of now:
> ; I want to search for all the images(files) in the directory trials,
> read them into the structure named data, and access each file within
> the structure.
>
> pro strcutres
> dir1='D:\trials'
> cd,dir1
> files=FILE_SEARCH('*[^\.{hdr}]', /QUOTE,count=numfiles)
> i=0
> while i lt numfiles do begin
> named=files(i)
> print,named
> data={ID:'a',sizes:fltarr(2179,761)}
> data=replicate(data,numfiles)
> data.sizes=findgen(numfiles)
> openr,1,named
> readu,1,data[i].sizes
> close,1
> i=i+1
> endwhile
> end
>
> ERROR message- READU: Expression must be named variable in this
> context: <FLOAT Array[2179, 761]>.
>
> I am getting the error here because it seems like i am not able to
> read in the LUN 1 or named, into data[i].sizes.
>
> Where am i going wrong ?
>
> Raghu


I'm not sure if it has been explained, but your error message
is telling you that readu,1,data[i].sizes does now work,
because data[i].sizes is an expression. It is similar to
readu,1,x + 4
or
readu, 1, abs(array)

in that IDL executes the data[i].sizes almost like it was a
function, and it returns the array you request (i.e. the 'sizes'
field of the fourth element of the data array).


Just read it directly into an array, the assign the array to the
structure in a second line.

The fact that your filename is called "named" and the error message
says you need a "named array" is just a coincedence.

ALSO, look at the line:
data.sizes=findgen(numfiles)

I am not sure this is doing what you want it to do.


Cheers,
bob
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Interactive Image Locations and Values
Next Topic: iTools hardware rendering

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

Current Time: Wed Oct 22 14:56:17 PDT 2025

Total time taken to generate the page: 0.00268 seconds