NAME

MPE::File - Perl extension for accessing MPE File intrinsics

SYNOPSIS

 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
 # (do not include '\n' at end of rec)

 $file->print($a, $b, $c);
 $file->printf($fmt, $a, $b, $c);
 # (do not include '\n' at end of rec)


 $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();

 $rec = $file->iowait();
   or
 $rec =iowait(0);
  then call lastwaitfilenum() to get file number

 $rec->mpe_fileno
   You'll need this to compare with lastwaitfilenum()

 mpeprint("rec");
   Calls MPE intrinsic PRINT()
   (Perl print does not work right if stdout is circular file, msg file, ...)

 printop($msg);
 $rec = printopreply($msg);

 @info = $file->ffileinfo(1, 3, 7, 9);

 @info = flabelinfo("FRED.PUB", $mode, 1, 3, 7, 9);
   If there is an error, an empty list is returned and you can check
   $MPE_error and @MPE::File::itemerror for the error

 $errmsg = ferrmsg($fserrcode);
 hperrmsg($displaycode,...)

DESCRIPTION

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).
For example:
  if ($MPE_error == 52) {
    print 0+$MPE_error, " ", $MPE_error, "\n";
  }
Will print
 52 NONEXISTENT PERMANENT FILE  (FSERR 52)
(if that is the error).

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).

EXPORT

flabelinfo $MPE_error

AUTHOR

Ken Hirsch <kenhirsch@myself.com>

This module may be used and distributed on the same terms as Perl.

SEE ALSO

perl(1).