OpenVMS DCL File Access
This sample code was the subject of “DCL File Access”, the February 6, 2011 installment of The OpenVMS Consultant, a column on OpenVMS computing hosted by OpenVMS.org.
Accessing files is a common programming task. Different languages have variations in the syntax and semantics. OpenVMS DCL is no different than any other language in this respect. Familiarity with the details of the mechanics of file management, together with how to effectively use its different features is crucial.
In OpenVMS DCL, file references can take two forms:
The three DCL command files comprising this example may be downloaded from this page. For your convenience, the files have been packaged in a ZIP archive.
The downloadable ZIP archive contains three example command files:
OPENVMS-DCLFILEACCESS-EXAMPLE1.COM | This procedure executes two procedures, using different mechanisms. The main procedure opens a file (which associates the RMS process permanent file with a process logical name), creates a logical name pointing to the logical name created by the DCL OPEN and then invokes two sub-procedures: an internal SUBROUTINE; and an external DCL procedure, OPENVMS-DCLFILEACCESS-EXAMPLE2.COM. |
OPENVMS-DCLFILEACCESS-EXAMPLE2.COM | This procedure is invoked by OPENVMS-DCL-FILEACCESS-EXAMPLE1.COM It demonstrates that a file opened from DCL may be indirectly accessed by a logical name pointing to the logical name assigned when the file was opened. |
OPENVMS-DCLFILEACCESS-EXAMPLE3.COM | This procedure executes two procedures, using different mechanisms. The main procedure opens a file (which associates the RMS process permanent file with a process logical name), creates a DCL symbol containing the name of the logical name (as opposed to its contents), and then uses the resulting symbol pass the name to a subroutine, which then writes to the file. Two sub-procedures are invoked: an internal SUBROUTINE; and an external DCL procedure, OPENVMS-DCLFILEACCESS-EXAMPLE3.COM. |
OPENVMS-DCLFILEACCESS-EXAMPLE4.COM | This procedure is invoked by OPENVMS-DCL-FILEACCESS-EXAMPLE3.COM It demonstrates that a file opened from DCL may be indirectly accessed by a logical name pointing to the logical name assigned when the file was opened. |