Name

if — Conditionally execute code.

Synopsis

if test code [ elseif | test | code ...] [ else | code ]

Description

The if command executes Hecl code conditionally. In its most basic form, it executes a test. If the results are not 0, then it executes code. If not, no further actions take place. if may take any number of elseif clauses, which have their own test and code. Finally, if none of the conditions has matched, it is also possible to supply an else clause that will be executed if the results of the if and elseif tests were all false.

Example

if { true } {
    puts "true"
} else {
    puts "false"
}
	  

Produces:

true
if { > 0 1 } {
    puts "true"
} else {
    puts "false"
}
	  

Produces:

false