1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ~/tcltk$ tclsh % set c1 {Bob Carol} Bob Carol % set c2 [list Ted Alice] Ted Alice % set Party1 [list $c1 $c2] {Bob Carol} {Ted Alice} % set Party2 [concat $c1 $c2] Bob Carol Ted Alice % linsert $Party1 1 Richard {Bob Carol} Richard {Ted Alice} % |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ~/tcltk$ tclsh % set People(friend) Tom Tom % set People(spouse) Marcia Marcia % set People(boss) Jack Jack % array names People friend boss spouse % set Person $People(friend) Tom % array get People friend Tom boss Jack spouse Marcia % set People(friend) \ [concat $People(friend) Bob] Tom Bob % set Person $People(friend) Tom Bob % |
1 2 3 4 5 | set i 1 ; set j 10 set array($i,$j) 3.14159 incr $j set array($i,$j) 2.71828 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/usr/bin/tclsh # # Demonstrate procedures and # global scoping briefly set PI [expr 2 * asin(1.0)] proc circum {rad} { global PI return [expr 2.0 * $rad * $PI] } proc c_area {rad} { global PI return [expr $rad * $rad * $PI] } set rad 3 puts stdout "Area of circle of\ radius $rad is [c_area $rad],\n\ the circumference is\ [circum $rad].\n" ********* ~/tcltk$ ./protest.tcl Area of circle of radius 3 is 28.2743338823, the circumference is 18.8495559215. |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |