1. # Standard simple if

  2. if {some condition} {

  3.     # Note that the open-brace for the body is on the same line

  4.     # as the if-command and condition.


  5.     some conditionally executed script...

  6. }


  7. # Standard simple if with else clause

  8. if {some condition} {

  9.     some conditionally executed script.

  10. } else {

  11.     some script to execute if the condition is not satisfied.

  12. }


  13. # Standard multi-test if

  14. if {first condition} {

  15.     thing to do if the first condition succeeds

  16. } elseif {second condition} {

  17.     thing to do if the first fails, but the second condition succeeds

  18. } else {

  19.     what to do if none of the conditions match - this one is optional,

  20.     but typically good practice to anticipate unexpected responses

  21. }


  22. # Handling complex (i.e. long) conditions

  23. if {

  24.     this condition stretches over

  25.     multiple lines

  26. } then {

  27.     thing to do if the condition succeeds

  28. }