The syntax of function or procedure in tcl is as
proc function_name { arguments } {
proc function_name { arguments } {
body
return
}
Example
proc add { a b } {
proc add { a b } {
return [expr $a + $b ]
}
set c [add 3 2 ]
out put 5
out put 5
Here we have declared a function or most appropriate a procedure named as add, with arguments as a,b. Later we set a variable c and we call the above function with two arguments. In return we obtain sum of these two arguments and that is assigned to c .
No comments:
Post a Comment