如何捕获计算表达式但仍然继续处理直到完成并低于脚本;
set vars {33 53 65t 43 word 55 d}
foreach varList $vars {
if {[expr {$varList / $varList}] == 1} { ;#I am stuck maths here if its not numerics string
set mathVar $varList
} else {
set mathVar "Invalid"
}
}
谢谢!
答案 0 :(得分:1)
foreach var $vars {
if {[string is integer -strict $var]} {
set mathvar $var
} else {
puts "not an integer: $var"
set mathvar 0 ;# or some default value
}
}