This section describes the methods Prism provides for printing and displaying data.
To print a variable or expression at the current program location, choose Print from the Debug menu. It is also by default in the tear-off region.
To display a variable or expression every time execution stops, starting at the current program location, choose Display from the Debug menu.
When you choose Print or Display, a dialog box appears; Figure 5-1 shows an example of the Print dialog box.
In the Expression box, enter the variable or expression whose value(s) you want printed. Text selected in the source window appears as the default; you can edit this text.
The dialog boxes also offer choices as to the window in which the values are to appear:
You can specify that the values are to be printed or displayed in a standard window dedicated to the specified expression. The first time you print or display the data, Prism creates this window. If you print data, and subsequently print it again, this standard window is updated. This is the default choice for both Print and Display.
You can create a separate snapshot window for printing or displaying values. This is useful if you want to compare values between windows.
You can print out the values in the command window.
Click on Print or Display to print the values of the specified expression at the current program location.
Click on Cancel or press the Esc key to close the window without printing or displaying.
To print and display from the source window:
Select the variable or expression by dragging over it with the mouse or double-clicking on it.
Right-click the mouse to display a pop-up menu.
Click on Print in this menu to display a snapshot visualizer containing the value(s) of the selected variable or expression at that point in the program's execution.
Click on Display to display a visualizer that is automatically updated whenever execution stops.
To print without bothering to display the menu, press the Shift key while selecting the variable or expression.
Prism prints the correct variable when you choose it in this way, even if the scope pointer sets a scope that contains another variable of the same name.
You can use the Events menu to define a print or display event that is to take place at a specified location in the program.
The Print dialog box (see Figure 5-2) prompts for the variable or expression whose value(s) are to be printed, the program location at which the printing is to take place, and the name of the window in which the value(s) are to be displayed.
Window names are dedicated, snapshot, and command; you can also make up your own name. The default is dedicated. See " Redirecting Output" for a discussion of these names.
When you have filled in the fields, click on OK; the event is added to the Event Table. When the location is reached in the program, the value(s) of the expression or variable are printed.
The Display dialog box is similar, but it does not prompt for a location; the display visualizer will update every time the program stops execution.
You can use the Event Table to define a print or display event that is to take place at a specified location in the program.
Click on Print or Display in the Common Events buttons to create an event that will print or display data.
If you click on Print, the Location and Action fields are highlighted. Put a program location in the Location field. Complete the print event in the Actions field, specifying the variable or expression, and the window in which it is to be printed. For example,
print d2 on dedicated
If you click on Display, the Location field displays stopped, and the Actions field displays print on dedicated. Complete the description of the print event, as described above. The variable or expression you specify is then displayed whenever the program stops execution.
Use the print command to print the value(s) of a variable or expression from the command window. Use the display command to display the value(s). The display command prints the value(s) of the variable or expression immediately, and creates a display event so that the values are updated automatically whenever the program stops.
The commands have this format:
[where (expression)] command variable[, variable ...]
The optional where (expression) syntax sets the context for printing the variable or expression; see below.
In the syntax, command is either print or display, and variable is the variable or expression to be displayed or printed.
Redirection of output to a window via the on window syntax works slightly differently for display and print from the way it works for other commands; see " Redirecting Output" for a discussion of redirection. Separate windows are created for each variable or expression that you print or display. Thus, the commands
display x on dedicated display y/4 on dedicated display [0:128:2]z on dedicated
create three windows, each of which is updated separately.
To print or display the contents of a register, precede the register's name with a dollar sign. For example,
print $pc
prints the program counter register. See " Displaying the Contents of Registers" for a list of register names supported by Prism.
You can precede the print or display command with a where statement that can make elements of a variable or array inactive. Inactive elements are not printed in the command window; " Overview of Data Visualization" describes how they are treated in visualizers. Making elements inactive is referred to as setting the context.
To set the context, follow the where keyword with an expression in parentheses. The expression must evaluate to true or false for every element of the variable or array being printed.
For example,
where (i .gt. 0) print i
prints (in the command window) only the values of i that are greater than 0.
You can use certain Fortran intrinsics in the where statement. For example,
where (a .eq. maxval(a)) print a
prints the element of a that has the largest value. (This is equivalent to the MAXLOC intrinsic function.) See " Writing Expressions in Prism" for more information on writing expressions in Prism.
Note that setting the context affects only the printing or displaying of the variable. It does not affect the actual context of the program as it executes.
You can specify the radix to be used in printing or displaying values by adding a suffix of the form /radix to the print or display command. radix can be b (binary), d (decimal), x (hexadecimal), or o (octal). For example,
print/b pvar1
prints the binary representation of pvar1 in the command window.
display/x pvar2 on dedicated
displays the hexadecimal values of pvar2 in a dedicated window.
The default radix is decimal, unless you have used the set $radix command to change it; see " Changing the Default Radix".