comp.lang.ada
 help / color / mirror / Atom feed
From: maysee@m11.sews.wpafb.af.mil (Eric E. Mays 52202)
Subject: Ada Tasking problem
Date: Thu, 21 Nov 91 08:04:51 EST	[thread overview]
Message-ID: <9111211304.AA10751@m11.sews.wpafb.af.mil> (raw)

Info-Ada Folks,

   I am currently taking a computer aided Ada course developed by 
keesler afb.  The last topic in this course involves tasking.  I am
trying to solve the following problem using tasking with entry point.

   The output i'm trying to display is the following:

           1          5
           2          4
           3          3
           4          2
           5          1

    I'm assuming these are to be printed concurrently.  The results i'm
displaying are:   

                      5
                      4
                      3
                      2
                      1
           1
           2
           3
           4
           5

   Here is my code, am I missing something?

with TEXT_IO;

procedure MAIN_TW1 is

   package MY_INT_IO is new TEXT_IO.INTEGER_IO (INTEGER);

   LAST_NUMBER : INTEGER;

   task REV_NUM_OUT is
      entry RECEIVE_NUM (MAX_NUMBER : in INTEGER);
   end REV_NUM_OUT;

   task body REV_NUM_OUT is

      MAX_NUM : INTEGER;

   begin

      accept RECEIVE_NUM (MAX_NUMBER : in INTEGER) do

         MAX_NUM := MAX_NUMBER;

         for I in reverse 1 .. MAX_NUM loop

             TEXT_IO.SET_COL (35);
             MY_INT_IO.PUT (I,WIDTH=>1); 
             text_io.new_line;

         end loop;

      end RECEIVE_NUM;

   end REV_NUM_OUT;


begin

   TEXT_IO.PUT ("Enter an integer number: ");
   MY_INT_IO.GET (LAST_NUMBER);
   TEXT_IO.NEW_PAGE;

   REV_NUM_OUT.RECEIVE_NUM (LAST_NUMBER);

   for J in 1 .. LAST_NUMBER loop

      TEXT_IO.SET_COL (1);
      MY_INT_IO.PUT (J);

   end loop;

end MAIN_TW1; 

   Any helpful hints or comments would be appreciated.

Thanks,

Eric Mays
maysee@m11.sews.wpafb.af.mil

             reply	other threads:[~1991-11-21 13:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-11-21 13:04 Eric E. Mays 52202 [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-11-23  0:03 Ada Tasking problem cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usen
1991-11-25  0:04 Bob Kitzberger
1991-11-25  4:04 cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!ogicse!milton
1991-11-25 17:02 agate!spool.mu.edu!wupost!zaphod.mps.ohio-state.edu!ub!dsinc!gvlf3.gvl.un
1991-11-26  9:10 paul goffin
replies disabled

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