HPlogo Getting Started as an MPE/iX Programmer Programmer's Guide: HP 3000 Computer MPE/iX Computer Systems > Chapter 6 File System

Record Structure

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Record structures provide a definition of storage format, record type, and size.

Storage Format

Devices on the 900 Series HP 3000 can transmit information in ASCII (American Standard Code for Information Interchange) and/or binary code, depending on the device. For example, a line printer handles ASCII formatted data, while a disc can transmit and store data in either format. You can use optional parameters in the HPFOPEN or FOPEN intrinsic to specify the code (ASCII or binary) in which a new file is to be recorded when it is written to a device that supports both codes.

Examples of ASCII files on the HP 3000 include program source files, general text and document files, and MPE/iX stream files containing MPE/iX commands. Examples of binary files include program files containing linked object code and application data files. For detailed information, refer to Accessing Files Programmer's Guide (32650-90017).

Record Types

A file can contain records written in one of three formats, called record types:

  • Fixed-length

  • Variable-length

  • Undefined-length

Figure 6-12 “Record Types” shows how the content of each record type appears.

Figure 6-12 Record Types

[Record Types]

You can specify the format for records by using one of the following:

  • HPFOPEN or FOPEN intrinsic

  • MPE/iX command :BUILD

  • MPE/iX command :FILE

Files residing on disc or magnetic tape can contain records in any of the three formats. For files on other devices, the File System overrides any specifications you supply for records and handles them as having undefined length.

A comparison of logical record formats is given in Table 6-5 “Comparison of Logical Record Formats”. For a detailed discussion of fixed-length, variable-length, and undefined-length records, refer to Accessing Files Programmer's Guide (32650-90017).

Table 6-5 Comparison of Logical Record Formats

Fixed-lengthVariable-lengthUndefined-length
File System knows data lengthFile System knows data lengthFile System does not know data length
All records same lengthRecord length variesRecord length varies
Record space contains only dataRecord space contains data plus byte countRecord space contains data plus filler
Request actual record sizeRequest maximum record sizeRequest maximum record size

 

Specifying a Record Size

You can specify the size of records in your file by using one of the following:

  • MPE/iX command :BUILD (for disc files)

  • MPE/iX command :FILE

  • HPFOPEN or FOPEN intrinsic

You can specify your own record size or accept the default size for the device you are using.MPE/iX default record sizes for devices are shown in Table 6-6 “Standard Default Record Sizes”. Subsystem defaults may be different from MPE/iX defaults. For example, the Editor default can be 72 or 80 bytes, depending on the text format, while the MPE/iX standard default is the record size configured for the device. For detailed information on specifying a record size, refer to Accessing Files Programmer's Guide (32650-90017).

Table 6-6 Standard Default Record Sizes

DeviceRecord Size (Bytes)
  
Disc256
Magnetic tape unit256
Terminals (most)80*
Line printer132*
Plotter510
 * Controlled by configured record length.
  

 

The File System sets up all records (ASCII and binary) to begin on 2-byte boundaries for device files. Even if you specify an odd-byte record, the next record cannot begin in the next byte. In this case, the File System adjusts the record size by adding one byte to make the next record begin on a word boundary. If the file is ASCII, the extra byte is made inaccessible for data. If the file is binary, the byte is accessible. Figure 6-13 “Odd-byte Record Sizes” below, shows how the File System handles odd-byte record sizes in Compatibility Mode for device

Figure 6-13 Odd-byte Record Sizes

[Odd-byte Record Sizes]

The adjustment the File System makes for odd-byte record sizes is important when reading tapes created on other systems. If the tape has actual odd-byte length records that are blocked, you cannot specify the exact byte length and blocking factor and obtain accurate results, because you will get a cumulative effect of each successive record being "off" by more bytes. It is a recommended practice to handle the block as one large logical record in one block and then programmatically pull apart the odd byte lengths. You can use the DEBLOCK option of FCOPY for this purpose.