Accessing Compatibility Mode Data Files [ HP Business BASIC/XL Migration Guide ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Migration Guide
Chapter 7 Accessing Compatibility Mode Data Files
Introduction
There are three data file types within HP Business BASIC/XL:
* ASCII
* Binary
* BASIC DATA
ASCII files store only character information. Binary files consist of
data items without item separators or descriptors. BASIC DATA files are
binary files that contain data descriptors for each item in the file.
There is no difference in the alignment of data between a compatibility
mode and a native mode data file because data file word length is 16 bits
in both systems. The internal representation of real data types is the
only difference between the two data file types.
The file code associated with each data file identifies whether the file
stores information in MPE V or MPE XL format. HP Business BASIC/XL reads
the file code when it opens the file. If the file code indicates that
the file stores data in MPE V format then floating-point real data
conversions are done automatically. Therefore, HP Business BASIC/XL
applications can share data files with unmigrated HP Business BASIC/V
(compatibility mode HP Business BASIC/XL) applications.
When the migration aid changes HP Business BASIC/V data files to HP
Business BASIC/XL data files, it is changing MPE V floating-point real
numbers to IEEE real numbers. Using IEEE real numbers instead of MPE V
floating-point real numbers provides faster execution of programs on MPE
XL because MPE XL uses IEEE real numbers as a default; native mode
programs that use compUatibility mode data files have lower performance
because real numbers have to be changed on each READ and WRITE of the
data files.
Accessing Compatibility Mode BASIC DATA Files
BASIC DATA files have a distinct file code and associated name in both
compatibility and native mode. The run-time library reads the file code
when the file opens and handles the data descriptor and data items as if
the file is on an MPE V system if the file is an HP Business BASIC/V Data
(BDATA) file. Real data types are changed automatically from MPE V real
numbers to IEEE real numbers during input and vice versa for output. In
most cases, source file changes are not necessary for compatibility mode
BASIC DATA file access. However, there are some potential problems
because of the change in floating-point real format representation. MPE
V and MPE XL have different limits on the exponents that real numbers and
short real numbers can have. Table 7-1 gives the ranges.
Table 7-1. Exponent Limits on Real and Short Real Numbers
----------------------------------------------------------------------------------------------
| | | |
| System | Real Exponent Range | Short Real Exponent Range |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| MPE XL | +308/-324 | +38/-45 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| MPE V | +/-77 | +/-77 |
| | | |
----------------------------------------------------------------------------------------------
The following problems might occur during reads or writes to HP Business
BASIC/V Data (BDATA) files:
* Short real overflow or underflow can occur on file reads during
conversions from MPE V real format because short real data in
compatibility mode data files can exceed the range of +38/-45.
* Short real overflow or underflow can occur when reading in a real
number as a short real number during file reads. On MPE V, you could
read in a real value as a short real variable without risking an
overflow. On MPE XL, you risk an overflow.
* Real overflow or underflow can occur on file writes during conversion
from IEEE real format to MPE V real format for real data that is not
between +77 and -77.
There are a few ways to solve the above problems. However, you must
examine each case carefully. A possible solution for short real overflow
and underflow problems is to change the short real variable to real.
This might cause further source file changes if you use direct record and
direct word input/output in the program, because real data type occupies
64 bits and short real data type only occupies 32 bits in the data file.
Another possible solution is to run programs that have these potential
range overflows in compatibility mode (HP Business BASIC/V) instead of
native mode (HP Business BASIC/XL).
Accessing Compatibility Mode Binary Files
Normally, there is no way to distinguish between a native mode binary
file and a compatibility mode binary file. If you want a native mode HP
Business BASIC/XL program to access a compatibility mode binary file, you
have to run the data file migration aid, BBCTMPEV.PUB.SYS, to add the
file code, "BBNCM" to the file. Adding this file code identifies that
file as one that uses MPE V real format data to native mode programs. HP
Business BASIC/XL assumes that binary files without this file code are
native mode files; floating-point real numbers are not converted. Both
HP Business BASIC/XL and HP Business BASIC/V create binary files without
file codes by default. Run the migration aid to add the filecode to the
binary file if you need both compatibility and native mode access.
However, there are some potential problems because of the change in
floating-point real number format representation. MPE V and MPE XL have
different limits on the exponents that real numbers and short real
numbers can have. Table 7-2 gives the ranges.
Table 7-2. Exponent Limits on Real and Short Real Numbers
----------------------------------------------------------------------------------------------
| | | |
| System | Real Exponent Range | Short Real Exponent Range |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| MPE XL | +308/-324 | +38/-45 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| MPE V | +/-77 | +/-77 |
| | | |
----------------------------------------------------------------------------------------------
The following problems might occur during reads and writes to HP Business
BASIC/V binary files (files with a BBNCM filecode):
* Short real overflow or underflow can occur on file read during
conversion from MPE V real format because short real data in
compatibility mode data files can exceed the range of +38/-45.
* Real overflow or underflow can occur on file writes during conversion
from IEEE real format to MPE V real format for real data that is not
between +77 and -77.
There are a few ways to deal with the above problems. However, you must
examine each case carefully. A possible solution for short real overflow
and underflow problems is to change the short real variable to real.
This might cause further source file changes if you use real variable to
real. This might cause further source file changes if you use direct
record read and write in the program, because real data type occupies 64
bits and short real data type only occupies 32 bits in the data file.
Another possible solution is to run programs that have these potential
range overflows in compatibility mode HP Business BASIC/V instead of
native mode HP Business BASIC/XL.
MPE/iX 5.0 Documentation