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-Thread: 103376,e52f7c34095c85e5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!attbi_s53.POSTED!53ab2750!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: unconstrained array type problems References: <40fea9b7@dnews.tpgi.com.au> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 24.6.132.82 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s53 1090434640 24.6.132.82 (Wed, 21 Jul 2004 18:30:40 GMT) NNTP-Posting-Date: Wed, 21 Jul 2004 18:30:40 GMT Organization: Comcast Online Date: Wed, 21 Jul 2004 18:30:40 GMT Xref: g2news1.google.com comp.lang.ada:2328 Date: 2004-07-21T18:30:40+00:00 List-Id: >open (file) > >read in dimensions of array1 >create the array1 >fill the array1 > >read in dimensions of array2 >create the array2 >fill the array2 > >close (file) > >allow the arrays to interact with one another >--- > >I cannot see a way around this. Repeating and expanding on Marius Amado Alves message: > > How can i make them visible to one another? This is so easy to do in > > c++/java. > > This is extremely easy in Ada with the proper design, namely with these > two entities: > > type Matrix is array (Positive range <>, Positive range <>) of Real; function Read_Matrix(File : File_Type) return Matrix is Row_Count, Column_Count : Positive; begin Get (File, Row_Count); Get (File, Column_Count); declare Result: Matrix_Type (1 .. Row_Count, 1 .. Column_Count); begin -- read in matrix data return Result; end; end Read_Matrix; > > Then read all the matrices you want in the same place: > procedure Do_Matrices is > Matrix_1 : Matrix := Read_Matrix(File); > Matrix_2 : Matrix := Read_Matrix(File); Product : Matrix(Matrix_1'range(1), Matrix_2'range(2)); -- for example begin -- do stuff with Matrix_1 and Matrix_2 end Do_Matrices;