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 #58148] Tue, 22 January 2008 06:45 Go to previous message
Hongkai is currently offline  Hongkai
Messages: 6
Registered: September 2006
Junior Member
Thanks, David and Maarten! Really nice solutions! While i was waiting
for your answers, I wrote a dirtier code to solve this problem using
the EXECUTE function :)

;Modify a single tag in a structure when we need to change the data
type or dimension of this tag
pro Structure_Modify, Structure, TagName, newValue

NAMES = TAG_NAMES(Structure)

cmdline = 'S1={'

for i_tag = 0,N_TAGS(Structure)-1,1 do begin

if strcmp( STRUPCASE(TagName), NAMES(i_tag) ) ne 1 then begin
cmdline = cmdline + NAMES(i_tag) + ': Structure.
('+strtrim(string(i_tag),2)+')'
endif else begin
cmdline = cmdline + NAMES(i_tag) + ': newValue'
endelse

if i_tag lt N_TAGS(Structure)-1 then begin
cmdline = cmdline + ', '
endif else begin
cmdline = cmdline + ' }'
endelse

endfor

result = EXECUTE(cmdline);

Structure = S1

end
[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: Fri Oct 10 18:27:26 PDT 2025

Total time taken to generate the page: 0.64210 seconds