cc:  [email protected]
Subject: Re: Re: [ast-users] Enumerate member variable names in compound 
variable?
--------

> 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
> 

The following function should output only the top level.
=====================cut here===============================
function members
{
        typeset nval IFS=$'\n' blank=$' \t'
        nameref var=$1
        for nval in $(print -v var)
        do      case $nval in
                $'\t\t'*)       ;;      
                *=*)    nval=${nval%%=*}
                        print "${nval##*[$blank]}";;
                esac
        done
}
=====================cut here===============================

David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to