Re: redout of "name", "type" and "value" tags into a string [message #54092] |
Wed, 23 May 2007 08:33 |
BavarianMike86
Messages: 9 Registered: May 2007
|
Junior Member |
|
|
@ Vince:
"impractical" ... I think this word caused misunderstanding due to
language barrier ;-) I just wanted to say that this method is unhandy
for an IDL novice like me.
@ Lajos and David:
Thank you for your lead. This method works excellent.
By the way, David. We use your libraries here at office. Thanks for
your work. It makes many things much easier!
Greetings from Bavaria,
Michael
|
|
|
Re: redout of "name", "type" and "value" tags into a string [message #54113 is a reply to message #54092] |
Mon, 21 May 2007 11:23  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On May 21, 10:55 am, BavarianMike86 <jo.mich...@gmx.de> wrote:
> Thank you for your help, Ben and Vince!
>
> It is impractical if there's no easy way to read in the "Value" tags.
> But I discovered that also the HELP-function shows me all the
> information I need.
> Is it possible to copy the HELP-function generated text on the
> logscreen into a text array?
>
> This text array is necessary for me because I want to build a widget
> which shows exactly this information.
>
> Greetings,
> Michael
Impractical? That I don't understand...
I just threw this together in about 45 seconds. I think it only took
that long because it's Monday:
pro help_str, struct
tab = string(9b)
if size(struct,/type) ne 8 then return
tnames = tag_names(struct)
for i=0, n_tags(struct)-1 do begin
vnow = struct.(i)
printf, -1, tnames[i] + tab + size(vnow,/tname) + tab + strtrim(vnow,
2)
endfor
return
end
Cheers,
Vince
|
|
|
Re: redout of "name", "type" and "value" tags into a string [message #54114 is a reply to message #54113] |
Mon, 21 May 2007 09:16  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
BavarianMike86 writes:
> Is it possible to copy the HELP-function generated text on the
> logscreen into a text array?
>
> This text array is necessary for me because I want to build a widget
> which shows exactly this information.
Try the OUTPUT keyword to HELP.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: redout of "name", "type" and "value" tags into a string [message #54115 is a reply to message #54114] |
Mon, 21 May 2007 09:16  |
Foldy Lajos
Messages: 268 Registered: October 2001
|
Senior Member |
|
|
On Mon, 21 May 2007, BavarianMike86 wrote:
> Thank you for your help, Ben and Vince!
>
> It is impractical if there's no easy way to read in the "Value" tags.
> But I discovered that also the HELP-function shows me all the
> information I need.
> Is it possible to copy the HELP-function generated text on the
> logscreen into a text array?
>
> This text array is necessary for me because I want to build a widget
> which shows exactly this information.
>
> Greetings,
> Michael
>
>
HELP, OUTPUT=out, ...
regards,
lajos
|
|
|
Re: redout of "name", "type" and "value" tags into a string [message #54116 is a reply to message #54114] |
Mon, 21 May 2007 08:55  |
BavarianMike86
Messages: 9 Registered: May 2007
|
Junior Member |
|
|
Thank you for your help, Ben and Vince!
It is impractical if there's no easy way to read in the "Value" tags.
But I discovered that also the HELP-function shows me all the
information I need.
Is it possible to copy the HELP-function generated text on the
logscreen into a text array?
This text array is necessary for me because I want to build a widget
which shows exactly this information.
Greetings,
Michael
|
|
|
Re: redout of "name", "type" and "value" tags into a string [message #54118 is a reply to message #54116] |
Mon, 21 May 2007 07:07  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On May 21, 4:03 am, BavarianMike86 <jo.mich...@gmx.de> wrote:
> Hello!
> I hope you can help me:
>
> I have a structure. I can redout and print the structure tags using
> the TAG_NAMES function.
> But I also want to readout the "Type" and "Value" tags into a string
> array.
> How can I do that?
>
> Greetings from Bavaria,
> Michael
Here's a quickie:
Loop through the tags and use xxxx.tag_name[i] and use
size(xxxx.tag_name[i],/type).
|
|
|
Re: redout of "name", "type" and "value" tags into a string [message #54119 is a reply to message #54118] |
Mon, 21 May 2007 07:06  |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On May 21, 5:03 am, BavarianMike86 <jo.mich...@gmx.de> wrote:
> Hello!
> I hope you can help me:
>
> I have a structure. I can redout and print the structure tags using
> the TAG_NAMES function.
> But I also want to readout the "Type" and "Value" tags into a string
> array.
> How can I do that?
>
Hi,
Getting the type names isn't too hard. You could wrap the follwoing
into a function.
IDL> n = n_tags(!X)
IDL> s = STRARR(n)
IDL> for i =0,n-1 do s[i]=SIZE(!X.(i),/TNAME)
IDL> print, s
But getting the value is not straight forward as a structure field
could be quite complex, like a pointer, object or another structure.
Besides, that is really what the "." operator does for you, it returns
the value of the field. Like...
print, !X.range
Ben
|
|
|