comp.lang.ada
 help / color / mirror / Atom feed
From: James Brewer <firstvestor@gmail.com>
Subject: Re: Passing a 2d array into a package and returning the same processed 2d back to main
Date: Mon, 3 Oct 2016 14:59:01 -0700 (PDT)
Date: 2016-10-03T14:59:01-07:00	[thread overview]
Message-ID: <23322f1c-76c2-4ab5-8098-421a3394bc04@googlegroups.com> (raw)
In-Reply-To: <nsucdi$rv3$1@dont-email.me>

On Monday, October 3, 2016 at 2:44:01 PM UTC-5, björn lundin wrote:
> On 2016-10-03 20:36, James Brewer wrote:
> > On Friday, September 30, 2016 at 5:28:01 PM UTC-5, dia...@gmail.com wrote:
> >> Hello again, new Ada programmer with a hopefully easy question. 
> >> I am trying to take a 2d array pass it to a package have the package change the data in the 2d array and send the same 2d array (with modified data) back to the main program. I am currently away from my computer or I would show you my broken code, though I doubt it would be useful. 
> >>
> >> Thanks
> > 
> > 
> > PACKAGE BODY WarshallsPkg IS
> >    
> >    PROCEDURE WarshallExecute(InArray : IN MY_ARRAY; OutArray : OUT MY_ARRAY) IS
> > 
> > --   TestArray: ARRAY(InArray'FIRST..InArray'LAST) OF Integer;
> > 
> >    BEGIN
> >    FOR I IN InArray'FIRST..InArray'LAST LOOP
> >       FOR J IN InArray'FIRST..InArray'LAST LOOP
> >          IF InArray(J,I) = True THEN --true nodes connected
> >             FOR K IN InArray'FIRST..InArray'LAST LOOP
> >                OutArray(J,K) := InArray(J,K) OR InArray(I,K);
> >             END LOOP;
> >          END IF;
> >       END LOOP;
> >    END LOOP;
> > 
> >    END WarshallExecute;
> >    
> > END WarshallsPkg;
> > 
> 
> try
> 
> package body WarshallsPkg is
>    procedure WarshallExecute(Arr : in out My_Array) is
>    begin
>    for I in Arr'range loop
>       for J in Arr'range loop
>          if Arr(J,I) then --true nodes connected
>             for k in Arr'range loop
>                Arr(J,K) := Arr(J,K) or Arr(I,K);
>             end loop;
>          end if;
>       end loop;
>    end loop;
>  end WarshallExecute;
> end WarshallsPkg;
> 
> 
> and then
> 
> 
> 
> >   WarshallExecute(Array2d, Array2d);
> 
> WarshallsPkg.WarshallExecute(Array2d);
> 
> 
> You pass the same array both as in and out to WarshallExecute.
> Why not pass it as in out ?
> 
> 
> 
> 
> -- 
> --
> Björn

Thanks for the help. It's hard to know what a language can and cannot do when your just starting out. Unfortunately, I'm still getting an error saying [expected type"MY_ARRAY" defined at warshallspkg.ads:5 warshallmain.adb:60:20: found type Array2d declare at line 19]. It may have something to do with what Jeffery was alluding too but I don't know enough to say for sure.

  reply	other threads:[~2016-10-03 21:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 22:27 Passing a 2d array into a package and returning the same processed 2d back to main diane74
2016-10-01  0:01 ` Jeffrey R. Carter
2016-10-01 20:01 ` Aurele
2016-10-01 21:04   ` Jeffrey R. Carter
2016-10-01 21:59     ` Aurele
2016-10-01 22:16       ` Jeffrey R. Carter
2016-10-02  0:09         ` Aurele
2016-10-02  7:31           ` Simon Wright
2016-10-03 18:36 ` James Brewer
2016-10-03 19:43   ` Björn Lundin
2016-10-03 21:59     ` James Brewer [this message]
2016-10-03 23:16       ` Anh Vo
2016-10-04 11:29       ` Brian Drummond
2016-10-05 16:16         ` James Brewer
2016-10-05 17:19           ` James Brewer
2016-10-05 18:57             ` Jeffrey R. Carter
2016-10-05 19:53               ` James Brewer
2016-10-05 19:57                 ` AdaMagica
2016-10-05 20:17                 ` Jeffrey R. Carter
2016-10-05 20:58                   ` James Brewer
2016-10-05 22:11                     ` Anh Vo
2016-10-05 19:47             ` Anh Vo
2016-10-05 20:30               ` James Brewer
2016-10-03 20:16   ` Jeffrey R. Carter
replies disabled

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