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

Home » Public Forums » archive » Re: Problem of precedence with pointer and structure
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: Problem of precedence with pointer and structure [message #47158 is a reply to message #47150] Fri, 27 January 2006 08:29 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
L. Testut writes:

>
> Here is my problem :
> ; If i define a is a 3 elements array of structure with two fields b
> and c
> ; each field is an array
> a=replicate({b:findgen(10),c:findgen(20)},3)
>
> ; and I want to replace the first field b with the constant value 0.5
> ; for the complete array structure, I write:
>
> IDL> a[*].(0)=0.5 ;or a[*].b=0.5 ; and it works
>
> ; Suppose i have now a 3 elements array of structure with two fields b
> and c
> ; each field is *pointer* to an array
>
> a=replicate({b:ptr_new(findgen(10)),c:ptr_new(findgen(20))}, 3)
>
> Is it possible to do the same replacement as above ???
>
> IDL> (*a[*].(0))=0.5 ;doesn't work
> % Expression must be a scalar in this context: <POINTER Array[3]>.
> % Execution halted at: $MAIN$ 1

Yes, I think that is a problem.

IDL> Help, a[*].b
<Expression> POINTER = Array[3]

IDL doesn't allow you to do mathematical operations on pointer arrays:

IDL> *(a[*].b) = *(a[*].b) + 3
Expression must be a scalar in this context: <POINTER Array[3]>.

I think a loop is the only way around this.

Cheers,

David

P.S. If I'm not mistaken, I think I recommended that structure
solution. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Problem of precedence with pointer and structure
Next Topic: Re: Extract a sub-structure from a structure

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

Current Time: Sat Oct 11 05:29:56 PDT 2025

Total time taken to generate the page: 1.43838 seconds