If statement “后面加上单词”;否则";“中的条款;如果;TCL代码的命令
我有一个tcl代码-If statement “后面加上单词”;否则";“中的条款;如果;TCL代码的命令,if-statement,tcl,If Statement,Tcl,我有一个tcl代码- if { $xyz == 43 } { # 1. Set some variables set my_filename_log "somename_log.txt" if {[file exists $my_filename_log ]} { file delete -force $my_filename_log } } # end of xyz = 43 编译时,我得到的错误
if { $xyz == 43 } {
# 1. Set some variables
set my_filename_log "somename_log.txt"
if {[file exists $my_filename_log ]} {
file delete -force $my_filename_log
}
} # end of xyz = 43
编译时,我得到的错误是-TCLERROR:error#args:if命令中“else”子句后面的额外单词-
如果{$xyz==43}{
#1.设置一些变量。。。
不确定此代码有什么问题,检查了tcl文档,在
tcl
中未找到任何内容,否则如果条件应以elseif
的形式写入,且不留空格。否则您将得到您提到的错误
if {$xyz==1} {
puts "Yes"
} else if {$xyz==2} {
puts "No"
}
wrong # args: extra words after "else" clause in "if" command
在代码中,您使用了
} # end of xyz = 43
在最后一行。您必须使用
标记语句的结尾,然后可以使用
开始注释
所以,你的代码应该写成
if { $xyz == 43 } {
# 1. Set some variables
set my_filename_log "somename_log.txt"
if {[file exists $my_filename_log ]} {
file delete -force $my_filename_log
}
}; # end of xyz = 43
谢谢,我知道
elseif
,但在开始评论之前不知道如何使用;
。