home *** CD-ROM | disk | FTP | other *** search
- -- Chapter 14 - Program 1
- with Text_IO;
- use 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 Text_IO.Integer_IO(INTEGER);
- use Int_IO;
- package Flt_IO is new Text_IO.Float_IO(FLOAT);
- use Flt_IO;
- package Enum_IO is new Text_IO.Enumeration_IO(BOOLEAN);
- use Enum_IO;
-
- package Fix_IO is new Text_IO.Fixed_IO(MY_FIXED);
- use Fix_IO;
- package Day_IO is new Text_IO.Enumeration_IO(DAY);
- use Day_IO;
- package New_Int_IO is new Text_IO.Integer_IO(MY_INTEGER);
- use New_Int_IO;
-
- begin
- -- INTEGER outputs
- 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 outputs
- 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;
-
-
-
-
- -- Result of execution
-
- -- Index is ---> 27<---
- -- Index is ---> 27<---
- -- Index is ---> 27<---
- --
- -- Count is ---> -7<---
- -- Count is ---> -7<---
- -- Count is ---> -7<---
- --
- -- 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 <---
-
-