tcl Expressions Calling a Tcl command from an expression

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Sometimes you need to call a Tcl command from your expression. For example, supposing you need the length of a string in it. To do that, you just use a [...] sequence in the expression:

set halfTheStringLength [expr { [string length $theString] / 2 }]

You can call any Tcl command this way, but if you find yourself calling expr itself, stop! and think whether you really need that extra call. You can usually do just fine by putting the inner expression in parentheses.



Got any tcl Question?