From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.14.38 with SMTP id c35mr79233otc.38.1475531941892; Mon, 03 Oct 2016 14:59:01 -0700 (PDT) X-Received: by 10.157.26.54 with SMTP id a51mr19950ote.0.1475531941863; Mon, 03 Oct 2016 14:59:01 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!l13no1962042itl.0!news-out.google.com!203ni6025itk.0!nntp.google.com!o19no36634ito.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 3 Oct 2016 14:59:01 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:2c4:101:d816:f193:77d7:742e:e2ce; posting-account=bfqYCQoAAADhOBV9jx08D2gm5EA72sgj NNTP-Posting-Host: 2601:2c4:101:d816:f193:77d7:742e:e2ce References: <44638b2d-c7fb-4113-9262-d57dd1cd5629@googlegroups.com> <241a25d0-e840-4d2f-b39f-e5bcdf9a6209@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <23322f1c-76c2-4ab5-8098-421a3394bc04@googlegroups.com> Subject: Re: Passing a 2d array into a package and returning the same processed 2d back to main From: James Brewer Injection-Date: Mon, 03 Oct 2016 21:59:01 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31982 Date: 2016-10-03T14:59:01-07:00 List-Id: On Monday, October 3, 2016 at 2:44:01 PM UTC-5, bj=C3=B6rn 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 wro= te: > >> Hello again, new Ada programmer with a hopefully easy question.=20 > >> I am trying to take a 2d array pass it to a package have the package c= hange the data in the 2d array and send the same 2d array (with modified da= ta) back to the main program. I am currently away from my computer or I wou= ld show you my broken code, though I doubt it would be useful.=20 > >> > >> Thanks > >=20 > >=20 > > PACKAGE BODY WarshallsPkg IS > > =20 > > PROCEDURE WarshallExecute(InArray : IN MY_ARRAY; OutArray : OUT MY_A= RRAY) IS > >=20 > > -- TestArray: ARRAY(InArray'FIRST..InArray'LAST) OF Integer; > >=20 > > BEGIN > > FOR I IN InArray'FIRST..InArray'LAST LOOP > > FOR J IN InArray'FIRST..InArray'LAST LOOP > > IF InArray(J,I) =3D True THEN --true nodes connected > > FOR K IN InArray'FIRST..InArray'LAST LOOP > > OutArray(J,K) :=3D InArray(J,K) OR InArray(I,K); > > END LOOP; > > END IF; > > END LOOP; > > END LOOP; > >=20 > > END WarshallExecute; > > =20 > > END WarshallsPkg; > >=20 >=20 > try >=20 > 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) :=3D Arr(J,K) or Arr(I,K); > end loop; > end if; > end loop; > end loop; > end WarshallExecute; > end WarshallsPkg; >=20 >=20 > and then >=20 >=20 >=20 > > WarshallExecute(Array2d, Array2d); >=20 > WarshallsPkg.WarshallExecute(Array2d); >=20 >=20 > You pass the same array both as in and out to WarshallExecute. > Why not pass it as in out ? >=20 >=20 >=20 >=20 > --=20 > -- > Bj=C3=B6rn Thanks for the help. It's hard to know what a language can and cannot do wh= en 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 wi= th what Jeffery was alluding too but I don't know enough to say for sure.