Re: errorInfo from scotty scripts under tkined (1.0.2)

Juergen Schoenwaelder (schoenw@data)
Thu, 17 Nov 94 10:57:24 +0100

Hi!

On Wed, 16 Nov 1994 15:06:14 +0000 (GMT),
Peter J M Polkinghorne <Peter.Polkinghorne@gec-hrc.co.uk> said:

Peter> Hello, excuse this rather naive question, but in developing
Peter> scotty scripts to run under tkined (version 1.0.2), I quite
Peter> frequently make mistakes! The single line error message that
Peter> appears on the stderr of the terminal that ran tkined is often
Peter> not sufficient to easilly pin down the source of error. What
Peter> I should like to do, is to display errorInfo for the stack
Peter> trace. However I can not see how to do this -- HELP.

There are two places were errors are handled in scotty: The first one
handles errors of commands started from the event loop. In thsi case,
the proc scottyerror is called or the error is ignored. This allows to
setup you own error handling code. I often use something very simple:

proc scottyerror { msg } {
global errorInfo
puts stderr "$errorInfo"
}

The error message you are talking about is written to stderr whenever
a scotty command is invoked on behalf of tkined. I think calling
scottyerror would be what you want. Below is a diff to ined.c that
implements this. Note however, that calling ined commands from the
scottyerror proc can result in deadlocks.

*** scotty-1.1.1/ined.c Tue Oct 25 17:36:33 1994
--- scotty-1.1.2/ined.c Thu Nov 17 09:17:51 1994
***************
*** 260,267 ****
while ((p = queue) != NULL) {
queue = queue->next;

! if (Tcl_Eval (interp, p->msg) != TCL_OK) {
! fprintf (stderr, "%s\n", interp->result);
}

free (p->msg);
--- 260,272 ----
while ((p = queue) != NULL) {
queue = queue->next;

! if (Tcl_GlobalEval (interp, p->msg) != TCL_OK) {
! Tcl_DString ds;
! Tcl_DStringInit (&ds);
! Tcl_DStringAppendElement (&ds, "scottyerror");
! Tcl_DStringAppendElement (&ds, interp->result);
! Tcl_GlobalEval (interp, Tcl_DStringValue (&ds));
! Tcl_DStringFree (&ds);
}

free (p->msg);

Peter> Supplementary question: I notice in some of the tkined scripts
Peter> a -noupdate option. What does this do?

The default behavior of the ined commands is to update the display
immediately. The -noupdate option allows tkined to delay display
updates. This is useful in cases where you are creating a new object,
moving it to the appropriate place, setting its color etc. Without the
-noupdate option, you will see each of this steps on the display.

Juergen