lesson 10 :proc 子函数的使用

1. proc sum {arg1 arg2} {
set x [expr $arg1+$arg2];
return $x
}

puts " The sum of 2 + 3 is: [sum 2 3]\n\n"

//[语法] :proc procName { var1 var2 ... } {
body
}
说明:
1. proc 命令有三个参数:procName 是定义的过程名字;{var1 var2 ...}是输入、输出
参数列表;body 是过程执行命令体。

 


2. proc for {a b c} {
puts "The for command has been replaced by a puts";
puts "The arguments were: $a\n$b\n$c\n"
}

for {set i 1} {$i < 10} {incr i}
//都是套路,自定义for函数,然后进行相应字符串赋值

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-11-28
  • 2021-12-03
  • 2021-11-29
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-26
相关资源
相似解决方案