Like other programming language TCL also support decision making using control structure like if -else , switch. As you might know that everything is command in TCL, including if-else and switch.
if statement validate expression and if expression is true then, block of statement written under if statement is executed. Here is syntax of if else:
One sample program based on above syntax:
Here if $number value is zero then expression will return true and as value of expression is true, statement written under if block will be executed.
Number is zero
Lets check how can we use if-else statement. Syntax of if-else statement:
Simple program based on if-else condition to check whether number is positive or negative.
Number is Positive