RATS 10.1
RATS 10.1

Using REPORT

REPORT is a very useful tool for building up tabled output. There's a detailed section about it elsewhere. When you create a report inside a procedure, it’s a good idea to declare it as a LOCAL REPORT. This avoids conflicts with reports that the user might be generating. If you do that, you need USE options on all the REPORT instructions. For instance, this is (part of)  CVSTABTEST.SRC:

 

local report sreport

report(use=sreport,action=define,title=ltitle)

report(use=sreport,atrow=1,atcol=1,span) ltitle

report(use=sreport,atrow=2,atcol=1) "Fluctuation Statistic" sstat

 

Using OPEN(WINDOW)

The OPEN instruction with the option WINDOW creates a new text window into which you can direct output. With the CHANGE instruction, you can direct all subsequent output to this window, or, with UNIT options on instructions like DISPLAY and COPY, you can put selected information into it. For example:

 

open(window) tempout "Second Window"

change output tempout

display "This will go to the tempout window"

change output screen

display "This will go to the main output window"

display(unit=tempout) "This will also go to tempout"

 

The OPEN instruction creates a window whose unit name is tempout. The window title (which is what appears on the title bar and in the Window menu) is “Second Window.” The first CHANGE OUTPUT switches output to that window; the second switches it back to the standard output window (whose unit name is always SCREEN).

 

Graph Window Titles

By default, RATS simply labels new graph windows by number, for instance, “Graph.01” and “Graph.02”. The WINDOW options on SPGRAPH, GRAPH, SCATTER, GBOX and GCONTOUR allow you to assign your own titles to the graph windows. These titles appear on the title bar of the window, and in the Window menu.

 

For procedures which produce several graphs, assigning meaningful window titles to each graph can be very helpful to the user, particularly for selecting a graph from the Window menu.

 

graph(window="Kalman filter/smooth") 3

# lgnp

# hpsmooth

# hpfilter

 

If there is no WINDOW option, the graph instructions will use the HEADER or FOOTER option as the title if either is present, but you can also use WINDOW to give a title that is easier to pick out of the Window menu.

Spreadsheet Windows

Some instructions (PRINT and most of the forecasting instructions) include a WINDOW option, which allows you to direct their output to a spreadsheet style window, rather than a standard text window. This will give you a separate window on the screen for each of these operations. While these windows are “read-only,” the information in them can easily be transferred into spreadsheet programs or word processors by using File—Export... or using the Cut and Paste operations.

 

MEDIT

We look at MEDIT (matrix edit) in “Using QUERY and MEDIT” as an instruction for getting information into RATS. It is also handy for displaying information from RATS. If you want to display the contents of a matrix, use MEDIT with the options NOEDIT and NOMODAL. With the NOMODAL option, MEDIT simply displays the information and continues. To help the user find the desired information, MEDIT has a WINDOW option for labelling the window on the title bar and in the Window menu. From the MEDIT window, the user can export the data, or cut and paste it into another program.

 

MEDIT is most useful when you need to display a single array. REPORT is more flexible when the data are generated across several instructions.

 

Using INFOBOX

INFOBOX allows you to keep the user informed about the progress of a time-consuming operation. While it can be used to post a simple message, its main purpose is to display a progress bar (and a guess at the time to completion). Note, by the way, that INFOBOX behaves quite differently from MESSAGEBOX. An INFOBOX displays a window on the screen which requires no response from the user—it removes itself from the screen under the control of your program. A MESSAGEBOX, on the other hand, stops the execution of the program until the user answers the question it asks, or, in the case of an alert box, acknowledges having seen it by clicking OK.

 

The following displays a progress bar for an operation which takes NDRAWS draws.

 

infobox(action=define,progress,lower=1,upper=ndraws) $

   "Gibbs Sampler"

do draw=1,ndraws

   instructions which actually do things 

   infobox(current=draw)

end do draw

infobox(action=remove)


Copyright © 2025 Thomas A. Doan