Expressions

  • Almost identical to C/C++
  • Evaluated through the expr command
  • In the if and while clause the expr is implicit
    Example:
    % set x .123
    % expr 2*sin($x)
  • Some operators (<, >, <=, >=, ==, != ) can be used with string in the if statement
    Example:
    % set s "hello"
    % if { "hello" == $s } { do_something }
  • If both the operands of a $==$ are numerical Tcl uses numeric comparison (see string operation for the string compare command).