On Tue, 30 Apr 2002 15:15:18 -0600, Martin Weber wrote:

> On Wed, May 01, 2002 at 05:25:57AM +0900, Craig Files wrote:
>> Thanks,  I have been playing with this all day and have made some
>> discoveries, but I still need some help.
>> 
>> The $! gives the error found during the Tk call (for example, wrong #
>> args: should be "set varName ?newValue?") But, I also want to report
>> the current line number and stack trace of the tcl error.  (To be more
>> exact, I want the output to look exactly like the error output when
>> running tclsh.)
> 
> Don't output $! then, but access the tcl variable errorInfo. It contains
> the traceback, as well as its heading is the same message as the $!.
> Dunno, but there should be a way to access tcl variables via
> Tk.something(var) ?
> 
> -Martin

Thanks.  

Getting the errorInfo variable is a great idea, but I cannot find a  
a method Tk.something(var).  I have done a grep on the ruby source 
code (both 1.6 and 1.7) for GetVar and have found nothing.  

But adding the following to tcltklib.c does print out the stack trace
when an error occurs:
    if (ptr->return_value == TCL_ERROR) {
      char *v;
      v = Tcl_GetVar(ptr->ip, "errorInfo",0);
      printf("%s\n", v);
      rb_raise(rb_eRuntimeError, "%s", ptr->ip->result);
    }

.... proof of concept that this does work.  Any other ideas that do
not require a change to tcltklib.c?

I have also tried to use tk_call() in ruby to print errorInfo, but the 
following does not print out the data in errorInfo:
Tk.tk_call('set','errorInfo')

Any other ways to access errorInfo?

  Thanks
     Craig




-- 
___________________________________________________________________________
 Craig Files, PhD                           |                  / 
  http://coxcomb.ftc.agilent.com/~cfiles/   |       __o       / 
  craig_files / agilent.com                   |       \<,      / 
____________________________________________|_____()/ ()____/ (970)288-0183