| ||||||
Extracting list args passed to a procedure Posted by Nuts (Nuts), 9 October 2007 Hi,I am passing a list (containing strings) to procedure. Now, if i try to read the individual elements of the '"args" argument in the procedure I couldn't get the individual value of the strings passed. ## File1 : test.tcl ## To connect to the NE set cmdtype TL1 set ipaddr 192.168.200.1 set portaddr 10001 set params [list $cmdtype $ipaddr $portaddr ] connect $params ## File2 : connect.tcl proc connect {args} { if {[llength $args] < 1} { error "not enough args" } puts "Value of args : $args\n" set cmdtype [lindex $args 0] set ipaddr [lindex $args 1] set portaddr [lindex $args 2] puts "Value of cmdtype : $cmdtype" if {$cmdtype == "TL1"} { puts "Connecting TL1 interface..." ### Output ### [neetesh@neetesh-OME expect_sample]$ ./test.tcl Value of args : {TL1 192.168.200.1 10001} Inside connect procedure........ Value of cmdtype : TL1 192.168.200.1 10001 ------------------------------------------------------------------------------------------ Kindly help me in this. regards, Neetesh Posted by admin (Graham Ellis), 9 October 2007 You're only passing a single list across, so there's only one thing in that list in the proc. You need to look at the list within the list. Here's an example of what I mean:Code:
And that runs as follows Code:
For future note, if you can trim down you questions to fewer lines, it would be a huge help. Thanks! Posted by Nuts (Nuts), 10 October 2007 Thanks Graham !! It worked for me.regards, Nuts This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| ||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |