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,HK_RANDOM_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,48bf593f723b7524 X-Google-Attributes: gid103376,public From: czgrr Subject: Re: Can I have an array of variant records? Date: 1999/04/21 Message-ID: <7fkruq$878$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 469135546 References: <371c84fb.0@silver.truman.edu> <87aew3j899.fsf@bglbv.my-dejanews.com> <7fk8c6$mbe$1@nnrp1.dejanews.com> <371DC9BE.585254A6@wbkst21.mach.uni-karlsruhe.de> X-Http-Proxy: 1.0 x3.dejanews.com:80 (Squid/1.1.22) for client 193.192.234.4 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Apr 21 15:47:40 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT) Date: 1999-04-21T00:00:00+00:00 List-Id: In article <371DC9BE.585254A6@wbkst21.mach.uni-karlsruhe.de>, kobylarz@wbkst21.mach.uni-karlsruhe.de wrote: > How to alter the discriminant? I searched in several different sources of > documentation > and I have not found that. > > I declared variant record: > > type Tool_Operation(action : Action_Type := Wait) is > record > case action is > when Wait => howlong : time; > when Move => where : position; min_time : time; > end case; > end record; > > Let's define variable: > > top : Tool_Operation; > > But such statement does not compile: > > top.action := Move; > > The compiler returns error: "left hand side of assignment must be a > variable" > > How to alter the discriminant? The discriminant can not be assigned directly, like the other fields in the record. In order to assign it, you must also assign every other field in that variant at the same time, otherwise they would be undefined. Hence, you have to do something like this... top := ( action => Move, where => ..., -- these are part of min_time => ... ) ; -- the "Move" variant Changing the discriminant back to "Wait" is a similar process. BTW, that means that you lose the previous value of "howlong". czgrr -- My opinions, suggestions, etc, are not necessarily those of my employer. They might not even be right. Use at your own risk. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own