0

I am using ActiveState's TclDevKit debugger to look through my code but at one point in the execution of the program I get the following error:

can't read "UserArray": variable is array
    while executing
"set UserArray"
    ("uplevel" body line 1)
    invoked from within
"DbgNub_uplevelCmd DbgNub_uplevelCmd $args"
    invoked from within
"uplevel 1 [list set $name]"
    (procedure "DbgNub_TraceVar" line 53)
    invoked from within
"DbgNub_TraceVar 1 array UserArray time1_satOTRS1,2 w"
    (write trace on "UserArray(time1_satOTRS1,2)")
    invoked from within
"set UserArray($item,$window) $profile_array($item)"

This error utterly baffles me because as I understand Tcl/Tk, what I am doing is completely valid and legal. The code goes:

foreach item [array names profile_array] {
    set UserArray($item,$window) $profile_array($item)
}

In Tcl one is allowed to read from and write to an index in an array, I don't think there should be an error here... Am I missing some detail?

1 Answer 1

0

In your code, at the line:

uplevel 1 [list set $name]

I guess that in your case, $name == "UserArray". The above statement will be executed at the previous stack frame as:

set UserLevel

which does not make sense, as UserLevel is an array--that's what the error message is trying to tell you. I wonder if you really mean:

upvar 1 $name UserArray

in order to access the array from a proc.

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately, that code seems to be inside the TclDevKit debugger
The debugger has a bug? Nooooooooo! (Has it been reported yet?)
I don't think it's a bug, but the way the Debugger instruments files is rather annoying. When setting file paths with something like [file dirname [info script]] the code will actually return the pathname of the TclDebugger - not the location of the script! So I've had to move my entire working environment into the bin directory of the TclDevKit to get the debugger to work, hahahaha.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.