home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 15 - Programming example 2
- with Text_IO;
-
- procedure CH15_2 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;
- What : BOOLEAN := TRUE;
- Who : BOOLEAN := FALSE;
- Size : MY_FIXED := 24.33;
- Today : DAY := TUE;
-
- package Int_IO is new Text_IO.Integer_IO(INTEGER);
- package Flt_IO is new Text_IO.Float_IO(FLOAT);
- package Enum_IO is new Text_IO.Enumeration_IO(BOOLEAN);
-
- package Fix_IO is new Text_IO.Fixed_IO(MY_FIXED);
- package Day_IO is new Text_IO.Enumeration_IO(DAY);
- package New_Int_IO is new Text_IO.Integer_IO(MY_INTEGER);
-
- begin
- -- INTEGER outputs
- Text_IO.Put("Index is --->"); Int_IO.Put(Index);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("Index is --->"); Int_IO.Put(Index,3);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("Index is --->"); Int_IO.Put(Index,8);
- Text_IO.Put("<---"); Text_IO.New_Line(2);
-
- -- FLOAT outputs
- Text_IO.Put("Put(X_Value) -------->"); Flt_IO.Put(X_Value);
- Text_IO.New_Line;
- Text_IO.Put("Put(X_Value,5) ------>"); Flt_IO.Put(X_Value,5);
- Text_IO.New_Line;
- Text_IO.Put("Put(X_Value,5,5) ---->"); Flt_IO.Put(X_Value,5,5);
- Text_IO.New_Line;
- Text_IO.Put("Put(X_Value,5,5,0) -->"); Flt_IO.Put(X_Value,5,5,0);
- Text_IO.New_Line(2);
-
- -- MY_FIXED outputs
- Text_IO.Put("Put(Size) -------->"); Fix_IO.Put(Size);
- Text_IO.New_Line;
- Text_IO.Put("Put(Size,5) ------>"); Fix_IO.Put(Size,5);
- Text_IO.New_Line;
- Text_IO.Put("Put(Size,5,5) ---->"); Fix_IO.Put(Size,5,5);
- Text_IO.New_Line;
- Text_IO.Put("Put(Size,5,5,0) -->"); Fix_IO.Put(Size,5,5,0);
- Text_IO.New_Line(2);
-
- -- BOOLEAN outputs
- Text_IO.Put("What is ---->"); Enum_IO.Put(What);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("Who is ----->"); Enum_IO.Put(Who);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("What is ---->"); Enum_IO.Put(What,7);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("Who is ----->"); Enum_IO.Put(Who,8);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("TRUE is ---->"); Enum_IO.Put(TRUE);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("FALSE is --->"); Enum_IO.Put(FALSE);
- Text_IO.Put("<---"); Text_IO.New_Line(2);
-
- -- Enumeration outputs
- Text_IO.Put("Today is --->"); Day_IO.Put(Today);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("Today is --->"); Day_IO.Put(Today,6);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("Today is --->"); Day_IO.Put(Today,7);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("WED is ----->"); Day_IO.Put(WED);
- Text_IO.Put("<---"); Text_IO.New_Line;
- Text_IO.Put("WED is ----->"); Day_IO.Put(WED,5);
- Text_IO.Put("<---"); Text_IO.New_Line(2);
-
- end CH15_2;
-
-
-
-
- -- Result of execution
-
- -- Index is ---> 27<---
- -- Index is ---> 27<---
- -- Index is ---> 27<---
- --
- -- Put(X_Value) --------> 3.14000000000000E+00
- -- Put(X_Value,5) ------> 3.14000000000000E+00
- -- Put(X_Value,5,5) ----> 3.14000E+00
- -- Put(X_Value,5,5,0) --> 3.14000
- --
- -- Put(Size) --------> 24.33
- -- Put(Size,5) ------> 24.33
- -- Put(Size,5,5) ----> 24.32813
- -- Put(Size,5,5,0) --> 24.32813
- --
- -- What is ---->TRUE<---
- -- Who is ----->FALSE<---
- -- What is ---->TRUE <---
- -- Who is ----->FALSE <---
- -- TRUE is ---->TRUE<---
- -- FALSE is --->FALSE<---
- --
- -- Today is --->TUE<---
- -- Today is --->TUE <---
- -- Today is --->TUE <---
- -- WED is ----->WED<---
- -- WED is ----->WED <---
-
-