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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,769e61538eb61436 X-Google-Attributes: gid103376,public From: David Morton Subject: Re: Variant record assignment Q: Date: 1996/07/10 Message-ID: <31E3A1FE.1DD3FFEE@jinx.sckans.edu>#1/1 X-Deja-AN: 167570289 references: <31E32A82.3984D09E@jinx.sckans.edu> content-type: text/plain; charset=us-ascii organization: student mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (X11; I; Linux 2.0.0 i486) Date: 1996-07-10T00:00:00+00:00 List-Id: David Morton wrote: > > hello again... > 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, Max_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; > > What's the quickest way to instantiate this? > I would like to be able to say, > > Tmp : String_Ptr; > Root : Object_Ptr; > > Tmp := new String("test"); > Root := new Object(Button)'(Status => Button, X => 10, Y => 10, Name => Tmp, Status => > Something); > > but I get errors, both with the string and record instantiations. > I've tried several variations, but no better... > > One particular error I tend to get (that is confusing me)is: > > Tmp := new String'("test"); > > 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" > > Thanks for any help! > > (I'll figure this stuff out yet!) whoops... forgot to mention Ada95 here... gnat on Linux... -- David Morton mailto:dmorton@jinx.sckans.edu http://www.sckans.edu/~dmorton/ 205 College, Winfield, KS 67156 This signature will self-destruct in 10 seconds...