MPE::File - Perl extension for accessing MPE File intrinsics
use MPE::File; $file = MPE::File->new("FRED.PUB,old;acc=in") or die "Cannot open FRED.PUB: $MPE_error\n"; OR $file = MPE::File->hpfopen(2, "FRED.PUB", 3, 1, 11, 0) or die "Cannot open FRED.PUB: $MPE_error\n"; OR $file = MPE::File->fopen("FRED.PUB", 1, 0) or die "Cannot open FRED.PUB: $MPE_error\n";
$rec = $file->readrec(); # use this instead of fread
$rec = $file->freadbykey($key, $keyloc); $rec = $file->freadlabel( [$labelid] ); $rec = $file->freaddir($lrecnum); $rec = $file->freadc(); $file->fread($buffer, $bufsize);
$file->writerec($buffer, [$controlcode] ) # use this instead of fwrite
$file->fupdate($buffer); $file->fwritedir($buffer, $lrecnum); $file->fwritelabel ($buffer, [$labelid] ) $file->fwrite($buffer, $length, $controlcode)
$file->fpoint($lrecnum); $file->fcontrol($itemnum, $item); $file->fdelete( [$lrecnum] ); $file->fsetmode($modeflags); $file->fremove(); $file->fgetkeyinfo($param, $control); $file->ffindbykey($value, $location, $length, $relop); $file->printfileinfo();
@info = $file->ffileinfo(1, 3, 7, 9);
@info = flabelinfo("FRED.PUB", $mode, 1, 3, 7, 9);
$errmsg = ferrmsg($fserrcode); hperrmsg($displaycode,...)
The primary reference should be the MPE/iX Intrinsic Reference Manual (available at http://docs.hp.com/mpeix/all/index.html)
Notice that there are some difference in parameters. For example, I take care of all the delimited strings in HPFOPEN Subroutines return 0 or undef on failure; check $MPE_error for the error number and/or string (both should be valid).
MPE::File->new($x) is the same as MPE::File->hpfopen(52, $x) which, to quote the Intrinsic manual: "Passes a character string that matches the file equation specification syntax exactly."
You can pass other HPFOPEN parameter pairs after the first one, although almost all can be specified in the file equation.
One that can't be is to save a file right away, on HPFOPEN, instead of waiting until FCLOSE. You can do that like this: $file = MPE::File->new("FRED,new;rec=-80,,f,ascii;msg;acc=in", 3, 4) or die "Cannot open FRED: $MPE_error\n"; (Notice the 3, 4 pair at the end.)
If you use FFREADBYKEY, remember to pad out your keys to the full length. Also, if they are binary keys, you'll need to use pack, otherwise a number will be converted to its string equivalent.
This documentation will be expanded at some point; feel free to send me suggestions (or completed paragraphs).
flabelinfo $MPE_error
Ken Hirsch <kenhirsch@myself.com>
This module may be used and distributed on the same terms as Perl.
perl(1).