[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: taming the shrew, a.k.a. structure



David Fanning wrote:

> Here is what I tried:
>
> IDL> month_struct = {month_struct, name: ptr_new( ), day: ptr_new(), $
>        temp_c: Ptr_New()}
> IDL> station = {station, number:0L, month:{month_struct}}
> IDL> po_basin = replicate (station, 2)
> IDL> po_basin.month.name = ptr_new( strarr(2190) )
> IDL> *((po_basin)[0].month.name) = 'dad'
> IDL> *((po_basin)[1].month.name) = 'mom'
>
> What is the problem!?
>

Good question!
I took snipets of advice from all the responses and played around with them a
bit, but I'm still not successful at getting the pointers to work.
Unfortunately, I'm not quite sure what I'm doing wrong.  Since I only started
programming in march, and that was in C (IDL just a few weeks ago), my comfort
with pointers is...well...closer to discomfort.  I appreciate you all taking the
time to help out.  If you want to get the full picture, I just did a quick and
dirty job of posting the .pro file (along with the data file it requires) on my
website at
http://instaar.colorado.edu/~hilberma/
click on the idl link.

Two questions come to mind:
David, you gave the nice example of *((po_basin)[0].month.name) = 'dad' as a way
to define the zeroth element of the po_basin array; is this the same sytax you
would use to access and manipulate po_basin[0]?  In other words, does the *
function like the & does in C?  I assume so, but I don't yet trust my assumptions
w.r.t. IDL.

Also, Pavel mentioned a stylistic preference w.r.t. spaces--is there a good web
resource for beginers that gives some tips on good IDL programming style?

Thanks!
RDH