Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - 日本語 - Русский

Please note that the recommended version of Scilab is 6.0.2. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Tcl/Tk Interface > TCL_EvalStr


Evaluate a string whithin the Tcl/Tk interpreter

Calling Sequence

TCL_EvalStr(str [,interp])
res = TCL_EvalStr(str [,interp])



string or matrix of strings, contains a Tcl/Tk script in each element.


optional character string parameter. Name of the slave Tcl interpreter in which the operation has to be performed. If not provided, it defaults to the main Tcl interpreter created by Scilab.


result of the evaluation, if it is successful. This is a character string matrix giving the evaluation result for each element of the input argument str


This routine allows to evaluate Tcl/Tk instructions with the Tcl/Tk interpreter launched with Scilab (when the interp parameter is not given), or in a slave interpreter.

When Tcl/Tk support is enabled in Scilab, you can evaluate Tcl/Tk expression from Scilab interpreter. In fact, Scilab launches a main Tcl/Tk interpreter. The Scilab instruction TCL_EvalStr can be used to evaluate expressions without having to write Tcl/Tk instructions in a separated file (this capability is provided by TCL_EvalFile).

More information about Tcl/Tk:


//with one call
TCL_EvalStr(["toplevel .foo1"
             "label .foo1.l -text ""TK married Scilab !!!"""
             "pack .foo1.l"
             "button .foo1.b -text close -command {destroy .foo1}"
             "pack .foo1.b"])

//step by step (debugging)
TCL_EvalStr("toplevel .foo2");

// creates a toplevel TK window. 
TCL_EvalStr("label .foo2.l -text ""TK married Scilab !!!""");

// create a static label
TCL_EvalStr("pack .foo2.l");

// pack the label widget. It appears on the screen.
text="button .foo2.b -text close -command {destroy .foo2}";
TCL_EvalStr("pack .foo2.b");

//kill the windows by program
TCL_EvalStr("destroy .foo1");
TCL_EvalStr("destroy .foo2");
//with one call, and in a slave interpreter
TCL_EvalStr('set test ""in Slave TCL Interp""','TCLSlave');


// return a result
res = TCL_EvalStr("expr 1+1")
res = TCL_EvalStr("tk_messageBox -message Hello -type okcancel")
res = TCL_EvalStr(["expr 4+5" "lsearch -all {a b c a b c} c" ; "list [list a b c] [list d e f] [list g h i]" "llength  {a b c d e}"])

See Also

  • ScilabEval — tcl instruction : Evaluate a string with scilab interpreter
  • TCL_EvalFile — Reads and evaluate a tcl/tk file
  • TCL_GetVar — Get a tcl/tk variable value
  • TCL_SetVar — Set a tcl/tk variable value
  • TCL_ExistVar — Return %T if a tcl variable exists
  • TCL_UnsetVar — Remove a tcl variable
  • TCL_UpVar — Make a link from a tcl source variable to a tcl destination variable


Author : Dennis Kruse posted the 11/12/2012 20:31
I can use readserial to read data from atmel microcontroller. The problem is with the timing. I'm sending data out at .5 s rate. I was able to initialize reading data [by looking for non-nul characater] but have trouble syncronizing reading data. I put a delay of ~.5 s in code but I sometimes miss data. Hyperterminal sees the "/r" character but scilab doesn't. There must be a simple way to receive data.
Reply to this comment
Please login to comment this page

Add a comment:
Please login to comment this page.

Report an issue
<< TCL_EvalFile Tcl/Tk Interface TCL_ExistArray >>

Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Fri Apr 11 14:07:05 CEST 2014