CRE Programmer's Guide
CRE Services
Common Run-Time Environment (CRE) Programmer’s Guide—528146-004
2-28
Determining When Standard Files Are Opened
Determining When Standard Files Are Opened
The language in which the main routine is written determines when and if standard files
are opened. If the main routine is written in C, the C run-time library opens the three
standard files as part of program initialization unless the C main routine specifies the
nostdfiles pragma. If the main routine is written in COBOL, FORTRAN, or TAL,
standard files are opened only when routines in those languages explicitly execute a
statement that opens a standard file.
If a program contains C routines and the main routine is not written in C, one of the C
routines must open explicitly each standard file before any C routine in the program
accesses that standard file. You open standard files in C by calling the C library
function fopen_std_file():
fopen_std_file( file, die_on_error )
fopen_std_file() opens a connection to a standard file.
The Guardian TNS C Library Calls Reference Manual describes the
fopen_std_file() library function.
See the reference manual for each language for further information on opening
standard files.
Using Terminals and Process
If the physical file specified for standard input is the same as the physical file specified
for either standard output or standard log (or both), and the device type of standard
input is either a terminal or a process (but not a spooler collector), the CRE opens the
specified file only once and uses the same operating system file open when your
program reads from standard input or writes to standard output or standard log.
Program Startup Message
When your program begins execution, the CRE reads the startup message sent to it by
the process that starts your program. The discussions that follow frequently reference
two of the fields of the startup message: INFILE and OUTFILE. Figure 2-10
shows the
locations of INFILE and OUTFILE in the startup message. The Guardian Programmer’s
Guide describes all of the fields in the startup message.