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=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,acc23819b8999ef9,start X-Google-Attributes: gid103376,public From: R Mullen Subject: an array of records within an array of records Date: 1998/04/14 Message-ID: <3533A214.D5F94451@mcmail.com>#1/1 X-Deja-AN: 344009680 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-04-14T00:00:00+00:00 List-Id: I am trying to create a jukebox program, and part of it involves having an array of records for the cd, and within that cd array have an array of records for the cd track. Firstly displaying each cd and having the user choose a cd, then displaying all tracks for that particular cd. I have encountered two problems so far 1. I cant supply an index to the record array of cd tracks only the index to the cd's, I am using the syntax of put(new_cd_array(index).track(loop_index).title); index, being the index passed to the procedure the code is in, representing the cd selected, and loop-index representing a loop, to loop round displaying all the fields in the tracks record array. Which I thought would work, however it refuses to operate correctly. And now I have removed it from the program I cant tell you what errors it was displaying. I have also tried every variation as well, but I still cant make it work. 2. Also how do you pre initialise the tracks array of records, the only way I could think of is: new_cd_array(1):=("title1--------------","artist1-------------",("title1--------------","artist1-------------",12.34,1),1); new_cd_array(1):=("title1--------------","artist1-------------",("title2--------------","artist2-------------",12.34,2),1); new_cd_array(1):=("title1--------------","artist1-------------",("title3--------------","artist3-------------",12.34,3),1); Surely this is a long-winded way, isn't there something easier? I don't want to be spoon fed the answers, but some helpful advice would be nice. Thanks R Mullen --------------------------------------------- I have also included the record initialisation in the declarations section as well as some of the program code: Declaration section: type cd_track is record title:string(1..20); artist:string(1..20); playlength:float:=0.00; id:integer; end record; type cd_track_array is array(positive range<>) of cd_track; new_cd_track:cd_track_array(1..3); type cd is record title:string(1..20); artist:string(1..20); id:cd_track; tracks:integer; end record; type cd_array is array(positive range<>) of cd; new_cd_array:cd_array(1..3); main program: procedure individual_cd(index:in integer) is begin for loop_index in 1..3 loop put(new_cd_array(index).title); put(new_cd_array(index).track(loop_index).title); put(new_cd_array(index).artist); put(new_cd_array(index).playlength); put(new_cd_array(index).id); end loop; put_line(" "); put_line("Select a track by choosing its ID."); put_line(" "); end individual_cd; Text IO and Float IO are both in use, and I am using the latest version of the GNAT compiler.