HP 3000 Manuals

Lesson 3 Creating Temporary Files [ Using the 900 Series HP 3000: Advanced Skills Module 2: File Management ] MPE/iX 5.0 Documentation


Using the 900 Series HP 3000: Advanced Skills Module 2: File Management

Lesson 3 Creating Temporary Files 


NOTE System programmers must read this lesson. If you do not plan to do any programming, you may skip this lesson.
Introduction Lesson 3 presents the following concepts related to compiling and linking files: * displaying names of temporary files * creating temporary files during compiling and linking * using system-defined temporary files to redirect compilation output Some files, other than those that you create, are created by the system or subsystem temporarily during program compiling and linking. These files are referred to as temporary, system-defined files. In this lesson, you will learn about several of these system-defined files: $NEWPASS Temporary file created automatically during compiling to which newly generated compiled code is written. $OLDPASS Temporary file created automatically when compiling is complete. Used to hold compiled code. $NULL Temporary file that is empty when used as input and meaningless when used as output. (The output essentially disappears into what is referred to as the bit bucket.) Each of these files is discussed in this lesson. $NEWPASS and $OLDPASS The system creates temporary files to hold data generated during program processing. By doing this, output from one process can serve as input to another process. For example, compiler output serves as linker input.
[]
Figure 2-4. Temporary Files When you compile and link a program, the following happens, as shown in figure 2-4: 1. Source code serves as input to the compiler. 2. The compiler builds $NEWPASS and writes compiled code to $NEWPASS. 3. When compiling is done, $NEWPASS is closed and renamed $OLDPASS (automatically). $OLDPASS contains the object code. 4. The linker uses $OLDPASS as input. 5. The linker builds $NEWPASS and writes linked, executable code to $NEWPASS. 6. When linking completes, $NEWPASS is closed and renamed $OLDPASS (automatically). $OLDPASS contains the executable code. $OLDPASS may be executed or saved with a new name by the user. The LISTFILE command alone does not the names of these files. LISTFILE displays only permanent, disk files. To display the names of temporary files, such as $OLDPASS, you must use the ;TEMP option of the LISTFILE command (LISTFILE;TEMP). Here is an exercise that generates these temporary files. Exercise 2-3: $OLDPASS. Follow the designated steps to generate $OLDPASS. 1. Make sure that you are logged on as USERx.ACCTx in the CLASS group. 2. Compile and link the C source code called HIC. You can list its contents with PRINT. The commands to compile and link are given below: CCXLLK source,program,listfile source: source file (HIC) program: compiled, linked code (default = $OLDPASS) listfile: errorlisting file (default = terminal screen) a. Allow the name of the executable program file (compiled, linked version) to default. b. Name the error listing file, HIERR. 3. To see if any temporary files were generated, enter: LISTFILE @.CLASS,2;TEMP a. Are any temporary files generated? b. What is their file type and file code? What does this mean? (A list of codes appears in the help facility (at the system prompt, enter: HELP FILE FILECODE). The same information is available in appendix F of the MPE/iX Commands Reference Manual Volumes 1 and 2 (32650-90003 and 32650-90364). c. What happens if you enter LISTFILE @.CLASS.ACCTx,2 Why? 4. To save the $OLDPASS file as a permanent file, you must enter this command: SAVE $OLDPASS,filename a. Do so now to save $OLDPASS as a permanent file called HICP. SAVE $OLDPASS,HICP b. Use the LISTFILE command to verify that it is now a permanent disk file with the proper characteristics. Notice in particular that this is a binary file, ready for execution. 5. Use LISTFILE,3 to examine the characteristics of the HIERR file (especially the record size and the file type). Since HIERR is an ASCII file, you should be able to view it; however, the record size is too great for the editor. What might you do to remedy this? ********** End of Exercise 2-3 ********** When you are modifying, compiling, and linking several programs, over and over again, $OLDPASS always contains the latest version of whatever source code was processed. To prevent the possibility of overwriting the current processed code, you must explicitly specify a program file name in the compile/link command line.
[]
Figure 2-5. Overwriting $OLDPASS Allow the name to default to $OLDPASS only if you are working with just one program. Make sure to save $OLDPASS under a different name when you finish, because temporary files only exist for the duration of the session! $NULL If you wish your output to "disappear," $NULL is a handy file to use. Output that is written to $NULL goes nowhere ("bit bucket").
[]
Figure 2-6. $NULL File For example, suppose that you had a program that took user input, performed calculations, and wrote those calculations to the terminal and to a file. During the compiling/linking phase, you are interested only in whether or not the program is syntactically correct. For testing purposes--when you run the program--you are interested only in whether or not it prompts correctly, and lists the results on the screen where you can examine them. You don't care whether the results are stored in a file or not. In this case, you can specify the output file to be $NULL and it will never show up on disk.
NOTE For Programmers When compiling a large program, specify $NULL as the list file. Compilation occurs much faster since no time is spent listing program lines on the screen.
Lesson summary 1. The LISTFILE;TEMP command displays the names of temporary files. 2. $NEWPASS and $OLDPASS are created during compiling and linking. Only $OLDPASS remains after the process. 3. $NULL can be used to direct program output to "disappear" during testing. 4. SAVE is used to save a temporary file as a permanent one.


MPE/iX 5.0 Documentation