SPL to HP C/XL Migration Guide (30231-90001)

9- 3
#include <mpe.h>
filenum
= _mpe_fileno(
filedes
)
See the
HP C/XL Library Reference Manual
for more details.
Conflicting Function and Intrinsic Identifiers
Five of the functions in the HP C/XL standard library have the same names
as MPE intrinsics: fopen, fclose, fread, fwrite, and read. If any of
the MPE intrinsics of the same name are used, it is recommended that you
rename them with the #pragma intrinsic directive to avoid confusion.
For instance:
#pragma intrinsic FREAD MPE_FREAD
Although case sensitivity would render FREAD distinct from fread, the
use of MPE_FREAD is much more descriptive. It's probably a good idea to
apply the same renaming scheme to all the MPE intrinsics your program
uses, just to make them easier to find.
Error Reporting
The MPE intrinsics vary in how errors are reported. Some return an error
value for a function value or parameter, but most have a side effect of
setting the condition code. The HP C/XL library function ccode returns
the most recent setting of the condition code.
The HP C/XL I/O functions report an error by returning an error value,
and sometimes by setting an external variable errno. The value of errno
will indicate the error which caused the most recent intrinsic or li-
brary function error. Its value is not changed or reset until the next
instance of an error, so errno should not be interrogated unless a
function that sets it reports an error.
Summary of Intrinsics, Macros, and Functions
Table 9-1 lists the MPE XL I/O intrinsics. Note that all but HPFOPEN are
equivalent to the MPE V versions. HPFOPEN is only available in MPE XL.
It has clearer ways of passing parameters than FOPEN, as well as having
more options. See the
MPE XL Intrinsics Reference Manual
for details.
Table 9-1. MPE XL I/O Intrinsics
-------------------------------------------------------------------------------------------
| Intrinsic Description |
-------------------------------------------------------------------------------------------
| FCHECK(
filenum
,
fserr
,
translog
,
block
,
nrec
) Get details on I/O errors |
| FCLOSE(
filenum
,
disp
,
seccode
) Close file |
| FCONTROL(
filenum
,
controlcode
,
param
) Perform control operation on file or |
| terminal |
| FOPEN(
formdesig
,
foptions
,
aoptions
,...) Open file; return
filenum
, 16-bit file |
| number |
| FREAD(
filenum
,
buffer
,
length
) Read logical record from sequential file; |
| return count |
| FREADDIR(
filenum
,
buffer
,
length
,
lrecnum
) Read logical record from direct access file |
| FSPACE(
filenum
,
disp
) Space forward or backward on file |
-------------------------------------------------------------------------------------------