Data Format Conversion [ HP Pascal/XL Migration Guide ] MPE/iX 5.0 Documentation
HP Pascal/XL Migration Guide
Data Format Conversion
The MPE V floating-point routines can access MPE V real numbers that
begin on 16-bit boundaries. This is not true for IEEE floating-point on
MPE XL based systems. These floating-point routines are written with the
32-bit boundary as the "natural" boundary for data types such as real
numbers. Programs using IEEE floating-point require four or eight byte
alignment for floating-point data. Refer to the HP Pascal Programmer's
Guide for further information on alignment.
The difference in floating-point formats can be handled by the
hpFPCONVERT intrinsic. This intrinsic converts a floating point number
from one format to another, as needed. This conversion is illustrated in
the data file migration example in Chapter 4. Refer to the Programmer's
Skill Migration Guide for a description of hpFPCONVERT.
Strconvert Procedure
The predefined procedure strconvert converts a string from Pascal/V
packing algorithm (HP3000_16) format to HP Pascal/XL packing algorithm
(HP3000_32) format. It is enabled by the HP3000_16 compiler option.
Syntax
strconvert(string1,string2)
Parameters
string1 The name of the string variable to be converted. The
string variable must be in Pascal/V packing algorithm
(HP3000_16) format.
string2 The name of the string variable into which the converted
string is to be stored. The string variable must be in
HP Pascal/XL packing algorithm (HP3000_32) format.
Example
$HP3000_16$ {Enables strconvert procedure}
PROGRAM prog;
TYPE
str16_20=string[20]; {Pascal/V packing algorithm (HP3000_16)}
str32_40=$HP3000_32$ string[40]; {Pascal/XL packing algorithm (HP3000_32)}
VAR
sv32_1,
sv32_2 : str32_40;
sv16_1,
sv16_2 : str16_20;
BEGIN
strconvert(sv16_1,sv32_"1);
strconvert(sv32_2,sv32_1); {Illegal}
strconvert(sv16_1,sv16_2); {Illegal}
END.
Setconvert Procedure
The predefined procedure setconvert converts a set from HP Pascal/XL
packing algorithm (HP3000_32) format to Pascal/V packing algorithm
(HP3000_16) format, or vice versa. It is enabled by the HP3000_16
compiler option.
Syntax
setconvert(set1,set2)
Parameters
set1 The name of the set variable to be converted.
set2 The name of the set variable into which the converted
set is to be stored.
The sets set1 and set2 can vary only in packing algorithm format. Their
packing (unpacked, packed, or crunched) and base types must be the same.
It is an error if their packing or base types are different. It is also
an error if their packing algorithm formats are the same.
Example
$HP3000_16$ {Enables setconvert procedure}
PROGRAM prog;
TYPE
hp3000_16_set1 = SET OF char;
hp3000_32_set1 = $HP3000_32$ SET OF char;
hp3000_32_set2 = $HP3000_32$ PACKED SET OF char;
hp3000_32_set3 = $HP3000_32$ SET OF integer;
VAR
set16_1,
set16_2 : hp3000_16_set1;
set32_1 : hp3000_32_set1;
set32_2 : hp3000_32_set2;
set32_3 : hp3000_32_set3;
BEGIN
setconvert(set16_1,set32_1); {convert from Pascal/V to HP Pascal}
setconvert(set32_1,set16_1); {convert from HP Pascal/XL to Pascal/V}
setconvert(set16_1,set32_2); {Illegal -- different packings}
setconvert(set16_1,set32_3); {Illegal -- different base types}
setconvert(set16_1,set16_2); {Illegal -- same packing algorithm format}
END.
NOTE The data file migration example in Chapter 4 shows the use of
hpFPCONVERT, setconvert, and strconvert.
MPE/iX 5.0 Documentation