30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Writing an Array Variable to a File<br />

Writing an Array Variable to a File<br />

It often occurs that you want to save the value of an array so that you can<br />

analyze its results at a later time. The following macro writes array values to<br />

a file:<br />

proc save_to_file {var fname} {<br />

set values [capture dprint $var]<br />

set f [open $fname w]<br />

}<br />

puts $f $values<br />

close $f<br />

The following example shows how you might use this macro. Using the exec<br />

command tells the shell’s cat command to display the file that was just<br />

written.<br />

d1. dprint list3<br />

list3 = {<br />

(1) = 1 (0x00000001)<br />

(2) = 2 (0x00000002)<br />

(3) = 3 (0x00000003)<br />

}<br />

d1. save_to_file list3 foo<br />

d1. exec cat foo<br />

list3 = {<br />

(1) = 1 (0x00000001)<br />

(2) = 2 (0x00000002)<br />

(3) = 3 (0x00000003)<br />

}<br />

d1.<br />

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

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

Saved successfully!

Ooh no, something went wrong!