30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

About CLI Output<br />

About CLI Output<br />

A CLI command can either print its output to a window or return the output<br />

as a character string. If the CLI executes a command that returns a string<br />

value, it also prints the returned string. Most of the time, you won’t care<br />

about the difference between printing and returning-and-printing. Either way,<br />

the CLI displays information in your window. And, in both cases, printed<br />

output is fed through a simple more processor. (This is discussed in more<br />

detail in the next section.)<br />

In the following two cases, it matters whether the CLI directly prints output<br />

or returns and then prints it:<br />

� When the Tcl interpreter executes a list of commands, the CLI only prints<br />

the information returned from the last command. It doesn’t show information<br />

returned by other commands.<br />

� You can only assign the output of a command to a variable if the CLI returns<br />

a command’s output. You can’t assign output that the interpreter<br />

prints directly to a variable, or otherwise manipulate it, unless you save it<br />

using the capture command.<br />

For example, the dload command returns the ID of the process object that<br />

was just created. The ID is normally printed—unless, of course, the dload<br />

command appears in the middle of a list of commands; for example:<br />

{dload test_program;dstatus}<br />

In this example, the CLI doesn’t display the ID of the loaded program, since<br />

the dload command was not the last command.<br />

When information is returned, you can assign it to a variable. For example,<br />

the next command assigns the ID of a newly created process to a variable:<br />

set pid [dload test_program]<br />

Because you can’t assign the output of the help command to a variable,<br />

the following doesn’t work:<br />

set htext [help]<br />

This statement assigns an empty string to htext because the help command<br />

doesn’t return text. It just prints it.<br />

To save the output of a command that prints its output, use the capture<br />

command. For example, the following example writes the help command’s<br />

output into a variable:<br />

set htext [capture help]<br />

You can only capture the output from commands. You can’t capture the informational<br />

messages displayed by the CLI that describe process state. If you are using the GUI,<br />

<strong>TotalView</strong> also writes this information to the Log Window. You can display this information<br />

by using the Tools > Event Log command.<br />

<strong>TotalView</strong> <strong>Users</strong> <strong>Guide</strong>: version 8.7 205

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!