RATS I/O Units |
RATS I/O units are the source and destination files or devices for the various types of input and output. The default RATS I/O units are listed below.
You can also use your own unit names in an OPEN instruction, and then direct information to, or read information from, that unit using the UNIT option on instructions such as DATA and DISPLAY.
INPUT |
Source file (or device) of RATS instructions. By default, this will be KEYBOARD in interactive mode, and the input file in batch mode. |
OUTPUT |
Destination file or device for RATS output. By default, the screen, unless you specify an output file in batch mode. |
DATA |
Source for data you want to read into RATS. Default unit for the DATA and READ instructions. |
COPY |
Destination of data you write out from RATS. Default unit for the COPY instruction. |
PLOT |
Intermediate file for storing high-resolution graphs. |
ODBC |
Connection to an ODBC/SQL database (Professional level of RATS only) |
KEYBOARD |
The computer keyboard |
SCREEN |
The output screen or window. |
PRINTER |
The currently selected printer. |
The last three are "hardware" units so you can never OPEN them.
In most cases, the only instruction that you will use in altering a unit is OPEN. There's an OPEN DATA instruction in almost every example program. With a data file, you typically open it, read from it and you're done with it. There are, however, several instructions which can be used to give more control over the I/O.
CLOSE RATS I/O unit
I/O units are always closed when you exit RATS, and files which are used strictly for reading are opened "read-only" so they generally won't conflict with other programs. However, if you create a file using RATS (such as with COPY) and want to open it within RATS or within another program (like a spreadsheet) before exiting RATS, you need to CLOSE the unit first.
REWIND RATS I/O unit
This is rarely needed. Most data file formats are read completely with each DATA or READ instruction so even if you need to do more than one data instruction off a single data file, you don't have to rewind the unit between those. However, unformatted text files or binary files (read with FORMAT=FREE or FORMAT=BINARY) are read sequentially so you might find a need to rewind so it can be read from the beginning in case you want to pick up a different set of information.
CHANGE oldunit newunit
This is a fairly sophisticated instruction which will generally only be needed in very special cases where you want to control carefully the output (typically) produced by a program. The oldunit is almost always OUTPUT as you can switch the target for output generated by the program between several files or units. The following, for instance, routes a subset of the output to a separate window on the screen (called "Key Regressions"):
open(window) regwindow "Key Regressions"
change output regwindow
linreg ...
....
change output screen
Copyright © 2025 Thomas A. Doan