Previous topic | Ada Home Page | Index

Example: Library Units

Standard I/O libraries for integers and floats can be compiled and entered into an Ada library. They are then available for use by other programs, which need only to import them with WITH statements.

The way you would do this depends on the ada environment you are using:


Sun ada

basic_io.a

------------------------------------------------------------
-- Define standard I/O packages for numbers
--
-- Chris Lokan
-- 26 July 1995
------------------------------------------------------------

with TEXT_IO;
package int_io is new TEXT_IO.INTEGER_IO(INTEGER);

with TEXT_IO;
package float_io is new TEXT_IO.FLOAT_IO(FLOAT);

Compilation

adac basic_io.a


gnat ada

int_io.ads

------------------------------------------------------------
-- int_io.ads - Declare standard integer I/O package
--
-- Lawrie Brown / 4 Aug 95
------------------------------------------------------------

with TEXT_IO;
package int_io is new TEXT_IO.INTEGER_IO(INTEGER);

float_io.ads

------------------------------------------------------------
-- float_io.ads - Declare standard float I/O package
--
-- Lawrie Brown / 4 Aug 95
------------------------------------------------------------

with TEXT_IO;
package float_io is new TEXT_IO.FLOAT_IO(FLOAT);

Compilation

gnatcc int_io.ads
gnatcc float_io.ads


Previous topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 17 Feb 1996