comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <dont.bother.mcondic.auntie.spam@[acm.org>
Subject: Re: Help setting up an array of records
Date: Wed, 22 May 2002 13:18:00 -0400
Date: 2002-05-22T17:18:02+00:00	[thread overview]
Message-ID: <acgjsa$9th$1@nh.pace.co.uk> (raw)
In-Reply-To: acgcbn$sue$1@paris.btinternet.com

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" <matt_ontheroad@hotmail.com> 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;
>
>





  parent reply	other threads:[~2002-05-22 17:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-22 15:09 Help setting up an array of records Matt Thomas
2002-05-22 16:39 ` Stephen Leake
2002-05-22 17:18 ` Marin David Condic [this message]
2002-05-22 17:32 ` Mark Johnson
2002-05-22 19:15 ` Preben Randhol
2002-05-23  1:58 ` Steve Doiel
  -- strict thread matches above, loose matches on Subject: below --
2002-05-26 13:00 help " Matt Thomas
2002-05-26 13:18 ` Preben Randhol
2002-05-26 13:24   ` Preben Randhol
2002-05-26 16:10     ` Matt Thomas
2002-05-28 15:01       ` Marin David Condic
2002-05-26 16:16 ` Matt Thomas
2002-05-26 19:53   ` Preben Randhol
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox