Mixing CSL and Non-CSL Statements
Within a single program you can mix both non-CSL statements (or macros) and CSL routines (callable services library routines). There are several reasons you might want to do this. The most common are:
- You have a program written prior to VM/SP Release 6 that is being used to operate only on files in file pools, and you want to enhance subroutines within the program to take advantage of SFS routines.
- You want to code a program that has two file I/O routines: one for files stored on minidisks, and another for SFS files stored in CMS file pools. Many of the CSL routines operate on minidisk files as well as SFS files. An application may use only CSL routines to operate on both types of files. There will be occasions though where your application can issue a function only for a minidisk (FORMAT) or to SFS (CREATE ALIAS). The program would use the DMSQFMOD routine (Query Filemode) or DMSVALDT (Validate File Name) to determine whether the file was on a minidisk or in a file pool.
- You want to create or update a file in another user's directory and you want to use CSL routines for direct file reference rather than access the directory as a file mode.
Once a file is opened using one method, you must continue to use that method to read, write, or close that image of the file. After the file is closed, you can re-open it using a different method.
You cannot, for example, open a file using FSOPEN, read it using a CSL DMSREAD routine, and then close it using FSCLOSE. Similarly, you cannot use CSL DMSOPEN and DMSCLOSE routines, and an FSWRITE macro to write to this image of the file. Mixing methods at that level will cause an execution error in your program.
- When using DMSOPEN:
- For an SFS file, you can open the file more than once for input (read) AND only once for output (new, write, or replace).
- For a minidisk file, you can open the file more than once for input (read) OR once for output (new, write, or replace).
- When using FSOPEN:
- For both a minidisk and SFS file, the file may only be opened once for either input or output.
Notice that CSL and non-CSL statements use the same default work unit ID. If you want the CSL routines to execute in a different work unit than the non-CSL statements, you will have to use the DMSGETWU routine (Get Workunitid).
It is possible to open an SFS file that is already open. It does not matter whether the file is opened using CSL or non-CSL statements. That is, you can open a file using the FS macros and then open the same file using CSL routines.
Note that CSL and non-CSL statements handle file space limits differently. You may write past your file space limits temporarily using CSL routines, but not via FS macros, EXECIO, 1 or OS Simulation WRITE/PUT macro operations. If you are writing past your file space limit and mixing interfaces, your updates may be rolled back.