HP 3000 Manuals

Lesson 2 Building Disk 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 2 Building Disk Files 

Introduction 

You have had a brief introduction to different types of files:
permanent, temporary, and formal.  In lesson 2, you will learn how to use
the BUILD command and the following options to create customized files:

   *   record size

   *   blocking factor

   *   record type

   *   file type

The BUILD command is useful when you need to change the file's format so
that another program or subsystem can accept the format.

For example, using the editor, you can only display and edit files that
contain data in a particular format.  If you "inherit" a file from
another system, it may not be in the correct format.  For example,
suppose that you enter the command:

     LISTFILE @,6 > LISTFILE

This command generates a temporary file called LISTFILE. The > causes
MPE/iX to put the display from this command into a temporary file.


NOTE If you try to edit LISTFILE you will find that the editor truncates some of the lines if they are too long for the editor. For many temporary text files, this presents no problem. If you suspect that truncation will cause a problem, then change the file format by building a new file with the appropriate format. Copy the temporary file into the new file. Then edit the new file. Your original temporary file keeps its format while you edit the copy.
The BUILD command allows you to specify the "shape" of a file that as yet contains no information. Using BUILD is much like creating a container into which liquid will be poured; the contents will conform to the dimensions of the container. In the BUILD situation, data will conform to the characteristics of the empty file created by the BUILD command. The following illustration shows how the data in a file will take on the characteristics of its "container."
[]
Figure 2-2. BUILD Command Generally speaking, as a general user, you are not so much concerned with the characteristics of a file, as with the data in it. Usually, the subsystem that you are using (for example, some editor) automatically creates files with the appropriate characteristics that determine how the contents are stored on disk. As you become a more experienced user, you may become concerned with how to make programs run most efficiently by defining a file's characteristics more precisely. Although you cannot alter the physical characteristics of an existing file, you can create a new file with the desired characteristics (using BUILD) and then copy the contents of the existing file into the new one (using FCOPY). The new file contents then have the appropriate characteristics. The FCOPY command is covered in module 4, File Transfer. BUILD command The BUILD command builds a new file. The options associated with the BUILD command determine the physical characteristics of the file. Partial syntax for the BUILD command appears below. The complete syntax and option explanation can be viewed in the MPE/iX Commands Reference Manual Volumes 1 and 2 (32650-90003 and 32650-90364) or in the online help facility. BUILD filename[/lockword];REC=recsize, blockfactor,rectype,filetype;options Parameter Description --------------------------------------------------------------------------------------- filename MPE/iX file name lockword Special password to restrict access to specific file recsize Record size (negative number is bytes, positive number is words) blockfactor Ratio indicating number of logical records per physical block (R/B on the LISTFILE columns) rectype Record type (F=fixed-length, V=variable length, U=undefined) filetype Type of data (ASCII,binary) options Device, file code, carriage control, and more Consider a file that already exists. View the various characteristics specified by the BUILD command. Enter this command: LISTFILE MYFILE,3 All questions about the BUILD command options refer to the display that you now see on the screen.
NOTE Later, you might also wish to do a LISTFILE MYFILE,2 to compare the abbreviated titles with the full-length ones of the LISTFILE MYFILE,3 command.
Lockword You've already worked with passwords at the account, group, and user level. MPE/iX provides a further level of security, lockwords. These are file "passwords," which restrict access to a particular file. This means that even if you know the account, group, and user passwords, you will not be able to access a particular file unless you know the lockword. When using the BUILD or RENAME command, use a forward slash (/) to delimit the lockword. The slash is not part of the lockword.
NOTE A user with SM capability can use LISTFILE,3 with the ;PASS option to display the lockword.
For example, suppose you build a file called SECRETS: BUILD SECRETS/KEY Whenever you try to view SECRETS, you must also specify the lockword, KEY.
Be Careful If you type a / when you are entering a file name, the system interprets everything after the / as a lockword. If that was not what you intended, you may have no recollection of it (and you may be unable to access the file).
For example, suppose that you accidentally type: MY/FILE You may think you have a file called MYFILE; however, the system interprets a file called MY with a lockword of FILE. Record size Record size refers to the number of bytes or words per record. Record size is important because certain applications can read only records of a certain size. You may find that if a file has records of a different size, you will not be able to display or edit that file. This record size may vary according to the utility or program that created the file. For example, a file created with the editor will have a different record size than one created by LISTFILE > filelist. A positive record size indicates the number of two-byte words in the record. A negative record size indicates the number of bytes in the record. -------------------------------------------------------------------------------------------- | | | Q2-5 What is the record size of MYFILE? | | | | | -------------------------------------------------------------------------------------------- Blocking factor This option is a holdover from a previous operating system, MPE V. At one time, the blocking factor was used to determine the number of logical records for each physically configured block. The more logical records per block, the more densely the data was packed. This helped to conserve space; however, blocking is rarely used on MPE/iX, so the blocking factor is usually allowed to default.
NOTE When you do not build the file with the BUILD command, the blocking factor may vary according to the utility or program that created that file.
For files with variable-length records, the blocking factor always equals one. -------------------------------------------------------------------------------------------- | | | Q2-6 What is the blocking factor for MYFILE? | | | | | -------------------------------------------------------------------------------------------- Record type Records are either fixed-length (length is a specific number of words or bytes), variable length (length changes with the data), or undefined. Generally speaking, editors can only read and work with fixed-length records.
NOTE When you do not build the file with the BUILD command, the record type may vary according to the utility that created that file.
[]
Figure 2-3. Record Type -------------------------------------------------------------------------------------------- | | | Q2-7 What is the record type of MYFILE? | | | | | -------------------------------------------------------------------------------------------- File data type Text files that you can view and edit tend to be ASCII. Executable program files and graphics files tend to be binary. In the next lesson you will have an opportunity to create some binary files. -------------------------------------------------------------------------------------------- | | | Q2-8 What is the file type of MYFILE? | | | | | | Q2-9 Based on the information from LISTFILE and on your understanding of BUILD | | options, what was the original BUILD command that created MYFILE? | | | | | -------------------------------------------------------------------------------------------- Other BUILD options There are several other options that you may occasionally wish to specify in the BUILD command: TEMP User-defined temporary file CCTL/NOCCTL Carriage control or no carriage control characters STD/MSG/CIR Standard, message, or circular file KSAMXL/SPOOL KSAM or spool file DEV Device CODE File code identifying the specific type of file (for example, the editor file or executable code). Exercise 2-2:creating a file to specification. 1. Write the correct BUILD command to create to specification each of the files listed below. Whenever default values are specified, let the parameter default in the BUILD syntax. _________________________________________________________________ NOTE 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). _________________________________________________________________ a. FILE1 - should have 64 words/record, have fixed-length records, be an ASCII file, and be circular. b. FILE2 - should have variable-length records whose maximum size is 256 words and be a binary file. c. FILE3 - should have variable-length records whose maximum size is 88 bytes and be an ASCII file. 2. Build the following file and give it a unique name. (Suggestion: use your first name of eight characters or less.) Assume following the values: record size = 80 bytes record type = fixed-length file type = ASCII _________________________________________________________________ NOTE Make sure that you are logged on as USERx.ACCTx in the CLASS group. _________________________________________________________________ Use LISTFILE to confirm that the file exists. Use PRINT to confirm that the file is empty. You will later have the opportunity to copy the contents of an existing file into this empty file. ********** End of Exercise 2-2 ********** Lesson summary 1. The BUILD command lets you create a file with specific characteristics. 2. The following BUILD options can be used to specify the file characteristics: a. record size (REC=) b. blocking factor c. record type (F,V,U) d. file type (ASCII,BINARY) e. device (DEV) f. file code


MPE/iX 5.0 Documentation