package body InteAK is ---------------------------------------------------------------------- ---------------------------------------------------------------------- function Ask_Int ( Prompt : string := ""; Default : integer := integer'first; Minimum : integer := integer'first; Maximum : integer := integer'last; Width : Field := integer'width ) return integer is ---------------------------------------------------------------------- Temp_Str : string ( 1..Width ) := ( others => ASCII.Nul ); Last : natural; Temp : integer; begin loop Put ( Prompt & "(" & integer'image ( Minimum ) & ".." & integer'image ( Maximum ) & ") [" & integer'image ( Default ) & "]: " ); Get_Line ( Temp_Str, Last ); begin if Last = 0 then return Default; else Temp := integer'value ( Temp_Str ( 1..Last ) ); end if; if Temp < Minimum then Put_Line ( "Please enter a value greater than or equal to " & integer'image ( Minimum ) & "." ); elsif Temp > Maximum then Put_Line ( "Please enter a value less than or equal to " & integer'image ( Maximum ) & "." ); else exit; end if; exception when others => Put_Line ( "Please enter an integer number between " & integer'image ( Minimum ) & " and " & integer'image ( Maximum ) & " inclusive." ); end; end loop; return Temp; end Ask_Int; function Ask_Nat ( Prompt : in string := ""; Default : in natural := natural'first; Minimum : in natural := natural'first; Maximum : in natural := natural'last; Width : in Field := natural'width ) return natural is ---------------------------------------------------------------------- Temp_Str : string ( 1..Width ) := ( others => ASCII.Nul ); Last : natural; Temp : natural; begin loop Put ( Prompt & "(" & natural'image ( Minimum ) & ".." & natural'image ( Maximum ) & ") [" & natural'image ( Default ) & "]: " ); Get_Line ( Temp_Str, Last ); begin if Last = 0 then return Default; else Temp := natural'value ( Temp_Str ( 1..Last ) ); end if; if Temp < Minimum then Put_Line ( "Please enter a value greater than or equal to " & natural'image ( Minimum ) & "." ); elsif Temp > Maximum then Put_Line ( "Please enter a value less than or equal to " & natural'image ( Maximum ) & "." ); else exit; end if; exception when others => Put_Line ( "Please enter an integer number between " & natural'image ( Minimum ) & " and " & natural'image ( Maximum ) & " inclusive." ); end; end loop; return Temp; end Ask_Nat; function Ask_Pos ( Prompt : in string := ""; Default : in positive := positive'first; Minimum : in positive := positive'first; Maximum : in positive := positive'last; Width : in Field := positive'width ) return positive is ---------------------------------------------------------------------- Temp_Str : string ( 1..Width ) := ( others => ASCII.Nul ); Last : natural; Temp : positive; begin loop Put ( Prompt & "(" & positive'image ( Minimum ) & ".." & positive'image ( Maximum ) & ") [" & positive'image ( Default ) & "]: " ); Get_Line ( Temp_Str, Last ); begin if Last = 0 then return Default; else Temp := positive'value ( Temp_Str ( 1..Last ) ); end if; if Temp < Minimum then Put_Line ( "Please enter a value greater than or equal to " & positive'image ( Minimum ) & "." ); elsif Temp > Maximum then Put_Line ( "Please enter a value less than or equal to " & positive'image ( Maximum ) & "." ); else exit; end if; exception when others => Put_Line ( "Please enter an integer number between " & positive'image ( Minimum ) & " and " & positive'image ( Maximum ) & " inclusive." ); end; end loop; return Temp; end Ask_Pos; procedure Put ( File : in File_Type; Item : in long_integer; Width : in Field := long_integer'width; Base : in Number_Base := 10 ) is ---------------------------------------------------------------------- package IntL_IO is new Text_IO.Integer_IO ( long_integer ); begin IntL_IO.Put ( File, Item, Width, Base ); end Put; procedure Put_Line ( Item : in integer; Width : in Field := integer'width; Base : in Number_Base := 10 ) is ---------------------------------------------------------------------- begin Put ( Item, Width, Base ); New_Line; end Put_Line; procedure Put_Line ( File : in File_Type; Item : in integer; Width : in Field := integer'width; Base : in Number_Base := 10 ) is ---------------------------------------------------------------------- begin Integer_IO.Put ( File, Item, Width, Base ); New_Line ( File ); end Put_Line; procedure Put_Line ( File : in File_Type; Item : in long_integer; Width : in Field := long_integer'width; Base : in Number_Base := 10 ) is ---------------------------------------------------------------------- package IntL_IO is new Text_IO.Integer_IO ( long_integer ); begin IntL_IO.Put ( File, Item, Width, Base ); New_Line ( File ); end Put_Line; ---------------------------------------------------------------------- ---------------------------------------------------------------------- end InteAK;