私はこのスクリプトを使用しています。私はsession.mvwファイルの2行目を置き換えるようにしたいので、入力として「名前」を入力します。 session.mvwファイルは{GRAPHIC_FILE_1 = "E:/ge work/hyperview scripting/222.rst"}
となりますが、代わって {GRAPHIC_FILE_1 = "E:/ge work/hyperview scripting/${name}.rst"}
となります。中括弧で囲まれた変数二重引用符tcl
puts "Enter your name: "
#flush stdout set name [gets stdin]
set in [open session.mvw r]
# get the path to the parent directory
set hostDir [file dirname session.mvw]
set tempfile "$hostDir/temp2.txt"
# open/create a temp file
set out [open $tempfile w]
set count 0
while { [eof $in] != 1 } {
gets $in line
#set firstItem [lindex $line 0] incr count
# a match has been found...
if {$count == 2 } {
puts $out {GRAPHIC_FILE_1 = "E:/ge work/hyperview scripting/${name}.rst"}
} elseif {$count == 3} {
puts $out {GRAPHIC_FILE_1 = "E:/ge work/hyperview scripting/${name}.rst"}
} else {
puts $out $line
}
}
close $in
close $out
close $hostDir
# over-write the existing file
#file rename -force $tempfile session_file.mvw
変数置換は、内部ブレースを発生しません印刷し、どちらもこの
。それを 'puts $ out 'に変更してください。GRAPHIC_FILE_1 = \" E:/ ge work/hyperview scripting/$ {name} .rst \ "" ' – Dinesh
222.rst "}私の次のコマンドは、次のハイパービューソフトウェアがその行を認識できるように中括弧が必要であることに依存します –
それで、{GRAPHIC_FILE_1 =" E:/ ge work/hyperview scripting/222.rst "} 'これは222を入力として出力します –