-- ======================================================================== -- Standard_IO.ADS [by Richard Riehle, AdaWorks Software Engineering -- -- This IO package gets and puts data on a terminal. It is designed -- as a wrapper for Text_IO (Ada.Text_IO) and is completely portable. -- It will work with Ada 83 or Ada 95. There are not Ada 95 features. -- It has no random cursor positioning. I/O for Integer and Float is -- pre-instantiated. Use type Answer for dialogue management. A "sloppy" -- option simplifies Float input. The "sloppiness" of Sloppy Float -- is sloppier than the sloppy float of Ada 95. A Prompt option is -- provided for Get operations to simplify dialogue management. Also, -- a limited private type, Answer, allows you to write programs that -- accept input of Y, y, Yes, N, n, No. The input is not case sensitive. -- operations. Nested catenators can be made visible with the "use" clause. -- Copyright 1999, AdaWorks Software Engineering. This is free software. -- You may copy it, modify it for your own purposes as long as you include -- attribution in your copies. No warranty is made of correctness of this -- software. You should always subject free software to your own set of -- quality assurance procedures. -- ========================================================================= package Standard_IO is type Answer is limited private; -- Values are (N, No, Y, Yes) -- Answer is for dialogue management procedure New_Line(Number : Positive := 1); procedure Set_Col(Number : Positive); -- must be > current column procedure Flush_Input_Line; -- sometimes required for scalar input procedure Put (Data : in Integer); procedure Put (Data : in Long_Integer); procedure Put (Data : in Character); procedure Put (Data : in String); procedure Put_Line(Data : in String); -- carriage return/line feed procedure Put (Data : in Float; Fore, Aft : in Positive); -- Every Get operation has a version with a Prompt of type String procedure Get(Data : out String; Last : out Natural); procedure Get(Prompt : in String; Data : out String; Last : out Natural); -- BasicIO.Get(Prompt => "Enter: ", Data => STR, Last => Len); procedure Get(Data : in out Answer); -- for limited private type procedure Get(Prompt : in String; Data : in out Answer); function Get return Character; -- X : Character := Get; function Get return Integer; function Get return Long_Integer; function Get (Sloppy : in Boolean := False) return Float; -- (Sloppy => True) permits sloppy input of floating point function Get (Prompt : in String) return Character; function Get (Prompt : in String) return Integer; function Get (Prompt : in String; Sloppy : in Boolean := False) return Float; -- Ada 95 Text_IO defaults to sloppy Float; Ada 83 does not. -- Answer is limited private. These operations are required. function Is_Yes (Value : Answer) return Boolean; -- test Answer function Is_No (Value : Answer) return Boolean; -- test Answer package Catenators is -- use BasicIO.Catenators for infix visibility function "&" (L : Integer; R : String) return String; function "&" (L : String; R : Integer) return String; function "&" (L : Long_Integer; R : String) return String; function "&" (L : String; R : Long_Integer) return String; function "&" (L : Float; R : String) return String; function "&" (L : String; R : Float) return String; -- Long_Float if your compiler supports it. Remove the comments -- from this specification and corresponding implementations -- in the package body. Then recompile it. -- function "&" (L : Long_Float; R : String) return String; -- function "&" (L : String; R : Long_Float) return String; end Catenators; Device_Error : exception; Invalid_Data : exception; private type Answer is (N, No, Y, Yes); -- Use for dialogue management end Standard_IO;