Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

A.10.3 Default Input, Output, and Error Files

Static Semantics

1
The following subprograms provide for the control of the particular default files that are used when a file parameter is omitted from a Get, Put, or other operation of text input-output described below, or when application-dependent error-related text is to be output.
2
procedure Set_Input(File : in File_Type);
3
Operates on a file of mode In_File. Sets the current default input file to File.
4
The exception Status_Error is propagated if the given file is not open. The exception Mode_Error is propagated if the mode of the given file is not In_File.
5
procedure Set_Output(File : in File_Type);
procedure Set_Error (File : in File_Type);
6
Each operates on a file of mode Out_File or Append_File. Set_Output sets the current default output file to File. Set_Error sets the current default error file to File. The exception Status_Error is propagated if the given file is not open. The exception Mode_Error is propagated if the mode of the given file is not Out_File or Append_File.
7
function Standard_Input return File_Type;
function Standard_Input return File_Access;
8
Returns the standard input file (see A.10), or an access value designating the standard input file, respectively.
9
function Standard_Output return File_Type;
function Standard_Output return File_Access;
10
Returns the standard output file (see A.10) or an access value designating the standard output file, respectively.
11
function Standard_Error return File_Type;
function Standard_Error return File_Access;
12/1
{8652/0052} {AI95-00194-01} Returns the standard error file (see A.10), or an access value designating the standard error file, respectively.
13
The Form strings implicitly associated with the opening of Standard_Input, Standard_Output, and Standard_Error at the start of program execution are implementation defined. 
14
function Current_Input return File_Type;
function Current_Input return File_Access;
15
Returns the current default input file, or an access value designating the current default input file, respectively.
16
function Current_Output return File_Type;
function Current_Output return File_Access;
17
Returns the current default output file, or an access value designating the current default output file, respectively.
18
function Current_Error return File_Type;
function Current_Error return File_Access;
19
Returns the current default error file, or an access value designating the current default error file, respectively.
20/1
{8652/0051} {AI95-00057-01} procedure Flush (File : in File_Type);
procedure Flush;
21/4
{AI12-0130-1} [The effect of Flush is the same as the corresponding subprogram in Sequential_IO (see A.8.2).] If File is not explicitly specified, Current_Output is used. 
21.a/4
Discussion: {AI12-0052-1} For the purpose of determining whether concurrent calls on text input-output subprograms are required to perform as specified, subprograms that implicitly operate on one of the default input-output files are considered to have a parameter of Current_Input or Current_Output (as appropriate). The result of Current_Output is considered to be overlapping with the file given to the latest call of Set_Output (or Standard_Output if Set_Output hasn't been called); a corresponding consideration applies to the result of Current_Input. See the introduction of Annex A for details. 

Erroneous Execution

22/1
{8652/0053} {AI95-00063-01} The execution of a program is erroneous if it invokes an operation on a current default input, default output, or default error file, and if the corresponding file object is closed or no longer exists.
22.a.1/1
Ramification: {8652/0053} {AI95-00063-01} Closing a default file, then setting the default file to another open file before accessing it is not erroneous. 
23/1
This paragraph was deleted.{8652/0053} {AI95-00063-01}
24
NOTE 1   The standard input, standard output, and standard error files cannot be opened, closed, reset, or deleted, because the parameter File of the corresponding procedures has the mode in out.
25
NOTE 2   The standard input, standard output, and standard error files are different file objects, but not necessarily different external files. 

Wording Changes from Ada 95

25.a/2
{8652/0051} {AI95-00057-01} Corrigendum: Corrected the parameter mode of Flush; otherwise it could not be used on Standard_Output.
25.b/2
{8652/0052} {AI95-00194-01} Corrigendum: Corrected Standard_Error so it refers to the correct file.
25.c/2
{8652/0053} {AI95-00063-01} Corrigendum: Clarified that execution is erroneous only when a closed default file is accessed. 

Wording Changes from Ada 2012

25.d/4
{AI12-0130-1} Corrigendum: Moved the definition of Flush to A.8.2, as all input-output packages now have it. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe