Tcl之Intro

时间:2024-03-28 13:37:50

  Tool command language, a widely used scripting tool that was deveoped for controlling and extending appliations.

1  Run

  When you have installed Tcl, the program you will then call to utilize it is tclsh.

  For instance, if you write some code to a file "hello.tcl", and you want to execute it, you would do it like so: tclsh hello.tcl

2  UNIX Tcl scripts (type "tclsh")

   1) putswrites the string to I/O steam

 puts "Hello, World - In quotes"    ; # This is a comment after the command.
puts {Hello, World - In Braces}
puts {Bad comment syntax example} # *Error* - there is no semicolon puts "line 1"; puts "line 2" puts "Hello, World; - With a semicolon inside the quotes" # Words don't need to be quoted unless they contain white space:
puts HelloWorld

   2) set - assign a value to a variable

  The dollar sign $ tells Tcl to use the value of the variable - in this case X or Y.

 set X "This is a string"

 set Y 1.24

 puts $X
puts $Y puts "..............................." set label "The value in Y is: "
puts "$label $Y"