GenStat makes use of various types of file. These are classified according to the information that they store. The files are accessed via channels. For each type there is a set of numbered channels that can be used to reference different files in the relevant directives. For example, there are five input channels, numbered 1 up to 5. Likewise, there are five output channels. GenStat distinguishes between the different types of channel, so you can have one file attached to output channel 3 and a different file simultaneously attached to backing store channel 3. Then, setting the option CHANNEL=3 in PRINT and STORE statements will send the different kinds of output to the appropriate files. With backing-store files, there are six channels, numbered 0 to 5, but channel 0 is reserved for the backing-store workfile. Similarly, there are six channels, numbered 0 to 5, for unformatted files. For procedure libraries there are three channels, numbered 1 to 3. For graphics files, each channel is used for output in a particular graphics format, corresponding to the number of the device selected by the DEVICE directive.
When you run GenStat it starts taking input from input channel 1 and produces output on output channel 1. In an interactive run, these will be keyboard and screen, while in a batch run they will be files on the computer. Another file that is attached automatically is the start-up file of instructions that are executed at the outset of each job; this is attached to input channel 5. The start-up file may attach other files. For example, if you are working interactively, the standard start-up file arranges for output channel 5 to store a transcript of your output. (This is done using the COPY directive.) The command that you use to run GenStat may allow you to arrange for other files to be attached when GenStat starts running. Alternatively, within GenStat, you can use the OPEN directive.
Usually you need specify only the name of the file, the channel number and type of file, and leave the other parameters to take their default settings. For example, the following statements attach a file called WEATHER.DAT to the second input channel, and then read data from it.
OPEN 'WEATHER.DAT'; CHANNEL=2; FILETYPE=input
READ [CHANNEL=2] Rain,Temperature,Sunshine
The filename can be anything that is acceptable to your computer system. You should, however, check for any constraints: for example, plotting software may require HPGL graphics files to have the extension .HPGL. You should check in your local documentation for information regarding any features that are specific to your computer or version of GenStat. For example, logical or symbolic names may be automatically translated by GenStat before files are accessed; upper and lower case characters may be significant, as on Unix systems. The filename may involve characters that have special meaning within GenStat. For example, the character \ may be required to specify directories and sub-directories on a PC. This character needs to be duplicated in a string to avoid GenStat interpreting it as the continuation symbol: for example
OPEN 'C:\\RES\\WEATHER.DAT'; CHANNEL=2; FILETYPE=input
to open the file 'C:\RES\WEATHER.DAT'. As a more convenient alternative, the PC version of GenStat allows you to use / instead.
You are free to choose which channels you want to use (within the range available for the specified type of file), apart from input and output channel 1 which are "reserved" for use by the files specified on the command line. As already mentioned, input channel 5 is used for the start-up file, and this may arrange for output channel 5 to store a transcript of your output. However, you can use the CLOSE directive to disconnect these files if you want to use the channels for some other purpose. The backing-store and unformatted work files are attached to channel 0, and this channel cannot be used in OPEN or CLOSE. Graphics files must be opened on the channel corresponding to the device number.
Obviously you cannot open more than one file on a channel, so if you wish to open a file on a channel that is currently in use you must first close that channel. Sometimes, in general programs or procedures, you may not know which channels are available. You can then let OPEN find a free channel: if CHANNEL is set to a scalar containing a missing value, the file is opened on the next available channel of the appropriate type, and the scalar is set to the number of the channel. The scalar need not be declared in advance; if CHANNEL is set to an undeclared structure, this will be defined as a scalar automatically.
OPEN 'WEATHER.DAT'; CHANNEL=FreeChan; FILETYPE=input
READ [CHANNEL=FreeChan] Rain,Temperature,Sunshine
Another constraint is that you cannot open the same file on more than one channel at once.
Input files must already exist when they are opened, whereas output files will be created by GenStat. If an output file with the specified name exists already, GenStat may create an extra "version" of the file, or report a fault, or cause the file to be overwritten, depending on the usual conventions on your type of computer. Your local documentation will describe what rules apply in this situation, and should also explain if there are any system variables you can set to control this action.
The STYLE parameter controls the style to be used to represent the information in an output file. The default is to use plain text, which assumes that all characters occupy an equal width. So, for example, columns are aligned by use of space characters and captions are highlighted by underlining them by rows of equal signs or minuses. However, you can also choose html (as used for example by web browsers), rtf (as used by word processors such as Microsoft Word) or LaTeX.
When you open a file for use by backing store or unformatted input and output, you can both read from it and send output to it, unless you set the ACCESS parameter (see below). Procedure libraries are a special type of backing-store file.
The WIDTH parameter sets the maximum number of characters per line for input and output files. It is ignored for other types of file. The default values for WIDTH are designed to be appropriate for each implementation of GenStat and may differ between input and output; details will be found in your local documentation. For input and output with screen displays that use windows WIDTH may be set automatically from the size of the appropriate window.
For input files the default is normally 80, reflecting the size of most screen displays. You can change this if necessary, to read either fewer characters from each line, or longer lines. If the WIDTH is set to be too small any extra characters will be lost, which may cause unexpected action or syntax errors. Remember that if you use READ with LAYOUT=fixed to read fixed-format data, short lines are extended with spaces up to the WIDTH setting. If you want to read data from a file with, say, 64 characters per line, setting WIDTH=64 when you open the file may make the format specification easier (rather than taking the default width of 80 and having to remember to skip 16 characters at the end of each line).
For output files, the default is the largest number of characters that can usually be displayed in a single line. This number is typically 80 for terminals but for files it is likely to be either 80, 120 or 132, depending on the type of computer. You can use the WIDTH parameter to restrict the number of output characters to a smaller number, or to a larger number up to 200.
The PAGE parameter specifies the size of page in output, affecting directives like GRAPH. For output to files, the default value of PAGE is designed to be suitable for printers. For windowed displays GenStat will, if possible, detect the size of the window and set the page size appropriately. You can also set option OUTPRINT=page in either JOB or SET to ensure that graphs and statistical analyses each start on a new page.
The INDENTATION parameter can be used to leave a specified number of blank characters to the left of each line of an output file, so that printed output can be bound for example. The indentation is subtracted from the WIDTH setting, so if you set WIDTH=80 and INDENTATION=10 then only 70 characters will be printed on each line of output.
The ACCESS parameter is used to control the way in which unformatted and backing-store files can be accessed, on computers that allow this.
Parameters: NAME, CHANNEL, FILETYPE, WIDTH, INDENTATION, PAGE, ACCESS, STYLE.
Directives: CLOSE, ENQUIRE, READ, PRINT, STORE, RETRIEVE, RECORD, RESUME.