값이 사전 목록에없는 경우에만 사전 목록에 값을 추가하려고합니다. 따라서, 나는 프로 시저에이를 분리하기 위해 노력하고있어, 나는 다음과 같은 코드가이를하지 않는 이유를 알아낼 수 없습니다 :사전 키가없는 경우에만 사전 키 값 추가
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
...
을
누군가 내가 여기서 잘못하고있는 것을 말해 줄 수 있습니까? 감사.
upvar 파일 앞에 $를 제거해보십시오 : DictAdd이 기준 $ 파일 이름을 파일. –