Accessing Files Programmer's Guide (32650-90885)

Chapter 5 97
Opening a File
Opening a System-Defined File
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;