tcl Expressions Multiplying a variable by 17


Example

set myVariable [expr { $myVariable * 17 }]

This shows how you can use a simple expression to update a variable. The expr command does not update the variable for you; you need to take its result and write it to the variable with set.

Note that newlines are not important in the little language understood by expr, and adding them can make longer expressions much easier to read.

set myVariable [expr {
    $myVariable * 17
}]

This does exactly the same thing though.