Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL: how to return an array ?

Status
Not open for further replies.
Feb 5, 2012
6
NL
hello All,

please find below a snippet of code that passes an array, manipulates the array, but i cannot return the new version of array.

here is the snippet :
Code:
 proc    get_mroute_active { &multicast }   {
        upvar   ${&multicast} MULTICAST ;

                set group   -1 ;
                set src -1 ;
                                set     mcast_group_source_id   -1 ;
                                set     MULTICAST($mcast_group_source_id,id) $mcast_group_source_id ;
                                set     MULTICAST($mcast_group_source_id,mcast_group) $group ;
                                set     MULTICAST($mcast_group_source_id,mcast_source) $src ;

        puts    [array size MULTICAST] ;
    parray  MULTICAST ;
}

array set     multicast { } ;

get_mroute_active [array get multicast] ;
puts    [array size multicast] ;
parray multicast ;

And the output of the code is :
Code:
3
MULTICAST(-1,id)           = -1
MULTICAST(-1,mcast_group)  = -1
MULTICAST(-1,mcast_source) = -1
0

Could you please help show me how the "MULTICAST" variable can be assigned to "multicast" ?
 
Hi,

I think you were close to the solution, I think what you need to do is:

replace
Code:
get_mroute_active [array get multicast]

with
Code:
get_mroute_active multicast

thacoda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top