Well, first off,
don't use caps in topic... EVER!!!
Secondly, tcl is newline terminated, and "else" is not a separate command, but a parameter to "if"..
Code: Select all
#This will work:
if {...} {
...
} else {
...
}
#However, this will not
if {...} {
...
}
else {
...
}
Third, you really should not use list commands such as lindex and lrange on strings, either build proper list using the "list" command, or use "split" to convert a string to a list.
Also be aware that lindex will return the item stored at the specified offset in the list, while lrange will return a list with the subset selected. You'll most likely like to convert the output from lrange back to a string; "join" is the trick here.
Fourth, you'd really be better of using "string equal" for comparing strings, rather than using "blah == $blah". The latter can produce some unexpected results in rare conditions.
Also, if you use the code-tags rather than the quote-tags, the code is alittle easier to read...