Annotation of OpenXM_contrib/PHC/Ada/System/communications_with_user.ads, Revision 1.1
1.1 ! maekawa 1: with text_io; use text_io;
! 2:
! 3: package Communications_with_User is
! 4:
! 5: -- DESCRIPTION :
! 6: -- The routines of this package are used to
! 7: -- 1) determine the names of input/output files:
! 8: -- + create a file: prevent over-writing of important files;
! 9: -- + open a file: check first its existence.
! 10: -- 2) make selections from menu's: choose one of the alternatives.
! 11:
! 12: function Read_String return string;
! 13:
! 14: -- DESCRIPTION :
! 15: -- Reads a string from standard input and returns it to the caller.
! 16: -- The length of the input string must be smaller than 80 characters.
! 17:
! 18: generic
! 19: with function Valid_Alternative ( alt : character ) return boolean;
! 20: procedure Ask ( ans : out character );
! 21:
! 22: -- DESCRIPTION :
! 23: -- This procedure keeps reading a character from standard input,
! 24: -- until a valid one has been given.
! 25: -- The function Valid_Alternative decides whether a certain
! 26: -- character corresponds to a valid answer to the question.
! 27:
! 28: procedure Ask_Yes_or_No ( ans : out character );
! 29:
! 30: -- DESCRIPTION :
! 31: -- Keeps reading a character from standard output,
! 32: -- until the user gives a 'y' or a 'n'.
! 33:
! 34: procedure Ask_Alternative ( ans : out character; alternatives : in string );
! 35:
! 36: -- DESCRIPTION :
! 37: -- This procedure keeps reading a character from standard input,
! 38: -- until a character that belongs to the string s has been given.
! 39:
! 40: procedure Ask_Alternative
! 41: ( ans : in out string; alternatives : string;
! 42: prefix : in character );
! 43:
! 44: -- DESCRIPTION :
! 45: -- Ask the user to give a character that occurs in the string of
! 46: -- alternatives, eventually preceded by the given prefix character.
! 47: -- This procedure keeps reading till a valid choice has been made.
! 48:
! 49: -- REQUIRED : ans'range = 1..2.
! 50:
! 51: procedure Read_Name_and_Open_File ( file : in out file_type );
! 52:
! 53: -- DESCRIPTION :
! 54: -- This procedure reads a name from standard input and
! 55: -- tries to open this file for input.
! 56: -- If this is unsuccesful, then another name will be asked.
! 57:
! 58: procedure Read_Name_and_Create_File ( file : in out file_type );
! 59:
! 60: -- DESCRIPTION :
! 61: -- This procedure reads a name from standard input and
! 62: -- a file with this name will be created for output.
! 63: -- If a file with the given name already exists,
! 64: -- the user will be asked if the existing file may be destroyed.
! 65:
! 66: procedure Open_Input_File
! 67: ( file : in out file_type; filename : in string );
! 68:
! 69: -- DESCRIPTION :
! 70: -- Tries to open a file for input, starting with the given file name.
! 71: -- If the opening of the file with the given name is not succesful,
! 72: -- then the procedure `Read_Name_and_Open_File' will be invoked.
! 73:
! 74: procedure Create_Output_File
! 75: ( file : in out file_type; filename : in string );
! 76:
! 77: -- DESCRIPTION :
! 78: -- This procedure creates an output file, starting with the given
! 79: -- file name. If the creation of a file with this name is unsuccesful,
! 80: -- then the procedure `Read_Name_and_Create_File' will be invoked.
! 81:
! 82: end Communications_with_User;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>