Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 73dd199eb6e9b337fa3dce2ea957874e9f254995
Ticket: 217948ffffffffffffffffffffffffffffffffff
trace not working in global, and upvar cases
User & Date: nobody on 2000-10-26 00:46:29
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 3917 Bug
    Version: 8.2.1
    SubmitDate: '1999-12-21'
    LastModified: '2000-01-20'
    Severity: MED
    Status: Closed
    Submitter: techsupp
    ChangedBy: ericm
    RelatedBugIDs: 1433
    OS: Linux
    OSVersion: 2.0.37
    Machine: 166 AMD 128M ram 19 Gig HD.
    FixedDate: '2000-10-25'
    ClosedDate: '2000-01-20'
    
    
    Name:
    Kenn Persinger
    
    Comments:
    Tcl is the greatest scripting language i've found.. I program in perl at work since its the company standard, but when i go home to program for fun, tcl is what i use. you guys have done a wonderful job.
    
    ReproducibleScript:
    #this sets up the array
    
    ################################
    # Sets Up the Cursor Handling  #
    ################################
    proc InitPointerArray {} {
        uplevel #0 {
            array set Pointer "x {} y {}"
            trace variable Pointer rwu SetPointerXY
        }
    }
    
    # This one sets the values.
    # each time its called, it updates the values.
    proc SetPointerXY {args} {
        uplevel #0 {
            set Pointer(x) [winfo pointerx .] 
            set Pointer(y) [winfo pointery .]
        }
    }
    
    #This GetVar fails to execute the trace. ie: GetVar1 Pointer(x)
    proc GetVar1 {varname} {
        upvar #0 $varname myvar
        return $myvar
    }
    
    # This one also Fails. ie: GetVar2 Pointer(x)
    proc GetVar2 {varname} {
        global $varname
        return $varname
    }
    
    # This GetVar works perfect
    proc GetVar3 {varname} {
     return [uplevel #0 set $varname]
    }
    
    InitPointerAraay
    SetPointerXY ""
    
    puts "This one fails"
    GetVar1 Pointer(x)
    puts "This one also fails"
    GetVar2 Pointer(x)
    puts "This one is correct"
    GetVar3 Pointer(x)
    
    ObservedBehavior:
    I have an array w/ two values, the X and Y of the mouse pointer
    
     i've set a trace on them so that anytime they are read, the trace executes, and updates the value (nicely, before the read)
    
     i created a proc called GetVar <varname> and use it to allow a child interp to grab values from the parent. i've found, if i use upvar, and try to get one of those variables, the trace is never triggered.
     i've also tryed using 'global' rather than upvar, and IT doesn't work either. i finally fell back on: return [uplevel #0 set 
     $varname] which DOES trigger the trace, but is in my opinion, a bad way to do it.
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.2.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "07. Variables"
  10. title changed to: "trace not working in global, and upvar cases"
  11. type changed to: "Bug"