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

Home » Public Forums » archive » Re: Is there any way to change the dimension of a field in a 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: Is there any way to change the dimension of a field in a structure? [message #58151 is a reply to message #58148] Tue, 22 January 2008 05:47 Go to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Jan 22, 6:11 am, Hongkai <wang.hong...@gmail.com> wrote:

> This is reasonable because IDL dose not allow to change the dimensions
> of the fields in the structure.
>
> I can solve this problem by redefining another structure S1 with the
> same tag names of S:
> S1 = {Dog:lindgen(3,118), Cat:'cc', Horse:[1,2,4]}
> S = S1
>
> However, the question is, if I only know the tag name of the field
> Dog, and I don't know the tag names of other fields in S, how can I
> change the dimension of Dog?
>
> I've tried this:
> aa = tag_names(S1)
> S = {aa(0):lindgen(3,118), aa(1):S.(1),a a(2):S.(2)}

Although David pointed to pointers as a solution, that does require
extensive changes to the rest of your code. The following dirty code
may be of help.

tnames = tag_names(S1)
tmp = create_struct(tnames[0], lindgen(3,118))
for ii=1,n_elements(tnames)-1 do tmp = create_struct(tmp, tnames[ii],
S.(ii))
S = tmp

Maarten
[Message index]
 
Read Message
Read Message
Previous Topic: color shift between 2 contour plots?
Next Topic: how to determine current position in a program??

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

Current Time: Wed Dec 03 07:23:33 PST 2025

Total time taken to generate the page: 1.60324 seconds