-- Some standard types and their output
-- These are all PRIMITIVE types (meaning what?)
with ada.text_io; use ada.text_io;
with ada.float_text_io; use ada.float_text_io;
with ada.integer_text_io; use ada.integer_text_io;
procedure types1 is
-- The libraries withed above handle Character, String, Float and Integer
-- No preexisting library exists for Boolean because it is an enumerated type
-- and so we make a library for it
package boolean_io is new ada.text_io.enumeration_io(Boolean);
use boolean_io; -- We created it, now let's use it
i: Integer := 11;
n: Natural := 22; -- 0 or greater: Why is this a good thing?
p: Positive := 33; -- Greater than 0
f: Float := 44.44; -- 3. and .3 not allowed. Why?
b: Boolean := true;
c: Character := 'x';
begin
-- OUTPUT IMAGES WITH TEXT_IO
put_line(i'img);
put_line(n'img);
put_line(p'img);
put_line(f'img);
put_line(b'img);
-- OUTPUT WITH SPECIFIC LIBRARIES
put(i); new_line;
put(n); new_line;
put(p); new_line;
put(f); new_line;
put(f, fore => 5, aft => 1, exp => 0); -- Explicit format. Keyword parameters.
-- fore=left, aft=right, exp=exponent digits
new_line;
put(f, fore => 1, aft => 6, exp => 0);
new_line;
put(c); new_line;
put(b); new_line;
end types1;
-- Output:
--| 11
--| 22
--| 33
--| 4.44400E+01
--|TRUE
--| 11
--| 22
--| 33
--| 4.44400E+01
--| 44.4
--|44.439999
--|x
--|TRUE