TCL Gotchas

TCL Gotchas

This page documents idiosyncrasies of the TCL language that you may run into while developing iApps.

Balanced braces, etc

All braces (and likely brackets and parenthesis) must be balanced in TCL, even when commented out. See Why can I not place unmatched braces in Tcl comments article in the Tclers wiki.
For instance, say you want to try a slightly different bit of logic in an if statement. If you comment out the line, but do not balance the curly brace, the TCL parser will throw back an error.
The following code does not work:
#if { foo <= bar } {
if { foo < bar } {
    puts "Foo is less than bar"
} else {
    puts "Foo is more than bar"
}

However, the following code does work:
#if { foo <= bar } {}
if { foo < bar } {
    puts "Foo is less than bar"
} else {
    puts "Foo is more than bar"
}

The difference is the extra } placed at the end of the comment
—-

The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.