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,bd40601768eaf8fd X-Google-Attributes: gid103376,public From: mcc@entropy.cs.princeton.edu (Martin C. Carlisle) Subject: Re: Thank you Date: 1999/09/08 Message-ID: <7r6ea2$pr8$1@cnn.Princeton.EDU>#1/1 X-Deja-AN: 522638498 References: <7r5vh3$imu1@svlss.lmms.lmco.com> <7r6acf$imu3@svlss.lmms.lmco.com> Organization: US Air Force Academy, Dept of Computer Science Newsgroups: comp.lang.ada Date: 1999-09-08T00:00:00+00:00 List-Id: It sounds like you did something like the following: with ada.integer_text_io; with ada.text_io; procedure test_discrim is type bob(discrim : integer := 1) is record dummy : integer; end record; type fred is array(integer range <>) of bob; x : fred(1..10); begin for i in x'range loop x(i) := bob'(discrim => i, dummy => 0); end loop; for i in x'range loop ada.integer_text_io.put(x(i).discrim); ada.text_io.new_line; end loop; end test_discrim; But, I still don't see why discrim can't just be a field of the record. (I guess you do have the advantage that discrim can't be modified w/o reassigning the entire record.) --Martin In article <7r6acf$imu3@svlss.lmms.lmco.com>, Bruce Detter wrote: > >Bruce Detter wrote in message >news:7r5vh3$imu1@svlss.lmms.lmco.com... >> How do you declare an array of variant records where each variant record's >> descriminant is the array index? Can it be done at all? I would prefer >not >> to use access pointers if it can be avoided. >Thank you for your response, a little experimentation based on Mr. Heaney's >solution provided the answer. I used a default variant for the array type >declaration, and "re-initialized" the array elements to what I wanted when >the array was instanciated. > >Professor Carlisle, I have several "message" structures I receive, each with >1 or more states I need to represent with ascii characters. I wanted to >have a single place where I could look up the ascii characters up based on >the message type and state. There is probably several ways I could have >done this including wrapping the message structure with in a tagged record >and using polymorphism, but I choose the down and dirty, brute force method >(for the time being) -- Martin C. Carlisle, Asst Prof of Computer Science, US Air Force Academy carlislem@acm.org, http://www.usafa.af.mil/dfcs/bios/carlisle.html DISCLAIMER: This content in no way reflects the opinions, standards or policy of the US Air Force Academy or the United States Government.