comp.lang.ada
 help / color / mirror / Atom feed
* about ADTs
@ 2001-07-19 20:38 Beau
  2001-07-20 16:28 ` Stephen Leake
  0 siblings, 1 reply; 2+ messages in thread
From: Beau @ 2001-07-19 20:38 UTC (permalink / raw)


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?

--
~Beau~
beau@hiwaay.net






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: about ADTs
  2001-07-19 20:38 about ADTs Beau
@ 2001-07-20 16:28 ` Stephen Leake
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Leake @ 2001-07-20 16:28 UTC (permalink / raw)


"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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-20 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-19 20:38 about ADTs Beau
2001-07-20 16:28 ` Stephen Leake

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