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

Home » Public Forums » archive » Re: pointer & structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: pointer & structure [message #69270] Tue, 12 January 2010 08:30
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jan 12, 2:05 pm, bing999 <thibaultga...@gmail.com> wrote:
> Actually, i replicated S first: S=replicate(S,N) but then, i need to
> iterate that process 10 times. And i used pointers ( k=0 => 10 ) for
> this because i do not know any other way to do it...

It is not very clear what is going on. Could you copy all the relevant
lines, including where you define S and p, and where you get the
problem?
Re: pointer & structure [message #69274 is a reply to message #69270] Tue, 12 January 2010 08:05 Go to previous message
Thibault Garel is currently offline  Thibault Garel
Messages: 55
Registered: October 2009
Member
On Jan 12, 4:50 pm, pp <pp.pente...@gmail.com> wrote:
> On Jan 12, 1:42 pm, bing999 <thibaultga...@gmail.com> wrote:
>
>
>
>> Hi,
>
>> i have created a structure S which contains a few elements (arrays)
>> a,b,c : S={a,b,c}
>> Then i replicate it N times.
>> Now i want to create iteratively 10 other structures with the same
>> skeleton.
>> Since, i did not see any other way to do, i used a pointer p to stock
>> the structures:
>
>> for k=0,10 do begin
>> *p(k) = S
>> endfor
>
>> By typing help,*p(k) i know *p(k) is indeed a structure BUT *p(k).a
>> (for instance) prints "Expression must be a structure in this context:
>> P"
>
>> So my question is: how can I extract the information stored in *p(k) ?
>
> The issue is the precedence of the operators. Use
>
> (*p[k]).a
>
> *p[k].a means *(p[k].a)

OK, thank you, that works !

>
> You do not need pointers for that array, you could have directly put
> that in a structure array with p=replicate(S,N), which makes an array
> with N copies of S. Then you can change the values of individual
> elements by their indexes.

Actually, i replicated S first: S=replicate(S,N) but then, i need to
iterate that process 10 times. And i used pointers ( k=0 => 10 ) for
this because i do not know any other way to do it...
Re: pointer & structure [message #69276 is a reply to message #69274] Tue, 12 January 2010 07:50 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jan 12, 1:42 pm, bing999 <thibaultga...@gmail.com> wrote:
> Hi,
>
> i have created a structure S which contains a few elements (arrays)
> a,b,c : S={a,b,c}
> Then i replicate it N times.
> Now i want to create iteratively 10 other structures with the same
> skeleton.
> Since, i did not see any other way to do, i used a pointer p to stock
> the structures:
>
> for k=0,10 do begin
> *p(k) = S
> endfor
>
> By typing help,*p(k) i know *p(k) is indeed a structure BUT *p(k).a
> (for instance) prints "Expression must be a structure in this context:
> P"
>
> So my question is: how can I extract the information stored in *p(k) ?

The issue is the precedence of the operators. Use

(*p[k]).a

*p[k].a means *(p[k].a)

You do not need pointers for that array, you could have directly put
that in a structure array with p=replicate(S,N), which makes an array
with N copies of S. Then you can change the values of individual
elements by their indexes.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Greek Symbols in Plot Annotations
Next Topic: Re: isurface with custom palette

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

Current Time: Wed Oct 08 19:28:35 PDT 2025

Total time taken to generate the page: 0.00492 seconds