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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a21dfb63457ea960 X-Google-Attributes: gid103376,public From: johnherro@aol.com (John Herro) Subject: Re: array of matrices Date: 1996/05/03 Message-ID: <4mdjbq$df7@newsbf02.news.aol.com>#1/1 X-Deja-AN: 152832243 sender: root@newsbf02.news.aol.com references: <4m9aeb$d0e@news2.h1.usa.pipeline.com> organization: America Online, Inc. (1-800-827-6364) newsgroups: comp.lang.ada Date: 1996-05-03T00:00:00+00:00 List-Id: boaz@usa.pipeline.com(Boaz Chow) writes: > type Matrix is array (integer range <>, integer range <>) of integer; > I want to set up a variable for array (1..N) of Matrix; > I know this won't work: A : array (1..N) of Matrix; You're right. You can't directly set up an array of an unconstarined type. There are two things you can do. One is to allow for the largest possible matrix for every element in the array, and keep track of the number of rows and columns actually used: type Square15 is array(1 .. 15, 1 .. 15) of Integer; type Matrix is record Data : Square15; Rows : Integer; Columns : Integer; end record; ... A : array(1 .. N) of Matrix; ... A(1).Rows := 5; A(1).Columns := 15; A(2).Rows := 15; A(2).Columns := 7; ... This has the disadvantage of using more memory than you actually need, but is perhaps a bit simpler than the second way. The second way is to declare an array of *pointers*. Each pointer can point to a different size matrix: type Matrix is array(Integer range <>, Integer range <>) of Integer; type Ptr is access Matrix; ... A : array(1 .. N) of Ptr; ... A(1) := new Matrix(1 .. 5, 1 .. 15); A(2) := new Matrix(1 .. 15, 1 .. 7); ... I hope this helps. - John Herro Software Innovations Technology http://members.aol.com/AdaTutor ftp://members.aol.com/AdaTutor