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

Home » Public Forums » archive » Re: structure information
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: structure information [message #26477 is a reply to message #26475] Thu, 06 September 2001 14:05 Go to previous messageGo to previous message
Todd Clements is currently offline  Todd Clements
Messages: 23
Registered: January 2001
Junior Member
> Who can write this so that the print-out has
> the *names* of the fields listed, too?
>
> Let's see, my usual prize when my kids do something
> like this is a "hug and a kiss". But I've met a few
> of you .... Maybe a handshake and the user group's
> undying admiration.
>
> Deadline is Monday, Sept 10th, so work productivity
> doesn't push the world economy into a real recession.
>

Here's my entry!

Todd

; --------------- Begin code -------------------
pro test
a = {struct1, x: fltarr(512), y: fltarr(512)}
b = {struct2, z: fltarr(512), q: {struct1}}
c = {struct3, a: {struct2}, b: {struct1}}
d = {struct4, w: {struct3}, y: 4}


result = s_info( d )
for i=0l, n_elements(result)-1 do print, result[i]
end

function s_info, struct, recurse
if( size(struct, /type ) ne 8 ) then return, ''

if( n_elements( recurse ) eq 0 ) then recurse = 0

help, struct, /structure, out=out

structLocations = strpos( out, '->' )

ntags = n_tags( struct )

if( recurse gt 0 ) then $
spaces = string(replicate(byte(' '),3*recurse)) else spaces=''

outString = spaces + out[0]

for i=1, ntags do begin
outString = [outString, spaces+out[i] ]
if( structLocations[i] ne -1 ) then begin
result = s_info(struct.(i-1), recurse+1)
if( result[0] ne '' ) then outString = [outString, result]
endif
endfor

return, outString
end ;; s_info
; ----------------- End code -----------------------

Result of running test:

** Structure STRUCT4, 2 tags, length=10244:
W STRUCT -> STRUCT3 Array[1]
** Structure STRUCT3, 2 tags, length=10240:
A STRUCT -> STRUCT2 Array[1]
** Structure STRUCT2, 2 tags, length=6144:
Z FLOAT Array[512]
Q STRUCT -> STRUCT1 Array[1]
** Structure STRUCT1, 2 tags, length=4096:
X FLOAT Array[512]
Y FLOAT Array[512]
B STRUCT -> STRUCT1 Array[1]
** Structure STRUCT1, 2 tags, length=4096:
X FLOAT Array[512]
Y FLOAT Array[512]
Y INT 4
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem combining structures
Next Topic: Re: call_method

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

Current Time: Sun Oct 12 17:08:05 PDT 2025

Total time taken to generate the page: 1.92471 seconds