with Ada.Text_IO;
use Ada.Text_IO;
procedure Formats is
type MY_FIXED is delta 0.01 range 20.0..42.0;
type DAY is (MON,TUE,WED,THU,FRI,SAT,SUN);
type MY_INTEGER is range -13..323;
X_Value:Float :=3.14;
Index:Integer:=27;
Count:MY_INTEGER:=-7;
What:Boolean:=TRUE;
Who:Boolean:=False;
Size:MY_FIXED:=24.33;
Today:DAY:=TUE;
package Int_IO is new Ada.Text_IO.Integer_IO(Integer);
use Int_IO;
package Flt_IO is new Ada.Text_IO.Float_IO(Float);
use Flt_IO;
package Enum_IO is new Ada.Text_IO.Enumeration_IO(Boolean);
use Enum_IO;
package Fix_IO is new Ada.Text_IO.Fixed_IO(MY_FIXED);
use Fix_IO;
package Day_IO is new Ada.Text_IO.Enumeration_IO(DAY);
use Day_IO;
package New_Int_IO is new Ada.Text_IO.Integer_IO(MY_INTEGER);
use New_Int_IO;
begin
-- integer output
Put("Index is --->");Put(Index);Put("<---");New_Line;Put("Index is --->");Put(Index,3);Put("<---"); New_Line;Put("Index is --->");Put(Index,8);Put("<---");New_Line(2);Put("Count is --->");Put(Count);Put("<---"); New_Line;Put("Count is --->");Put(Count,3);Put("<---"); New_Line;Put("Count is --->");Put(Count,8);Put("<---");New_Line(2);--float output
Put("Put(X_Value)------>");Put(X_Value); New_Line;Put("Put(X_Value,5)------>");Put(X_Value,5); New_Line;Put("Put(X_Value,5,5)------>");Put(X_Value,5,5); New_Line;Put("Put(X_Value,5,5,0)------>");Put(X_Value,5,5,0);New_Line(2);-- MY_FIXED outputs
Put("Put(Size) -------->");Put(Size); New_Line;Put("Put(Size,5) ------>");Put(Size,5); New_Line;Put("Put(Size,5,5) ---->");Put(Size,5,5); New_Line;Put("Put(Size,5,5,0) -->");Put(Size,5,5,0);New_Line(2);-- BOOLEAN outputs
Put("What is ---->");Put(What);Put("<---"); New_Line;Put("Who is ----->");Put(Who);Put("<---"); New_Line;Put("What is ---->");Put(What,7);Put("<---"); New_Line;Put("Who is ----->");Put(Who,8);Put("<---"); New_Line;Put("TRUE is ---->");Put(TRUE);Put("<---"); New_Line;Put("FALSE is --->");Put(FALSE);Put("<---");New_Line(2);-- Enumeration outputs
Put("Today is --->");Put(Today);Put("<---"); New_Line;Put("Today is --->");Put(Today,6);Put("<---"); New_Line;Put("Today is --->");Put(Today,7);Put("<---"); New_Line;Put("WED is ----->");Put(WED);Put("<---"); New_Line;Put("WED is ----->");Put(WED,5);Put("<---");New_Line(2);
end Formats;
这里声明了 Ada.Text_IO的六个单独的实例化,以便与程序中使用的六种类型一起使用,为了输出我们在此程序中使用的各种类型,这些都是必需的。在声明各种类型后,必须声明包实例化。with Ada.Text_IO;use Ada.Text_IO;procedure Formats is type MY_FIXED is delta 0.01 range 20.0..42.0;...