Reputation: 1482
Is it possible to get logs generated by one function in variable without returning that value from that function in TCL like what "$"
used to be do in BASH.
function f1 {
echo "ABC"
return 0
}
Calling procedure is,
var=$(f1) ;# gives output ABC
What i know about how to solve this problem is,
proc f1 {} {
return "ABC | 0"
}
At the time of calling i need extract both value like,
set console_msg [lindex [split [f1] "|"] 0]
set retval [lindex [split [f1] "|"] 1]
Is there a proper way to do it in TCL?
Thanks,
Upvotes: 0
Views: 225
Reputation: 246774
This may seem obvious to you in hindsight:
set value [f1]
and to assign to variables:
lassign [split $value |] msg val
Upvotes: 1