Execute code after every tcl command? 
Author Message
 Execute code after every tcl command?

Is there a way to automatically execute some code after every tcl
command is executed?  For instance, if I did an eval { ... }, I would
like some bit of c code to be called after every command in the eval.
Presently, I have all the commands I add return a function instead of
TCL_OK, and that function does something then returns TCL_OK.
Unfortunately, this only works if the user happens to be executing
code I write.

I don't necessarily need the code to be executed after every line, but
I do need it to be called fairly often.

-Kevin



Sun, 17 Mar 1996 04:42:10 GMT  
 Execute code after every tcl command?

   Is there a way to automatically execute some code after every tcl
   command is executed?  For instance, if I did an eval { ... }, I would
   like some bit of c code to be called after every command in the eval.
   Presently, I have all the commands I add return a function instead of
   TCL_OK, and that function does something then returns TCL_OK.
   Unfortunately, this only works if the user happens to be executing
   code I write.

   I don't necessarily need the code to be executed after every line, but
   I do need it to be called fairly often.

I should think that if you created a second interpreter, stripped out
  *every* command from it, and mutzed with its 'unknown' command to run a
  command in the orig interpreter (with whatever you want to do on each
  cmd), then resend the actual cmd in the stripped interp...
  (of course, you have to figure a way to avoid having this mechanism
  triggered again).

It's probably just as easy to hack into the tcl core and add this by hand.
  (1 line of code?)

--
Thanks again,

                                  "Life___  is complicated."



Sun, 17 Mar 1996 07:05:00 GMT  
 Execute code after every tcl command?

|> Is there a way to automatically execute some code after every tcl
|> command is executed?

I think what you want is the Tcl_CreateTrace command.  It arranges for a C
procedure to be called before Tcl calls command procedures to process
commands.  See the "CrtTrace" manpage in the tcl documentation.

-------

University of California, Berkeley      uucp: uunet!ucbvax!postgres!bsmith
Computer Sciences Department            phone: (510)642-9585



Sun, 17 Mar 1996 07:54:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. execute code every set time

2. Executing tcl commands from outside the tcl shell

3. here is code to execute periodic commands

4. How to execute TCL command stored in a variable

5. Problem executing shell command through tcl

6. Problem executing shell command through tcl.

7. executing tcl commands in different time intervals.

8. Executing Tcl commands from a Windows app

9. Execute shell commands via TCL script and display the results

10. executing command line programs using tcl in win98

11. executing script command inside tcl.

12. problem when executing unix commands in tcl

 

 
Powered by phpBB® Forum Software