065.Ada.Text.IO的单独实例化

这里声明了 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;
   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;
     
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值