Modifying File Attributes

File attributes are entities that describe the properties of files. For example, file attributes specify the title of the file and the physical device type on which it resides (such as disk or tape). Programs can specify attributes for a file in the file declaration. Programs can also add to or change file attributes with file attribute assignment statements later in the program.

After you have written and compiled a program, you might later find that you would like the program to start using a different set of file attributes than were originally specified in the program. One method for doing this is to rewrite and recompile the program. This method can be time consuming for the programmer, and can make heavy use of system resources such as processor time and memory.

Alternatively, you can modify the file attributes used by a program through constructs called file equations. For example, suppose a program uses a file called IN and another file called OUT. In a CANDE RUN command, you could use file equations to specify different titles for these files in the RUN statement that initiates the program. The following is an example:

RUN REPORT1;FILE IN = (HKANE)INDATA, OUT = (HKANE)OUTDATA

File equations thus enable you to modify the file attributes used by a program without having to rewrite or recompile the program. However, in order to use a file equation you first have to know the internal name of the file. The internal name of the file is determined by the value of the INTNAME file attribute. If the program does not specify a value for INTNAME, then INTNAME defaults to the value of the file identifier used for the file in the program. You can determine the internal name of a file by looking at the file declaration in the program source file. Thus, either of the following ALGOL declarations creates a file with an internal name of SOURCE:

FILE CUSTDATA(INTNAME = “SOURCE.”);
FILE SOURCE;

The syntax for file equations in CANDE, MARC, and WFL is almost identical. For example, to change the device kind of the file with the internal name of SOURCE, you can append the following to a RUN statement submitted through any of these sources:

FILE SOURCE(KIND = REMOTE);

The flexibility provided by file equations can be so convenient that programmers sometimes design a program with the intention that the user will use file equations. For example, in the documentation for various compilers and utilities, you can find descriptions of the internal names of files used by these compilers and utilities. These internal names are documented so that you can use them in file equations.

Note that the same file attribute can be assigned different values by file declarations, file attribute assignment statements, and file equations. In these cases, the values assigned through file equations override those specified in the file declaration. File equations are in turn overridden by any conflicting file attribute assignment statements executed by the program. A programmer can prevent file equations from having effect simply by specifying file attributes through file attribute assignment statements rather than through attribute assignments in the file declaration.

When you specify file equations for a process, the system stores the equations in the FILECARDS task attribute of the process.

One of the file attributes that it is frequently useful to change at run time is the FAMILYNAME file attribute. You can save yourself the trouble of including FAMILYNAME equations for each disk file in the program by using the FAMILY task attribute instead. Refer to Specifying Family Substitution later in this section. Also, you can establish default values for the file attributes related to printing by using the PRINTDEFAULTS task attribute, as described under Programmatic Control over Printing later in this section.

You might find occasionally that you initiated a process and forgot to specify the correct file equations. The system suspends the process if both the following conditions are true:

  • The process attempts an open operation with the WAIT option specified or with no specific open option.

  • The process is unable to open the specified file because of a missing or incorrect file attribute value.

You cannot use file equations to remedy this problem, because file equations must be specified at process initiation. Instead, you can use the FA system command to supply the needed file attribute values. For example, suppose a process is suspended because it tried to open a file SOURCE with KIND = TAPE, and the file is a disk file. The Y system command output looks like this:

STATUS OF TASK 38057\23046 at 07:28:51
Program name: *SYSTEM/DUMPALL ON DISK
 Codefile created: Monday, July 2, 2001 (2001183) at 11:07:28
Priority: 50
Origination: SB154/CANDE/3 (LSN 320)
MCS: SYSTEM/CANDE
Usercode: JASMITH
Stack State: Waiting on an event, Assigning a file
RSVP: NO FILE SOURCE (MT) #1
Reply: NF, FA, UL, IL, OK, DS

Note that the name SOURCE, which appears on the RSVP line, is the file title rather than the internal name. However, it does not matter if you do not know the internal name in this case. When you specify file attribute assignments in an FA command, the system automatically applies the assignments to the file the process is trying to open. The following FA command enables the process to open the file and resume running normally:

5692 FA KIND = DISK

For detailed descriptions of all the file attributes available on the system, refer to the File Attributes Programming Reference Manual.