comp.lang.ada
 help / color / mirror / Atom feed
From: Steve O'Neill <smoneill@sanders.lockheed.com>
Subject: Re: Variant record assignment Q:
Date: 1996/07/11
Date: 1996-07-11T00:00:00+00:00	[thread overview]
Message-ID: <31E5271A.6B67@sanders.lockheed.com> (raw)
In-Reply-To: 31E3A1FE.1DD3FFEE@jinx.sckans.edu


David Morton wrote:
> given the specification:
>
> type String_Ptr is access all string;
> type Object_Type is (Field, Button);
> type Object;
> type Object_Ptr is access Object;
> type Object(Obj : Object_Type) is record
>   Status : Object_Type;
>   Next, Prev : Object_Ptr;
>   case Obj is
>     when Field =>
>       Label_X, Label_Y, 
>       Field_X, Field_Y, 
>       Buffer_Size, x_Buffer_Size : natural;
>       Buffer : String_Ptr;
>       Field_Name : String_Ptr;
>     when Button =>
>       X, Y : natural;
>       Name : String_Ptr;
>       Status_Code : Return_Code;
>   end case;
> end record;
>
> One particular error I tend to get (that is confusing me)is:
>
> Root := new Object(Obj => Button); -- line 24 BTW
> Root.all := (Status => Button, X => 10,Y => 10, Name => Tmp, 
>              Status_Code => This);
>
> user_info_management.adb:25:13: no value supplied for discriminant obj"

That's because Obj (the discriminant) is also part of the record and
must be assigned a value.  So the assignment would be:
  Root.all := (Obj => Button,
               Status => Button, 
               Next => Something,
               Previous => Something,
               X => 10,Y => 10, 
               Name => Tmp, 
               Status_Code => This);

Assuming valid values for Something, Tmp and This, of course.  Perhaps
this is what you had in mind by having the Status component.

-- 
Steve O'Neill                      | "No,no,no, don't tug on that!
Sanders, A Lockheed Martin Company |  You never know what it might
smoneill@sanders.lockheed.com      |  be attached to." 
(603) 885-8774  fax: (603) 885-4071|    Buckaroo Banzai




  reply	other threads:[~1996-07-11  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-09  0:00 Variant record assignment Q: David Morton
1996-07-10  0:00 ` David Morton
1996-07-11  0:00   ` Steve O'Neill [this message]
1996-07-10  0:00 ` Jon S Anthony
replies disabled

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