comp.lang.ada
 help / color / mirror / Atom feed
* How to include shared code
@ 2013-09-19  0:17 Emanuel Berg
  2013-09-19  5:31 ` Peter Brooks
  2013-09-19  7:20 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 4+ messages in thread
From: Emanuel Berg @ 2013-09-19  0:17 UTC (permalink / raw)


If I have two files:

protected_buffer.adb
bounded_buffer.adb

and those compile and run fine.

But, in both those, I have this piece of code:

function Random_Integer return integer is
   type Span is range 1..9;
   package Random_Integer is new Ada.Numerics.Discrete_Random(Span);
   Seed    : Random_Integer.Generator;
   Outcome : Span;
begin
   Random_Integer.Reset(seed);
   Outcome := Random_Integer.Random(seed);
   return INTEGER(Outcome);
end Random_Integer;

function Random_Period return Time_Span is
begin
   return Milliseconds(Random_Integer*100);
end Random_Period;

Now, how can I extract that piece of code from both files, and put
it into another file, say, random_period.adb, and then "include"
it into each of the above files (that operate in isolation)?

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-19  7:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-19  0:17 How to include shared code Emanuel Berg
2013-09-19  5:31 ` Peter Brooks
2013-09-19  6:24   ` Simon Wright
2013-09-19  7:20 ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox