The FILEDEF Command. --- ------- -------- The FILEDEF command allows you to specify filename information for use by FORTRAN programs at the MCR level. This means that it allows you to write programs that do not require OPEN statements or code to prompt you for the name of files to be used by the program. The FILEDEF command (which may be abbreviated to FIL) is used to specify input or output file specifications before you run your program. It may also be used to delete one or all of your assignments, or to provide a list of them. Once specified, the information remains in effect for the duration of the terminal session or batch job, unless you explicitly change it. 1.0 Specifying Assignments. ---------- ------------ The general form of this mode of the FILEDEF command is: FILEDEF unit filespec where 1. "unit" is the logical unit number that will be used to read from or write to the file. This should be an integer in the range 1 to 20. 2. "filespec" is the file specification of the file to be used for input and/or output. The two parameters may be separated from each other and from the command name by one or more spaces or tabs. The general form of the "filespec" parameter is: ddnn:[g,m]name.typ;vers where 1. "ddnn:" is the device on which the file resides or is to reside. If omitted, this field defaults to SY:, the current default disk device. 2. "[g,m]" is the User File Directory (UFD) in which the file resides or is to reside. If omitted, the UFD defaults to the current default directory. PAGE 2 3. "name" is the name of the file, from 1 to 9 alphanumeric characters. If omitted, the name defaults to the usual FORTRAN default, for example, FOR003 for logical unit 3. 4. "typ" is the file extension of the file, from 1 to 3 alphanumeric characters. If omitted, the file extension defaults to DAT. 5. "vers" is the version number of the file. This field may be specified as zero, to force the latest version, or as -1, to force the oldest version. If the version number is omitted (or zero), then the latest version will be used if the first I/O statement is a READ (the file must of course exist), or a new version will be created if the first I/O statement is a WRITE. In the latter case, an explicit version number will cause the file to be overwritten if the specified version already exists. If an OPEN statement is used in a program for a unit where an assignment has previously been created with FILEDEF, then a NAME= or FILE= keyword in the OPEN statement will cause the assignment to be overridden and the value specified with NAME= or FILE= to be used. If an OPEN statement is used without specifying a NAME= or FILE= keyword, then two cases arise: (i) If FILEDEF has supplied filename or type information, this is used in conjunction with the OPEN statement in exactly the same way as if NAME= or FILE= had supplied the information given by FILEDEF; and (ii) If FILEDEF has not been used for this particular logical unit, the usual FORTRAN defaults apply. A call to the ASSIGN routine (see Appendix D of the FORTRAN-77 Users' Guide) also causes the FILEDEF information to be overridden. Since FILEDEF does not explicitly specify whether the file is to be used for input or output, you may wish to code an OPEN statement of the form: OPEN(UNIT=n,READONLY,STATUS='OLD') if the file is to be used exclusively for input. The effect of this is to prevent the file from becoming locked should you abort the program while the file is open. Of course, other OPEN keywords may be used if you wish, for example, for direct access files. If you want to use unit 6 for terminal output instead of the normal FORTRAN default of 5, then the command PAGE 3 FILEDEF 6 TI: may be issued (in this particular case, the MCR command ASN TI:=CL: would accomplish the same thing more efficiently). Other points to note when using FILEDEF are: 1. Assignments are terminal specific, so that you may run the same program at the same time at different terminals with no conflicts. 2. Specifying a unit/file assignment where one exists causes the previous assignment to be replaced. A message will be issued if this happens. 3. All assignments are deleted at the end of the terminal session or batch job so that each new user starts with a clean slate. 4. FILEDEF will work only with programs compiled with the FORTRAN-77 compiler that use the FORTRAN-77 Object Time System (OTS). No special action is required either when compiling or taskbuilding. The FILEDEF system uses a modified OTS which is automatically linked with your task by TKB. 5. The appearance of a file specification in the assignment list in no way implies the existence or otherwise of the file, unless it is actually used by a running program. 6. FILEDEF can produce a number of messages, but these are generally self-explanatory and so are not listed here. 7. If the version number is defaulted, the latest version is used or a new version is created at the time the program is run. If the device and/or UFD is defaulted, the SY: device or the default UIC in effect at the time the FILEDEF command was issued is used. Example: FILEDEF 1 MYFILE.DAT which causes FORTRAN programs activated by subsequent RUN commands to read data from MYFILE.DAT when a statement such as READ(1,10) is executed. PAGE 4 2.0 Deleting Assignments. -------- ------------ The FILEDEF command in the form FILEDEF unit (no file specification) causes the current assignment (if one exists) to be deleted. The usual FORTRAN defaults then apply. If "unit" is zero (not a normally valid logical unit number), then all current assignments for that terminal are deleted. This is done for you by the system when you log off, or a batch job terminates. 3.0 Listing Assignments. ------- ------------ The FILEDEF command with no parameters, that is, FILEDEF produces a listing of your current assignments. The listing may be cancelled by typing CTRL/O if desired.