I โinheritedโ some Tcl code, and although I worked with some textbooks and could understand the meaning of the language, there is no specific ... finesse in my own Tcl constructs.
For example, I have this code:
puts "Column 'name': [ $queryRs getString name ]"
$queryRs
is a collection of SQL query results. The [ $queryRs getString name ]
construct retrieves the contents of the column for the name table from the current row in the result set. If the database field is NULL, puts
does not print anything.
I would like to print the string "default", i.e. if [ $queryRs getString name ]
gives nothing, I would like to replace it with "--"
.
Now I could do something like this:
set nameVar "[ $queryRs getString name ]" if { [ string length $nameVar ] == 0 } { set nameVar "--" } puts "Column 'name': $nameVar"
But it has a more compact solution, which can be done inline instead of adding four lines and a temporary variable. Help me please?
source share