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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5f2c12e14eeb0f5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-21 16:37:44 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!intgwpad.nntp.telstra.net!news.telstra.net!news-server.bigpond.net.au!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: Can you use arrays from another package ? References: User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Message-ID: Date: Tue, 21 May 2002 23:37:43 GMT NNTP-Posting-Host: 144.132.91.90 X-Complaints-To: news@bigpond.net.au X-Trace: news-server.bigpond.net.au 1022024263 144.132.91.90 (Wed, 22 May 2002 09:37:43 EST) NNTP-Posting-Date: Wed, 22 May 2002 09:37:43 EST Organization: BigPond Internet Services (http://www.bigpond.net.au) Xref: archiver1.google.com comp.lang.ada:24489 Date: 2002-05-21T23:37:43+00:00 List-Id: Jon wrote: > say the main program is calle MAIN.ADB > > and uses 2 packages X and Y > > if there is an array of records in X called A. > > how do i use the array A in Y ? > > e.g > > package body X is > type R is record > hi : string; > bye : integer; > end record; > > A : array(1..10) of R; > > end X; > > > now in Y, how do i use that array ? ive tried this : you need a "with, use" clause at the start of either Y's package spec, or it's package body. You'll also need to wrap up the call to get inside a procedure... e.g. with X; use X; > package body Y is procedure Get_Hi is begin > get( X.A(1).hi ); end; > > end Y; That's how to get it working; however i think it's a bad design. My design rule is "never declare variables in a package spec". The declaration of A would be better in Main, and then you pass it into procedure Get_Hi as a parameter. A big mistake that people make it to treat packages as objects - a good way to view them is just as a place where type declarations and subprograms go. (this is not quite the only way to view them, but it's a good first step). Dale