package body FloaAKD is ---------------------------------------------------------------------- ---------------------------------------------------------------------- -- Copyright (C) 1994 David Wallace Croft. All rights reserved. ---------------------------------------------------------------------- ---------------------------------------------------------------------- function Ask ( Prompt : string := ""; Default : float := 0.0; Minimum : float := - float'safe_large; Maximum : float := + float'safe_large; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp ) return float is ---------------------------------------------------------------------- Item : string ( 1..79 ); Last : natural; Temp : float; Bad_Entry : boolean; 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, Last ); exception when others => begin Temp := float ( integer'value ( Item ( 1..Last ) ) ); exception when others => Bad_Entry := true; end; end; if Bad_Entry then New_Line; Put ( "Unrecognized. Please enter a float number like " ); Put ( Default, Fore, Aft, Exp ); Put_Line ( "." ); else exit when ( Minimum <= Temp ) and ( Temp <= Maximum ); New_Line; Put ( "Out of range. Please enter a value between " ); Put ( Minimum, Fore, Aft, Exp ); Put ( " and " ); Put ( Maximum, Fore, Aft, Exp ); Put ( "." ); end if; end loop; return Temp; end Ask; procedure Put_Line ( Item : in float; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := 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 Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp ) is ---------------------------------------------------------------------- begin Put ( File, Item, Fore, Aft, Exp ); New_Line ( File ); end Put_Line; ---------------------------------------------------------------------- ---------------------------------------------------------------------- end FloaAKD;