Hi!

----

Where comes another problem with types, namerefs and arrays:
The following testcase reads a compound variable from stdin which
contains a list of variables of the type "foo_t":
-- snip --
function cat_content
{
        cat <<EOF
(
        foo_t -a foolist=(
                ( val=3 )
                ( val=4 )
                ( val=5 )
                ( val=6 )
                ( val=7 )
                ( val=8 )
                ( val=9 )
                ( val=10 )
                ( val=11 )
                ( val=12 )
        )
)
EOF
        return 0
}

typeset -T foo_t=(
        integer val=-1
        
        function precheck
        {
                (( _.val != -1 )) || print "error, val != -1"
                (( _.val >   2 )) || print "error, val > 0"
                return 0
        }
        
        function print
        {
                print -- ${_.val}
        }
)

function do_something
{
        typeset index
        nameref li=$1 # "li" may be an index or associative array

        for index in "${!...@]}" ; do
                li[${index}].precheck
                li[${index}].print
        done
}

cat_content | read -C x

do_something x.foolist
-- snip --

... in theory this program should print the numbers 3-12 but running it
with ast-ksh.2009-06-22 just prints:
-- snip --
3
3
3
3
3
3
3
3
3
3
-- snip --

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to