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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to return 2 values from a proc

Status
Not open for further replies.

mithunmo

Programmer
Mar 22, 2008
2
US
Hi All,

Please someone let me know how can I return more than one value from proc in tcl ?


Thanks and Regards,
Mithun
 
Your procedure can return simply a list of values.
Example pok.tcl:
Code:
proc cons_list {x y z} {
  # construct list of 3 elements
  return [list $x $y $z]
}

# running proc
set result [cons_list 1 "Hello" 3]
# result
puts "result = {$result}"
puts "1.part of result = [lindex $result 0]"
puts "2.part of result = [lindex $result 1]"
puts "3.part of result = [lindex $result end]"
Result:
Code:
D:\>tclsh85 pok.tcl
result = {1 Hello 3}
1.part of result = 1
2.part of result = Hello
3.part of result = 3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top