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

Home » Public Forums » archive » passing structure elements... by value?
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: passing structure elements... by value? [message #25809 is a reply to message #25725] Mon, 16 July 2001 02:45 Go to previous messageGo to previous message
Jaco van Gorkom is currently offline  Jaco van Gorkom
Messages: 97
Registered: November 2000
Member
Randall Skelton wrote:
> I have a simple routine that increments the value of a structure:
>
> pro test, mod_struct
> for i=0, n_tags(mod_struct)-1 do begin
> mod_struct.(i) = mod_struct.(i) + 1
> endfor
> end
>
> As expected, this will increment all of the values in a passed structure.
>
> IDL> struct = {A:0, B:0} & big = replicate(struct,3)
> IDL> print, big
> { 0 0}{ 0 0}{ 0 0}
> IDL> test, big
> IDL> print, big
> { 1 1}{ 1 1}{ 1 1}
>
> But, when I try and increment a single element in the structure it fails?
>
> IDL> struct = {A:0, B:0} & big = replicate(struct,3)
> IDL> test, big[0]
> IDL> print, big
> { 0 0}{ 0 0}{ 0 0}
> ^^^^^^^^^^^^^^^^^^
>
> I expected the ^^ element above to be ones? Is there any way to force IDL
> to pass this by reference instead of passing by value? It would be nice if
> you could put brackets around the thing you want to pass by reference...
> something like '(big[0])'

Note that in your example you are passing one *array* element of an array of
structures. Indexed array elements are also passed by value - see Liam's list.
One workaround would be to copy the array element(s) into a temporary variable:
working_elements = big[range]
test, working_elements
big[range] = working_elements
, with range being a vector of indices, just [0] in the example.
Another workaround involves passing the indices-of-interest into the routine.

cheers,
Jaco

----------------
Jaco van Gorkom gorkom@rijnh.nl
FOM-Instituut voor Plasmafysica `Rijnhuizen', The Netherlands
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Events in IDLDrawWidget
Next Topic: widget-programming

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

Current Time: Wed Oct 08 14:52:36 PDT 2025

Total time taken to generate the page: 0.00483 seconds