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行) –