辞書リストに値を追加したいことがよくありますが、その値がすでにリストにない場合にのみ表示されます。したがって、私は、手続きにこれを分離しようとしている、と私は、次のコードは、これを達成しない理由を把握することはできません。まだ存在していない場合にのみ、辞書キーに値を追加してください。
proc DictAdd {_dictionary key value} {
upvar 1 $_dictionary dictionary
if { $value ni [dict get $dictionary $key] } {
dict lappend dictionary $key $value
}
}
このプロシージャを呼び出すと、次のエラーが返されます。
can't read "dictionary": no such variable
while executing
"dict get $dictionary $key"
(procedure "DictAdd" line 5)
invoked from within
"DictAdd $files baseline $fileName"
(procedure "getFilesToLoad" line 53)
invoked from within
...
を
誰かが私がここで間違っていることを教えてもらえますか?ありがとう。
は、ファイルの前に$を削除してください:DictAddファイルベースライン$ファイル名。 –