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

Home » Public Forums » archive » Re: Structure Pass By Reference?
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: Structure Pass By Reference? [message #32880] Fri, 15 November 2002 16:28 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Nidhi Kalra (nrk5@cornell.edu) writes:

> I have a very deep structure that looks something like this:
>
> struct = $
> {vmap, $
> a: ptr_new(), $
> b: ptr_new()$
> }
>
> struct = $
> {rindex, $
> x: 0, $
> y: 0 $
> }
>
> where vmap.a is an array of structures of type RINDEX. vmap is an
> actual defined object and rindex is just a structure
>
> in a vmap method i need to access individual elements of a. i tried
> (for example):
>
> rindex1 = (*self.a)[2]
> rindex1.x = 2
>
> I would think that since (*self.a)[2] is a structure of type rindex,
> it would be passed by reference and therefore rindex1.x = 2 would mean
> (self.a)[2].x =2, but this is not the case. Can somebody help me out?

I guess I've been working with IDL for too long, because
I don't find this result surprising at all. You are returning
a subscripted array member. I would expect it to be returned
by value. That is consistent with IDL's rules for this kind of
thing.

If you want to put it back after you have changed it,
you just do this:

rindex1 = (*self.a)[2]
rindex1.x = 2
(*self.a)[2] = rindex1

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Previous Topic: Re: passing parameters from base to base
Next Topic: File_Which What!?

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

Current Time: Wed Oct 08 20:56:07 PDT 2025

Total time taken to generate the page: 1.28292 seconds