This is my first post. My question is when using the following
puts “What show command would you like to execute? Type ‘stop’ to close dialog.”
set cmd [gets stdin]
proc makeLC {str} {
puts “begin”
puts $str
set lStr [string tolower $str]
set lStr [string trim $lStr]
puts “after low and trim”
puts $lStr
puts “scan”
puts [scan $lStr %s]
set lenStr [string length $lStr]
for {set i 0} {$i < $lenStr} {incr i} {
puts [string index $lStr $i]
}
return $lStr
}
set lcmd [makeLC $cmd]
When a user types “test12345” then backspaces to display “test123” then adds “67” to finally display “test12367”
puts $lStr returns “test12367”
but the for loop will display “test12345 67” the spaces between “12345” and “67” I believe are “\b\b”.
Why the inconsistancy? and how do I ensure that when passing $lStr that “test12367” is assigned and “test12345 67” is not?