| United States-English |
|
|
|
![]() |
HP Pascal/HP-UX Programmer's Guide > Chapter 3 Input/Output Opening Files |
|
Except when using input and output files, your program must open files before it can use them. A call to a predefined file-opening procedure has the following syntax and parameters. Syntax [{resetrewriteappendopen} (logical_file [, physical_file [, open_options]])] Parameters
Example 1
If you specify physical_file, the system associates it with logical_file. If logical_file was previously associated with another physical file, the system closes the other physical file with its data intact and opens a new physical file. Example 2
If logical_file is not a program parameter, and physical_file is not specified, logical_file remains associated with its previously associated physical file. If logical_file was not previously associated with a physical file, the system associates logical_file with a temporary, nameless physical file. Example 3
If logical_file is a program parameter, and physical_file is not specified, the system opens the physical file that has the same name as logical_file (with the lowercase letters upshifted — see Appendix B “HP-UX Dependencies ” for HP-UX implications). If no such physical file exists, the result depends on whether either append or rewrite opened the logical file. If so, the system creates the physical file. If not, it is an error. Example 4 For this example, assume that the physical file file1 exists, but the physical file file2 does not.
A temporary, nameless physical file cannot be saved. It becomes inaccessible when the main program or routine that declared logical_file terminates, or when you associate logical_file with a new physical file. Your program does not need to open the standard textfiles input and output. When they are program parameters, the operating system opens them with reset and rewrite, respectively. The standard textfiles input and output are bound to specific system files. For the MPE/iX operating system, see Appendix A “MPE/iX Dependencies ”; for the HP-UX operating system, see Appendix B “HP-UX Dependencies ”. Table 3-2 “Characteristics of File-Opening Procedures” summarizes the characteristics of the four predefined file-opening procedures. Table 3-2 Characteristics of File-Opening Procedures
Title not available (Opening Files )
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||