How can I store the result of user defined tcl command "get_failed" into a tcl variable?

In tcl, we can set the returned characters of a inlined command into a tcl variable as below.

Tcl> set x [pwd]
/home/user_leo/tmp
Tcl> puts $x
/home/user_leo/tmp

We implement a user defined command "get_failed" by Tcl C/C++ API, and this command will print result to screen as below:

Tcl> get_failed
a1 a3 a5 a7

We want we can store the prove result into a tcl variable. But we tried, it failed.

Tcl> set y [get_failed]
a1 a3 a5 a7
Tcl> puts $y

Nothing was stored in variable $y.

So how can I make it work? How can I store the result of user defined tcl command "get_failed" into a tcl variable? I hope it can work as below:

Tcl> set y [get_failed]
a1 a3 a5 a7
Tcl> puts $y
a1 a3 a5 a7

I hope this because I want to pass the result of "get_failed" to another user defined command, sample as below.

Tcl> check_by_method2 [get_failed]
checking a1...
done, pass.
checking a3...
done, fail.
checking a5...
done, pass
checking a7...
done, pass


Read more here: https://stackoverflow.com/questions/64951958/how-can-i-store-the-result-of-user-defined-tcl-command-get-failed-into-a-tcl-v

Content Attribution

This content was originally published by Leo at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: