David, your example doesn't work for nested compound variables, i.e.
'compound x=( a=1 b=2 c=3 compound d=( a=1 b=2 compund z=( y=3 )) )'.
I tried it myself and did not found a simple way to extract just the
names of the members of the top level and not any level below.

Olga

On Tue, Mar 22, 2011 at 7:17 PM, David Korn <[email protected]> wrote:
> cc: [email protected]
> Subject: Re: [ast-users] Enumerate member variable names in compound variable?
> --------
>
>
>> Developers, has any one found a way to enumerate the names of members
>> in a compound variable, e.g. if I have compound var=( a=2 b=5
>> c='hello' ) I like to have the list "a b c". How can I do that?
>>
>> Olga
> You could write a function like the following:
>>
>
> ===============cut here======================
> function members
> {
>        typeset nval
>        nameref var=$1
>        [[ ! -v var ]] && return 1
>        for nval in $(print -v var | grep  =)
>        do      print ${nval%%=*}
>        done
> }
>
> compound var=( a=2 b=5 c='hello' )
> members var
> ===============cut here======================
>
> David Korn
> [email protected]
>



-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     [email protected]   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to