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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,eb9238bef304c5d4 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.glorb.com!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Using discriminant record: problem with assigning to an array in body Reply-To: no to spamers (No@email.given.org) References: <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Tue, 17 Mar 2009 20:24:42 GMT NNTP-Posting-Host: 12.64.186.237 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1237321482 12.64.186.237 (Tue, 17 Mar 2009 20:24:42 GMT) NNTP-Posting-Date: Tue, 17 Mar 2009 20:24:42 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:5133 Date: 2009-03-17T20:24:42+00:00 List-Id: -- try this one: -- procedure test is type GOODS_TYPE is ( LIQUID, TEXTILE); -- Ada prefers array to be predefined for usage in records type float_array is array ( 0..5 ) of float; type TYPE_GOODS( GOODS_TYPE_SELECTION : GOODS_TYPE) is record case GOODS_TYPE_SELECTION is when LIQUID => ITEM_NAME : float_array ; -- new type defined and stops compiler errors when TEXTILE => LENGTH : float; WIDTH : float; end case; end record; A : TYPE_GOODS( LIQUID ); begin A := ( GOODS_TYPE_SELECTION => LIQUID, ITEM_NAME => (1.0, 1.1, 1.2, 1.3, 1.4,1.5) ); end test; In <976bd0a5-4aff-4f40-83c7-c6b7829ab4d8@s9g2000prg.googlegroups.com>, ChristopherL writes: >The below procedure compiles and links fine, but when I run it I get a >"discriminant check failed" error message. Can you please modify this >code so that the array assignment works. > >procedure test is > >type GOODS_TYPE is ( LIQUID, TEXTILE); > >type TYPE_GOODS( GOODS_TYPE_SELECTION : GOODS_TYPE) is > record > > case GOODS_TYPE_SELECTION is > when LIQUID => > ITEM_NAME : is array ( 0..5 ) of float; > > when TEXTILE => > LENGTH : float; > WIDTH : float; > end case; > end record; > > A : TYPE_GOODS( LIQUID ); > > begin > > A := ( GOODS_TYPE_SELECTION => LIQUID, > ITEM_NAME => (1.0, 1.1, 1.2, 1.3, 1.4,1.5) ); > >end test;