Opening a System-Defined File [ Accessing Files Programmer's Guide ] MPE/iX 5.0 Documentation
Accessing Files Programmer's Guide
Opening a System-Defined File
System-defined file designators indicate those files that the file system
uniquely identifies as standard input/output devices for jobs and
sessions. System-defined files are $STDIN, $STDINX, $STDLIST, $NEWPASS,
$OLDPASS, and $NULL. You cannot redefine characteristics for these files
once the process executing your code has been created, nor can you
backreference a file equation to redefine the characteristics for
a system-defined file designator. For more information about
system-defined files, refer to Chapter 3, "Specifying a File Designator".
The following examples show two different ways that you can open
system-defined files using the indicated HPFOPEN options:
* "Opening $STDIN" shows an example of an HPFOPEN call that uses the
designator option to open the job or session standard input device
(see Example 5-3).
* "Opening $STDLIST" shows an example of an HPFOPEN call that uses
the formaldesignator option to open the job or session standard
list device (see example 5-4).
Opening $STDIN
Example 5-3 is an HP Pascal/iX code segment containing an HPFOPEN
intrinsic call that uses only the designator option to open the
system-defined file $STDIN. $STDIN is the file designator associated with
your job or session's standard input device. For an interactive session,
$STDIN is always a terminal keyboard. For a batch job, $STDIN may be a
disk file or other input device. You can also open a system-defined file
using only the HPFOPEN formaldesignator option (illustrated in Example
5-4).$STDIN, opening:files|
Example 5-3. Opening $STDLIST Using HPFOPEN designator option
procedure open_standard_input_device
const
designator_option = 5; {defines HPFOPEN itemnum 5}
var
inputfile_num : integer; {required HPFOPEN filenum parameter}
status : integer; {returns info if error/warning occurs}
designator : integer; {declares HPFOPEN item 5 }
begin
inputfile_num := 0;
status := 0;
designator := 4; {Specifies $STDIN }
HPFOPEN (inputfile_num, status,
designator_option, designator, {HPFOPEN designator option}
);
if status <>0 then handle_file_error (inputfile_num, status);
end;
If the HPFOPEN call is successful, a positive integer value is returned
in inputfile_num, and status returns a value of zero. The file is now
open and can be read from. If an error or warning condition is
encountered by HPFOPEN, status returns a nonzero value, thus invoking the
error-handling procedure handle_file_error. For more information about
HPFOPEN parameters, refer to the MPE/iX Intrinsics Reference Manual
(32650-90028).
Opening $STDLIST
Example 5-4 is an HP Pascal/iX code segment containing an HPFOPEN
intrinsic call that uses the formaldesignator option to open the
system-defined file $STDLIST.
$STDLIST is the file designator associated with your job or session's
standard list device. For an interactive session, $STDLIST is nearly
always a terminal screen. For a batch job, $STDLIST is usually a line
printer. You can also open $STDLIST using the HPFOPEN designator option
(illustrated in Example 5-3).
Example 5-4. Opening $STDLIST Using HPFOPEN formaldesignator option
procedure open_standard_list_device
const
formal_designator_option = 2; {defines HPFOPEN itemnum 2}
type
pac80 = packed array [1..80] of char;
var
listfile_num : integer; {required HPFOPEN filenum parameter}
status : integer; {returns info if error/warning occurs }
file_name : pac80; {declares HPFOPEN item 2 }
begin
listfile_num := 0;
status := 0;
file_name := '$stdlist'; {Specifies system-defined file }
{Blank is used as delimiter }
HPFOPEN (listfile_num, status,
formal_designator_option, file_name,
{formaldesignator option}
);
if status <>0 then handle_file_error (listfile_num, status);
end;
If the HPFOPEN call is successful, a positive integer value is returned
in listfile_num, and status returns a value of zero. The standard list
device is now open and can be written to. If an error or warning
condition is encountered by HPFOPEN, status returns a nonzero value, thus
invoking the error-handling procedure handle_file_error.
In appendix A, "HP Pascal/iX Program examples," example A-1 uses a
similar procedure to open $STDLIST. For more information about
HPFOPEN parameters, refer to the MPE/iX Intrinsics Reference Manual
(32650-90028).
MPE/iX 5.0 Documentation