21.1.11 Print Statement and Return Values

21.1.11.1 Print Statement

Use the puts command to write a string to an output channel. Predefined output channels are “stdout” and “stderr.” If you do not specify a channel, then puts display text to the stdout channel.

Note: The STDIN Tcl command is not supported by Microchip SoC tools.

For example:

set a [ myprog arg1 arg2 ]
puts "the answer from myprog was $a (this text is on stdout)" 
puts stdout “this text also is on stdout”

21.1.11.2 Return Values

The return code of a Tcl command is a string. You can use a return value as an argument to another function by enclosing the command with square brackets [ ]. For example:

set a [ prog arg1 arg2 ] exec $a

The Tcl command “exec” will run an external program. The return value of “exec” is the output (on stdout) from the program. For example:

set tmp [ exec myprog ] puts stdout $tmp