FILE - I/O in FRED.

A file name in FRED is a standard TSS file descriptor with the exception that no alternate names or permissions are allowed. Every buffer in FRED may have a file name associated with it, to be used as a default when an I/O command is issued with no file name specified.

A successful W or R command without a specified line address will set the file name associated with the current buffer to the name of the file that was written or read. The associated file name will be the full name of the given file, regardless of how the name is specified in the read or write command. For example, if your current directory is rvanwinkle and you write a permanent file with

w /pmfile

the file name associated with the current buffer is set to

rvanwinkle/pmfile

not just /pmfile.

If a line address is given in the R or W command, the file name associated with the current buffer is not changed. Thus

w file
*w file

both write the contents of the current buffer, but only the first will change the buffer's associated file name.

The F command can also set a buffer's file name, as in

f filename

The given name need not be the full name of a file. If it isn't a full name, FRED will supply the full name the first time the file is read or written. From then on, the file name associated with the buffer will be the full name.

To get rid of the file name associated with a buffer, issued the F command followed by a space, followed by a new-line.

Any passwords specified with a file name are stripped away when the name is associated with a buffer. In other words, FRED does not remember passwords used in connection with a file. Thus if you are working with a file that requires a password, you must enter the password each time you read or write.

Writing with the W Command:

The general form of the W command is

w filename

The result of this depends on the form of the file name.

If the file name does not contain a / or a $ and the name is less than nine characters long:

If the file name used contains a / or a $, or if the name is nine characters or longer:

In summary then, a file name with a slash or password is taken to denote a catalogued file which is not in the AFT. If it starts out in the AFT, it is removed before the write procedure begins. If such a file does not exist, FRED attempts to create one if possible.

When a write command is issued for a file without a slash or password, FRED first looks for that file in the AFT and then in the current catalog. If the file is not found in either location, a temporary file is created. File names that contain nine characters or more are always treated as if they contain a slash.

All permanent files are removed from the AFT once the write has taken place; temporary files are not removed from the AFT after a write.

Note that a write is aborted when the file is in the AFT but cannot be written, or when an attempt to create a new file fails.

Reading with the R Command:

The general form of the R command is

r filename

The result of this depends on the form of the file name.

If the file name used has no / or $, FRED first looks for the file in the AFT and then in the user's catalog. If the file is not found, an error is issued.

If the file name has a / or $, it is removed from the AFT if present, then opened for reading. If the file cannot be opened for reading, an error is issued.

Permanent files are removed from the AFT once the read has been completed. Temporary files are not removed from the AFT after a read.

I/O Error Conditions:

An L, R, or W command with the incorrect command syntax will result in an error. For example, the error is issued if a file name is not separated from the L, R, or W by exactly one space.

If there is an error in the file access, an error is issued and the count register is set to a value indicating the reason for the error. This is the first status return word from the file access attempt. The Y command will analyze this status return word and explain why the attempted access failed.

An error message is issued if an I/O error occurs during a read or write operation. On a read, the error usually means the file has a bad format. On a write, the error usually means that the specified output file cannot be grown, or that one of the lines being written is too long. Again, the Y command is useful for determining the exact problem.

Copyright © 1998, Thinkage Ltd.