1
您好我是新来的tcl我想插入元素列表中的proc从用户输入并返回列表并调用它在另一个列表 我已经尝试这个,我得到我如何插入项目列表中的tcl从用户输入
puts "Enter list Size"
set size [gets stdin]
set aList [fillTheList $size]
proc fillTheList {arg1 } {
set lList {}
for {set i 0} {$i <= $arg1} {incr i} {
set value [gets stdin]
linsert $lList $i int(value)]
puts "[lindex $lList $i]"
}
return $lList
}
,我在cmd中得到这个错误
invalid command name "fillTheList"
while executing
"fillTheList $size"
invoked from within
"set aList [fillTheList $size]"
(file "ascending.tcl" line 5)
你必须在你调用它之前定义proc **。只需将'set aList [fillTheList $ size]'移动到最后。 –
@glennjackman它的工作,但我得到这个错误 –
@glennjackman无法读取“ALIST”:没有这样的变量 在执行 “设置ALIST [fillTheList $大小]” (文件“ascending.tcl”第21行) –