這個命令主要用於控制結構體裏面,可以對控制結構進行進一步的控制。
命令的參考鏈接如下:
return命令的可選項非常豐富,這裏只是對典型的應用進行舉例說明。
從過程中返回:
% proc myProc {} {
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
也可以返回一些異常代碼:具體請參考return的命令參考。