Please enable JavaScript to view this site.

A-Shell Consolidated Reference

The benefits of read-only file access apply to all environments. The idea is that if you have no intention of updating a particular file, then there is no reason to pay all of the overhead that is associated with locking the file and coordinating your accesses with other users. The performance difference between reading records in a file opened for read-only access, and reading records from the same file opened for normal (read/write) access is relatively minor in a single-server Unix environment, but very substantial in networked environments such as NFS or Windows.

In the Windows case, the decision to use read-only mode vs. local copy mode would be based on the size of the file relative to the number of accesses to be made to it. Local copy mode is more efficient (because you cut the network entirely out of the picture) but it does involve the initial overhead of copying the entire file across the network to the workstation. So you aren't going to read most of the records in the file during a particular instance of a program, then it probably is more efficient to leave the file on the server and use read-only mode.

In the case of NFS under Unix, local copy is not an option, so read-only mode is the recommended approach for optimizing read access to a file.

Your mileage will vary, but it is not uncommon for read-only access over a network to be twenty times faster than reading from a file that has been opened for read/write access by more than one person. (When only one process has the file open, it doesn't seem to have much effect.)

Read-only access can be specified in one of two ways. One is to the "read'only" suffix to the open statement, for example:

Open #1, "MYFILE.DAT", RANDOM'FORCED, RECSIZ, RECNOVAR, READ'ONLY

The READ'ONLY suffix is requires that you use the /V:1 switch or any of the /X switches when compiling the program.

A second approach is to use xcall ASFLAG,1 prior to opening the file. Like the other ASFLAG uses described above, all OPEN statements after the xcall ASFAG,1 are affected. So you either need to rearrange your OPEN statements, or clear the read-only flag using xcall ASFAG,0.