문제

I have two procs: From MAIN I call another proc Glob. $Allforces is a list of lists.

proc ::MAIN {} {  
    # something
    ::Glob $AllForces
}

proc ::Glob {Input} {
    upvar $Input AllForces
    # do something
}

I get "No such variable" as an error for my attemt to upvar. So I tried:

upvar $InputMPCForces ::MAIN::AllForces

Then I get: "upvar won't create namespace variable that refers to procedure variable"

How can I access AllForces from MAIN in Glob by reference?

도움이 되었습니까?

해결책

You need to call your proc like this:

::Glob AllForces

that is, you pass the name of the variable, not its value.

Then, in the proc, the upvar command will take the variable whose name is the value of the local variable input and make it available locally as AllForces

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top