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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3c76823dab9c4a0e X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!news.banetele.no!uio.no!newsfeed1.fi.sn.net!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Tue, 13 Nov 2007 01:25:35 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: access attributes from record References: <5prshlFsgf8dU1@mid.individual.net> In-Reply-To: <5prshlFsgf8dU1@mid.individual.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4738d236$0$3500$39db0f71@news.song.fi> Organization: TDC Song Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1194906166 news.song.fi 3500 81.17.205.61:32846 X-Complaints-To: abuse@song.fi Xref: g2news1.google.com comp.lang.ada:18331 Date: 2007-11-13T01:25:35+02:00 List-Id: Dominik F�ssler wrote: > Hi > > Is it possible to determine the 'Length of a record, loop > it an get attribute name/value/type? If I understand your question correctly, you have a record type (or an object of a record type) and you want to write a loop that traverses the record's components, one by one from the first to the last, and somehow learns the name, type, and value of each component? A bit as if the record were an array, and you were traversing over the elements of the array, but in the record case the components have names instead of array indices, and may have different types? You cannot do this within you Ada application itself, but you can do something similar (at least for component names and types, but not for values) by means of the Ada Semantic Interface Standard (ASIS), in a metaprogramming fashion. That is, you pass the Ada record definition (embedded in a compilable Ada program) to an ASIS-enabled Ada compiler such as GNAT, which produces an ASIS data-base, and then you write a second Ada (meta-)program to query the ASIS data-base for the record structure. But as this is meta-programming (not reflective programming) you only have access to static type information, not to dynamic values. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .