Re: Tcl bug?





Donald Arseneau wrote:
Ken Tilton <kentilton@xxxxxxxxx> writes:


Donald Arseneau wrote:

Ken Tilton <kentilton@xxxxxxxxx> writes:


proc TraceOP {n1 n2 op} {event generate $n1 <<tracewrite>> -data {$n1 $op}}

Don't use braces for -data! You are preventing $n1 $op from
being substituted in the context of TraceOP.

Really? I thought I saw that working. maybe not since the last upheaval.


No, it is not a recent change.

Sorry, i meant upheaval in my code. :)

Variables in braces are not substituted
(immediately). You pass the literal string `$n1 $op' as the event data,
but the event is handled in the global scope after TraceOP returns, at
which time those variables have vanished.

You don't show the event handler code, so one can't say how you get from
that error to the specific error message.

Did it work with "-data [list $n1 $op]"?


Tcl_Eval("set .f44.ent55")


Are you sure it did that? It probably did "set $n1"

No, I pass the tkwin pointer associated with a widget as the client-data when registering the handler, and keep a hash table of tkwin (and xwin!) pointers back to the Lisp instance. And I did get an error dialogue popping up saying ".f44.ent55" was no good. (I guess this is another advantage of having the Tcl interpreter running in the same process.)



I guess since the trace command had triggered the callback, a procedure was
running and so the scope was local. Game over. :)


No, event handlers run at global (outermost) level. But maybe your handler
goes into its own scope (as it should).


Well, hang on, I will try without specifying global on the tcl_getvar....ok, looks like you are right. I can specify global_only or namespace_only and get the value. Strangely, specifying neither returns nothing but does not return an error. Oh, well. :)

thx for clarifying the scoping thing.

kenny



--
Cells: http://common-lisp.net/project/cells/

"Have you ever been in a relationship?"
Attorney for Mary Winkler, confessed killer of her
minister husband, when asked if the couple had
marital problems.
.



Relevant Pages

  • Re: javascript custom object event handling and this
    ... > The method you are using to assign the event handler actually ... The value of instance's - HandleKeyDown - is a reference to a function ... to call an object instance method without ...
    (microsoft.public.scripting.jscript)
  • Re: javascript custom object event handling and this
    ... > The method you are using to assign the event handler actually ... The value of instance's - HandleKeyDown - is a reference to a function ... to call an object instance method without ...
    (microsoft.public.scripting.jscript)
  • RE: Are domain/machine names required when specifying roles
    ... from the expectations set by pretty much all the ... only one handler is used to ... >Authorization handler that will eliminate the need ... specifying roles ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: list of raised events
    ... > Hi Tim, ... > datagrid 's sortcommand handler statically or dynamically at runtime? ... > event handler will be lost when the page is posted back. ... I think Kevin's suggestion that check the form fields ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to pass more than two parameters in the event handler
    ... That information is passed into the event handler ... curveArray data without passing parameters in. ... private void plotCurves(ZedGraphControl zgc, int[,] curveArray) ...
    (microsoft.public.dotnet.languages.csharp)