Text_IO defines functions Current_Input, Current_Output, and Current_Error; each returns a File_Type. Current_Error is like Current_Output but should be used for error messages. Here's an example of printing an error message:
Put(Current_Error, "Error - the widget file is missing.");
Procedures Set_Input, Set_Output, and Set_Error let you set the current input, output, and error files somewhere else. For example, if you want all error messages to go to file "error", do the following:
Error_File : File_Type; -- ... Create(Error_File, Out_File, "error"); Set_Error(Error_File);
Ada and the underlying operating system may delay sending output to the user to increase overall performance. This is called buffering. Usually buffering is a good idea, but sometimes you want the output to be displayed right away. In that case, use the Flush operation to immediately display everything sent to a given file (the default is Current_Output).
Sometimes you want to check the keyboard to see if a user has pressed a key, and if so, what that key was. The Ada 95 procedure to do that is called Get_Immediate. There are a few caveats with Get_Immediate:
There is no quiz question for this section.
You may go to the next section.
![]() |
![]() |
---|
David A. Wheeler (dwheeler@ida.org)