comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: about ADTs
Date: 20 Jul 2001 12:28:21 -0400
Date: 2001-07-20T16:45:38+00:00	[thread overview]
Message-ID: <uvgknimze.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: tlehc36ma4rge2@corp.supernews.com

"Beau" <beau@hiwaay.net> writes:

> In the child package for an ADT I need to get an enumerated type. Would I
> instantiate a package to read the enumerated data inside the child package?
> How would I write the child package get? would it look like this:
> --in the spec file for the child package
> PROCEDURE Get(File : IN Ada.Text_IO.File_Type;
>                                   Item : OUT Account);  --Account is a
> record containing a seperate ADT value Date, the
>                                                                          --e
> numeration type and a float value
> 
> --then inside the body of the child package:
> PROCEDURE Get(File : IN Ada.Text_IO.File_Type;
>                                    Item : OUT Account) IS
>     --here I would get the Dates from the other ADT package I am using
>     --here is where I would get the enumeration type
>     Enumeration_IO.Get( Item => TransKind);
>     --Here I get the Amount
>     Ada.Integer_Text_IO.Get(Item => Amount);
> 
> END Get;
> 
> does this look remotely right?

"remotely", yes. Here's an attempt to fix things:

procedure Get (File : in  Ada.Text_IO.File_Type;
               Item : out Account)
is
    package Account_Enum_IO is new Ada.Text_IO.Enumeration_IO (Enum_Type);
begin
   --here I would get the Dates from the other ADT package I am using
   Account_Enum_IO.Get (Item.TransKind);
   Ada.Integer_Text_IO.Get (Item.Amount);
end Get;

You need to instantiate the generic package Ada.Text_IO.Enumeration_IO
(I guessed at the name of the enumeration type). Record components are
accessed by ".", not "=>".

Hope this helps,

-- 
-- Stephe



      reply	other threads:[~2001-07-20 16:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-19 20:38 about ADTs Beau
2001-07-20 16:28 ` Stephen Leake [this message]
replies disabled

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