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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,697fa9e83df511c1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-22 21:42:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!news-lond.gip.net!news.gsl.net!gip.net!easynet-melon!easynet.net!psiuk-p2!psiuk-p3!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Help setting up an array of records Date: Wed, 22 May 2002 13:18:00 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: References: NNTP-Posting-Host: dhcp-200-133.miami.pace.co.uk X-Trace: nh.pace.co.uk 1022087882 10161 136.170.200.133 (22 May 2002 17:18:02 GMT) X-Complaints-To: newsmaster@news.cam.pace.co.uk NNTP-Posting-Date: 22 May 2002 17:18:02 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:24559 Date: 2002-05-22T17:18:02+00:00 List-Id: That depends. Do you want to read the content from a file or just initialize the array with some constant values? The array you declared "PRODUCT" can have an initialization expression as part of its declaration. The expression needs to evaluate to the type PRODUCT_TYPE_ARR - so it could be a function. In general, the simplest thing to do would be to use an aggregate. Look in the Ada Reference Manual in section 4.3 for a description of aggregates for arrays and records. Also, your textbook almost certainly has a description of it, so check the index for "aggregate" there as well. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com "Matt Thomas" wrote in message news:acgcbn$sue$1@paris.btinternet.com... > I know this might be a stupid question to most of you but i have just > started using Ada. > > For my uni coursework i have to write a program to simulate a vending > machine. > > I'm using an array of records to represent the items in the vending machine > but I dont know how to actually get the information into my array. I need > to specify the name of the item, its cost and the quantity left. > > Here is the record and array declaration, any help would be grateful. > > MACHINE_SLOTS : constant := 6; -- > > type PRODUCT_TYPE is > record > NAME : STRING (1..12); > LEN : POSITIVE; > PRICE : INTEGER; > QUANTITY : INTEGER; > end record; > > type PRODUCT_TYPE_ARR is array (1..MACHINE_SLOTS) of PRODUCT_TYPE; > > PRODUCT : PRODUCT_TYPE_ARR; > >