这个命令主要用于控制结构体里面,可以对控制结构进行进一步的控制。
命令的参考链接如下:
return命令的可选项非常丰富,这里只是对典型的应用进行举例说明。
从过程中返回:
% proc myProc {} {
puts "This is a example"
return
puts "This is not printed"
}
% myProc
This is a example
puts "This is a example"
return
puts "This is not printed"
}
% myProc
This is a example
这个例子直接返回,所以在过程体内return之后的命令不会再执行。
返回一个返回值,OK为返回值:
% proc myProc {} {
puts "This is a example"
return OK
}
% myProc
This is a example
OK
puts "This is a example"
return OK
}
% myProc
This is a example
OK
也可以返回一些异常代码:具体请参考return的命令参考。