Tcl Conditional and Logical operators code example

Example: Tcl Conditional and Logical operators

# Conditional/Logical Operators in Tool Command Language (Tcl)
# ============================================================
# Equal to: "=="
set x 101;
if {$x == 101} {
	puts "x = 101";
}
# Not Equal to: "!="
if {$x != 100} {
	puts "x is NOT equal to 100";
}
# Conditional OR: "||"
if {$x == 101 || $x == 22} {
	puts "Either x = 101 OR 22";
}
# Conditional AND: "&&"
if {$x == 101 && [expr $x - 1] == 100} {
	puts "x=101 AND x-1 = 100";
}

Tags:

Cpp Example