with ConsAK; package body FloaAK is ---------------------------------------------------------------------- ---------------------------------------------------------------------- function Ask ( Prompt : string := ""; Default : float := 0.0; Minimum : float := - float'safe_large; Maximum : float := + float'safe_large; Fore : Text_IO.Field := Float_IO.Default_Fore; Aft : Text_IO.Field := Float_IO.Default_Aft; Exp : Text_IO.Field := Float_IO.Default_Exp ) return float is ---------------------------------------------------------------------- Item : string ( 1..79 ); Last : natural; Temp : float; Bad_Entry : boolean; Dummy_Pos : positive; begin loop Bad_Entry := false; Put ( Prompt & "(" ); Put ( Minimum, Fore, Aft, Exp ); Put ( ".." ); Put ( Maximum, Fore, Aft, Exp ); Put ( ") [" ); Put ( Default, Fore, Aft, Exp ); Put ( "]: " ); Get_Line ( Item, Last ); if Last = 0 then return Default; end if; begin Get ( Item ( 1..Last ), Temp, Dummy_Pos ); exception when Constraint_Error => Bad_Entry := true; end; if Bad_Entry then New_Line; Put_Line ( "Please enter a value in floating-point format." ); Put_Line ( "For example, instead of entering 0, enter 0.0." ); ConsAK.Pause; else exit when ( Minimum <= Temp ) and ( Temp <= Maximum ); New_Line; Put ( "Please enter a value between " ); Put ( Minimum, Fore, Aft, Exp ); Put ( " and " ); Put ( Maximum, Fore, Aft, Exp ); Put ( "." ); ConsAK.Pause; end if; end loop; return Temp; end Ask; procedure Put_Line ( Item : in float; Fore : in Text_IO.Field := Float_IO.Default_Fore; Aft : in Text_IO.Field := Float_IO.Default_Aft; Exp : in Text_IO.Field := Float_IO.Default_Exp ) is ---------------------------------------------------------------------- begin Put ( Item, Fore, Aft, Exp ); New_Line; end Put_Line; procedure Put_Line ( File : in File_Type; Item : in float; Fore : in Text_IO.Field := Float_IO.Default_Fore; Aft : in Text_IO.Field := Float_IO.Default_Aft; Exp : in Text_IO.Field := Float_IO.Default_Exp ) is ---------------------------------------------------------------------- begin Put ( File, Item, Fore, Aft, Exp ); New_Line ( File ); end Put_Line; function Value ( From : string ) return float is ---------------------------------------------------------------------- Item : float; Last : positive; begin Get ( From, Item, Last ); return Item; end Value; ---------------------------------------------------------------------- ---------------------------------------------------------------------- end FloaAK;