[Q]Passing parts of structure arrays between routines [message #6871] |
Thu, 22 August 1996 00:00 |
Tim Patterson
Messages: 65 Registered: October 1995
|
Member |
|
|
I have an array of structures within my IDL code,
and I would like to select just one structure from
the array and pass it to another routine to have
its contents altered.
It arrives in the other routine ok, but when returned,
its contents have not changed. Instead, I have to copy
this structure into a temporary variable, pass that, and then
copy the results back into the array of structures.
The short routines below illustate this.
array_test will result in 1 2 3 printed (wrong)
array_test2 gives 7 8 9 (correct)
Is this use of temporary variables the only solution,
and why can't I get the 'correct' result using the
neater array_test procedure? I can't find anything under
'arrays' or 'structures' in the IDL docs that say I shouldn't
be able to do it that way.
Thanks
Tim
---------------------------------------------------------
Pro Array_Test
temp = {tempstruct, test:intarr(3)}
array = Replicate(temp, 5)
array(0).test=[1,2,3]
Change_It, array(0)
print,array(0)
Return
End
Pro Array_Test2
temp = {tempstruct, test:intarr(3)}
array = Replicate(temp, 5)
array(0).test=[1,2,3]
dummy = array(0)
Change_It, dummy
array(0)=dummy
print,array(0)
Return
End
Pro Change_It, input
input.test = [7,8,9]
Return
End
|
|
|