R - Read file.

Syntax:

R filelist
RX filelist
Rs filelist
Rs-f filelist
Rs,c filelist

Examples:

$r bcdfile
rx /cat/myfile
r10 /cat/oldfile
r10,20 /newfile
r10-30 /newfile
r file1,file2,file3
r possible,

Options:

X
displays statistics about the read operation even if the R command is executed from a buffer. Usually, FRED only prints statistics if you enter the R command directly from the terminal. The format of the statistics is described below. The X option can be added to any form of the R command, as in
rx20-30 /file
s
is a positive integer. If this is specified, FRED starts reading the file at the given line number instead of the start of the file. For example,
r10 /file

reads in the contents of the file beginning at the file's line 10.

f
is a positive integer. If you say Rs-f file, FRED starts reading the file at line s and ends with line f. For example,
r10-20 /file

will read in lines 10 to 20 (inclusive) from the specified file.

c
is a positive integer. If you say Rs,c, FRED starts reading the file at line s and reads a total of c lines. For example,
r10,30 /file

reads a total of 30 lines, beginning at line 10 in the file.

filelist
is a list of zero or more file names, separated by "," characters.

Description:

R reads an ASCII or BCD file and puts it into the current buffer. If you specify an address, FRED appends the input after the given line. In this case, the file name associated with the current buffer does not change.

If you do not specify an address, the current buffer must be empty. If it is not empty, FRED will give you an error. Otherwise, FRED reads the material from the file into the buffer. If you have read in the entire contents of the file (i.e. you did not use options like Rs, Rs-f, or Rs,c) the name of the file will be associated with the buffer. This is the full name of the file, regardless of how you specified the name in the R command. For example, you can say

r /file

but the buffer name associated with the buffer will be

userid/file

(if your current directory is userid).

You do not have to specify a file name for R. In this case, the R command should be the last thing on the line, with no trailing spaces. R will read the file whose name is associated with the current buffer. For example, if you mess up the contents of a buffer and want to start over again,

*d r

deletes everything and reads in the associated file again.

If you specify several file names, as in

r file1,file2,file3

FRED tries to read the first file in the list. If the read operation fails because of a syntax error in the file name, or because the file or UMC was not present, FRED will try to read the second file name in the list. If this read operation also fails for one of the given reasons, FRED will try to read the next file in the list, and so on. In other words, FRED tries to read each file in the list until one of the read operations succeeds.

Note that FRED only tries new files in the list if a read operation fails because of a syntax error in a file name or because the file could not be found. If the read operation fails for any other reason, FRED stops trying and the entire R instruction fails.

When R successfully reads a file, FRED sets "." to the last line read and sets the count register to the number of blocks read. Statistics for the read operation are printed on the terminal, provided the read was not executed from a buffer. The statistics take the form

12,345,6789 b(name) user/cat/file

The first number gives the number of llinks read; the second is the number of lines; and the third is the number of characters. After this comes the name of the buffer and the full name of the file. The X option lets you display these statistics even when R is executed from a buffer.

When FRED executes R from a buffer, it does not issue an error message if the read operation is unsuccessful. Instead, FRED sets the condition register FALSE for an unsuccessful read and TRUE for a successful one. If you use R to read an empty file, the condition register is set TRUE even though nothing has been read.

If the R command has multiple filenames listed, the condition register will be set true if any of the read operations are successful. Buffer programs should usually check the condition register after an R command to make sure the read operation succeeded.

As a special case, you may specify a file list that ends with ",", as in

r file1,file2,

If all the read operations in the list fail because of syntax errors or because the given files cannot be found, FRED sets the condition register to TRUE even though none of the read operations succeeded. FRED also sets the count register to -1.

If a read operation fails for some other reason, FRED sets the count register to the negative of the value that would be assigned to errno under the same conditions in a C program.

Copyright © 1998, Thinkage Ltd.